API Reference¶
HLA_vae (in themap.model)¶
train_model(train_loader, lr, epochs, device)¶
Train the HLA VAE model using MSE loss and KL divergence.
Parameters¶
Name |
Type |
Description |
|---|---|---|
|
|
Batches of input HLA tensors. |
|
|
Learning rate. |
|
|
Number of training epochs. |
|
|
Device to run training (e.g., |
Returns¶
None.
embed_hla(hla_loader, device)¶
Generate latent embeddings for HLA sequences using the trained encoder.
Parameters¶
Name |
Type |
Description |
|---|---|---|
|
|
Batches of input HLA sequences. |
|
|
Computation device. |
Returns¶
Tuple[np.ndarray, np.ndarray]
z_hla_mean: latent mean vectorsz_conv: intermediate convolutional features
PEP_vae (in themap.model)¶
train_model(train_loader, lr, epochs, device)¶
Train peptide VAE using reconstruction + KL + alignment loss.
Parameters¶
Name |
Type |
Description |
|---|---|---|
|
|
Batches of |
|
|
Learning rate. |
|
|
Number of training epochs. |
|
|
CUDA or CPU device. |
Returns¶
None.
embed_pep(data_loader, device)¶
Embed peptides using the trained VAE encoder.
Parameters¶
Name |
Type |
Description |
|---|---|---|
|
|
Peptide batches. |
|
|
Device for inference. |
Returns¶
Tuple[np.ndarray, np.ndarray]
z_pep_mean: latent mean embeddingsz_conv: intermediate conv features
THE (in themap.model)¶
train_model(...)¶
Train the full THE model using labeled TCR-target binding pairs.
Parameters¶
Name |
Type |
Description |
|---|---|---|
|
|
Training set with TCR, target, and label. |
|
|
Number of training epochs. |
|
|
Training device. |
|
|
Batch size (default: 256). |
|
|
Learning rate (default: 1e-4). |
|
|
One of |
|
|
|
|
|
Required if |
|
|
Additional data to append. |
|
|
Enable negative sampling (default: |
|
|
Resample negatives each epoch (default: |
|
|
Max alpha CDR3 length. |
|
|
Max beta CDR3 length. |
|
|
Max peptide length. |
Returns¶
None.
test_model(...)¶
Evaluate trained THE model on a test set or test loader.
Parameters¶
Name |
Type |
Description |
|---|---|---|
|
|
Test set DataFrame. |
|
|
Batch size. |
|
|
If provided, skip DataFrame. |
|
|
Required for HLA targets. |
|
|
CPU or CUDA. |
|
|
|
|
|
|
|
|
Max alpha CDR3 length. |
|
|
Max beta CDR3 length. |
|
|
Max peptide length. |
Returns¶
Tuple[Tensor, Tensor, Tensor]
scores: predicted binding scoresalpha_attn: attention for alphabeta_attn: attention for beta