sceptr.variant#

For the curious/power users, several model variants are available to load and use through this submodule. The submodule exposes functions, each named after a particular variant, which when called will return a Sceptr instance corresponding to the selected model variant. Sceptr instances expose the same methods as in the functional API: namely calc_pdist_vector(), calc_cdist_matrix(), and calc_vector_representations(). Each of their function signatures are equivalent to the functional API, so you can just plug and play!

sceptr.variant.a_sceptr()#

Load the alpha chain-only variant of SCEPTR. This variant has the same architecture as the default, but is specifically trained only with the alpha chain in distribution. Thus, this model cannot interpret paired-chain or beta chain-only data.

Important

This variant is unrelated to the single-chain analysis in our manuscript, which involved applying the default() model to single-chain data. In contrast, this variant is a distinct model that was pre-trained specifically only on alpha chains.

Note

Because this model is trained only with the alpha chain in distribution, we expect it to perform slightly better than the default in settings where strictly only the alpha chains are available. However, in most cases where a mix of alpha, beta, and paired-chain data are available, we recommend using the default for ease of use.

Returns:

A Sceptr instance with the alpha chain-only model state loaded.

Return type:

Sceptr

sceptr.variant.average_pooling()#

Load the average-pooling variant of SCEPTR. This variant uses the average-pooling method to generate TCR embeddings, instead of the <cls> pooling solution used by the default.

Returns:

A Sceptr instance with the average-pooling model state loaded.

Return type:

Sceptr

sceptr.variant.b_sceptr()#

Load the beta chain-only variant of SCEPTR. This variant has the same architecture as the default, but is specifically trained only with the beta chain in distribution. Thus, this model cannot interpret paired-chain or alpha chain-only data.

Important

This variant is unrelated to the single-chain analysis in our manuscript, which involved applying the default() model to single-chain data. In contrast, this variant is a distinct model that was pre-trained specifically only on beta chains.

Note

Because this model is trained only with the beta chain in distribution, we expect it to perform slightly better than the default in settings where strictly only the beta chains are available. However, in most cases where a mix of alpha, beta, and paired-chain data are available, we recommend using the default for ease of use.

Returns:

A Sceptr instance with the beta chain-only model state loaded.

Return type:

Sceptr

sceptr.variant.blosum()#

Load the BLOSUM variant of SCEPTR. The embedder module of this variant uses columns/rows of the BLOSUM62 substitution matrix to generate the initial vector embeddings of the amino acid residue tokens, instead of the one-hot solution used by the default.

Returns:

A Sceptr instance with the BLOSUM model state loaded.

Return type:

Sceptr

sceptr.variant.cdr3_only()#

Load the CDR3-only variant of SCEPTR. This variant only uses the CDR3 loops as input.

Returns:

A Sceptr instance with the CDR3-only model state loaded.

Return type:

Sceptr

sceptr.variant.cdr3_only_mlm_only()#

Load the CDR3-only MLM-only variant of SCEPTR. This variant only uses CDR3 loops as input, and did not receive autocontrastive learning.

Returns:

A Sceptr instance with the CDR3-only MLM-only model state loaded.

Return type:

Sceptr

sceptr.variant.default()#

Load the default variant of SCEPTR.

Returns:

A Sceptr instance with the default model state loaded. Calling methods on this Sceptr instance is equivalent to using the functional API.

Return type:

Sceptr

sceptr.variant.dropout_noise_only()#

Load the dropout noise only variant of SCEPTR. This variant did not receive any residue/chain dropping noising signal during autocontrastive learning, and instead relied entirely on the model’s internal dropout noise.

Returns:

A Sceptr instance with the dropout noise only model state loaded.

Return type:

Sceptr

sceptr.variant.finetuned()#

Load the fine-tuned variant of SCEPTR. This variant is fine-tuned using supervised contrastive learning for six pMHCs with peptides GILGFVFTL, NLVPMVATV, SPRWYFYYL, TFEYVSQPFLMDLE, TTDPSFLGRY and YLQPRTFLL (from VDJdb)

Note

This model is fine-tuned explicity for discriminating between the pMHC specificities listed above. While it does indeed become much better than the default model at that specific task, its general performance is otherwise demonstrably worse compared to the default.

Returns:

A Sceptr instance with the fine-tuned model state loaded.

Return type:

Sceptr

sceptr.variant.large()#

Load the large variant of SCEPTR. This is a larger variant with model dimensionality 128 instead of 64.

Returns:

A Sceptr instance with the large model state loaded.

Return type:

Sceptr

sceptr.variant.left_aligned()#

Load the left-aligned variant of SCEPTR. This is similar to the default model, but with learnable token embeddings and a sinusoidal position information embedding method more similar to the original NLP BERT/transformer models.

Returns:

A Sceptr instance with the left-aligned model state loaded.

Return type:

Sceptr

sceptr.variant.mlm_only()#

Load the MLM-only variant of SCEPTR. This is the default model trained without autocontrastive learning.

Returns:

A Sceptr instance with the MLM-only model state loaded.

Return type:

Sceptr

sceptr.variant.shuffled_data()#

Load the shuffled-data variant of SCEPTR. This variant was trained on the same Tanno et al. dataset as the default, but with alpha-beta chain pairing randomised.

Returns:

A Sceptr instance with the shuffled-data model state loaded.

Return type:

Sceptr

sceptr.variant.small()#

Load the small variant of SCEPTR. This is a smaller variant with model dimensioanlity 32 instead of 64.

Returns:

A Sceptr instance with the small model state loaded.

Return type:

Sceptr

sceptr.variant.synthetic_data()#

Load the synthetic-data variant of SCEPTR. This variant was trained on a size-matched set of synthetic TCR sequences generated by OLGA, a probabilistic model of VDJ recombination.

Returns:

A Sceptr instance with the synthetic-data model state loaded.

Return type:

Sceptr

sceptr.variant.tiny()#

Load the tiny variant of SCEPTR. This is a tiny variant with model dimensionality 16 instead of 64.

Returns:

A Sceptr instance with the tiny model state loaded.

Return type:

Sceptr