Enhancing TCR specificity predictions by combined pan- and peptide-specific training, loss-scaling, and sequence similarity integration

  1. Mathias Fynbo Jensen
  2. Morten Nielsen  Is a corresponding author
  1. Department of Health Technology, Section for Bioinformatics, Technical University of Denmark, Denmark
14 figures, 4 tables and 3 additional files

Figures

Architecture of the pre-trained model.

The pan-specific CNN block consists of the layers shown in blue, whereas the peptide-specific CNN block consists of the layers shown in red. During the pan-specific training, the weights and biases for the peptide-specific CNN block are frozen, whereas the opposite is the case during the peptide-specific training. The layers shown in purple are kept unfrozen during both training steps.

Per peptide performance of the peptide-specific and pan-specific NetTCR 2.1 in terms of AUC, when trained and evaluated on the new dataset.

The peptides are sorted based on the number of positive observations from most abundant to least abundant, with the number of positive observations listed next to the peptide sequence. The unweighted (direct) mean of AUC across all peptides is shown furthest to the left, while the weighted mean is shown second furthest to the left. The weighted mean is weighted by the number of positive observations per peptide and puts more emphasis on the peptides with the most observations. The models included in this figure corresponds to model 1 (NetTCR 2.1 - Pan) and model 2 (NetTCR 2.1 - Peptide) in Supplementary file 1.

Figure 3 with 1 supplement
Boxplot of AUC of the pan- and peptide-specific NetTCR 2.1 and 2.2 models, respectively.

The NetTCR 2.2 models include the updates to the model architecture, with the primary change being the introduction of dropout for the concatenated max-pooling layer (dropout rate = 0.6). Both the introduction of dropout and sample weights are shown to result in considerably improved performance for the pan-specific model. Separate boxplots are shown for all peptides, as well as separately for peptides with at least 100 positive observations and peptides with less than 100 positive observations, to highlight the effect of introducing dropout and sample weight for the least abundant peptides. The models included in this figure corresponds to model 1 (NetTCR 2.1 - Pan), model 3 (NetTCR 2.2 - Pan +Dropout), model 4 (NetTCR 2.2 - Pan +Dropout + Sample Weight), model 2 (NetTCR 2.1 - Peptide) and model 5 (NetTCR 2.2 - Peptide +Dropout) in Supplementary file 1.

Figure 3—figure supplement 1
Boxplot of AUC 0.1 of the pan- and peptide-specific NetTCR 2.1 and 2.2 models, respectively.

The NetTCR 2.2 models include the updates to the model architecture, with the primary change being the introduction of dropout for the concatenated max-pooling layer (dropout rate = 0.6). Both the introduction of dropout and sample weights are shown to result in considerably improved performance for the pan-specific model. Separate boxplots are shown for all peptides, as well as separately for peptides with at least 100 positive observations and peptides with less than 100 positive observations, to highlight the effect of introducing dropout and sample weight for the least abundant peptides. The models included in this figure corresponds to model 1 (NetTCR 2.1 - Pan), model 3 (NetTCR 2.2 - Pan +Dropout), model 4 (NetTCR 2.2 - Pan +Dropout + Sample Weight), model 2 (NetTCR 2.1 - Peptide), and model 5 (NetTCR 2.2 - Peptide +Dropout) in Supplementary file 1.

Mean AUC of the pan-specific and peptide-specific NetTCR 2.2 models, when training on the original redundancy reduced training data, and with redundant observations back.

The AUC is reported in terms of weighted and unweighted mean across all peptides, as well as unweighted mean when the data is split into peptides with at least 100 positive observations, and less than 100 positive observations. The models included in this figure corresponds to model 4 (NetTCR 2.2 - Pan), model 6 (NetTCR 2.2 - Pan - Add Redundant), model 5 (NetTCR 2.2 - Peptide), and model 7 (NetTCR 2.2 - Peptide - Add Redundant) in Supplementary file 1.

Figure 5 with 3 supplements
Difference in AUC between pan-specific CNN trained on the limited dataset (70th percentile) and full dataset.

Peptides with TCRs originating solely from 10 x sequencing are highlighted in red. The performance was in both cases evaluated per peptide on the full dataset. A positive ΔAUC indicates that the model trained on the limited dataset performs better than the model trained on the full dataset. The performance differences are based on the performance of model 10 and model 4 in Supplementary file 1, with model 4 being the baseline.

Figure 5—figure supplement 1
Prediction values on the full test data for each peptide when predicted using the NetTCR 2.2 - Peptide model.

The prediction scores are shown for model 5 in Supplementary file 1.

Figure 5—figure supplement 2
Mean AUC of the pan-specific NetTCR 2.2 models when trained on datasets with potential outliers removed.

The percentile refers to the threshold of prediction scores used for removing observations (see Materials and methods), and the higher the percentile is, the more observations are removed from training. The AUC is reported in terms of weighted and unweighted mean across all peptides, as well as unweighted mean when the data is split into peptides with at least 100 positive observations, and less than 100 positive observations. The performance is based on model 4 (All data), model 8 (50th percentile), model 9 (60th percentile), model 10 (70th percentile), model 11 (80th percentile), model 12 (85th percentile), model 13 (90th percentile), and model 14 (95th percentile) in Supplementary file 1.

Figure 5—figure supplement 3
Percentage of observations discarded for the 70th percentile limited dataset, as a result of the removal of potential outliers.
Figure 6 with 1 supplement
Per peptide performance of the updated peptide-specific, pan-specific, and pre-trained CNN in terms of AUC, when trained on the limited training dataset and evaluated on the full dataset.

The peptides are sorted based on the number of positive observations from most abundant to least abundant, with the number of positive observations listed next to the peptide sequence. The unweighted (direct) mean of AUC across all peptides is shown furthest to the left, while the weighted mean is shown second furthest to the left. The weighted mean is weighted by the number of positive observations per peptide and puts more emphasis on the peptides with the most observations. The models included in this figure corresponds to model 10 (NetTCR 2.2 - Pan), model 15 (NetTCR 2.2 - Peptide), model 16 (NetTCR 2.2 - Pre-trained) and model 17 (TCRbase ensemble) in Supplementary file 1.

Figure 6—figure supplement 1
Per peptide performance of the updated peptide-specific, pan-specific, and pre-trained CNN in terms of AUC 0.1, when trained on the limited training dataset and evaluated on the full dataset.

The peptides are sorted based on the number of positive observations from most abundant to least abundant, with the number of positive observations listed next to the peptide sequence. The unweighted (direct) mean of AUC across all peptides is shown furthest to the left, while the weighted mean is shown second furthest to the left. The weighted mean is weighted by the number of positive observations per peptide and puts more emphasis on the peptides with the most observations. The models included in this figure corresponds to model 10 (NetTCR 2.2 - Pan), model 15 (NetTCR 2.2 - Peptide), model 16 (NetTCR 2.2 - Pre-trained), and model 17 (TCRbase ensemble) in Supplementary file 1.

Figure 7 with 1 supplement
Performance of TCRbase ensemble as a function of α along with boxplot of optimal alpha in terms of AUC and AUC 0.1 for the validation partitions.

(A) The predictions of the pre-trained model ensemble (trained on the limited dataset) on the test partitions (full data) were scaled by the kernel similarity to known binders, as given by TCRbase with a weight of (1,1,3,1,1,3), to a power of α. The performance is given as the unweighted mean performance across all 26 peptides, in terms of AUC and AUC 0.1. The dashed line shows the performance when α is set to 10, which strikes a good balance between AUC and AUC 0.1. An α of zero corresponds to the model ensemble without the TCRbase scaling. (B) Boxplot of the optimal alpha scaling factor per cross-validation model, when evaluated in terms of AUC and AUC 0.1, respectively, on the validation partitions. The models used for calculating the performance of the ensembles in this figure are model 16 (NetTCR 2.2 - Pre-trained) and model 21 (TCRbase) in Supplementary file 1.

Figure 7—figure supplement 1
Difference in true positive rate (TPR) between TCRbase ensemble (pre-trained +TCRbase models) and pre-trained models as a function of false positive rate (FPR).

A positive ΔTPR corresponds to an increased performance of the TCRbase ensemble compared to the pre-trained models alone. The models used for this figure are model 16 (NetTCR 2.2 - Pre-trained) and model 17 (TCRbase ensemble) in Supplementary file 1.

Boxplot of direct prediction scores and percentile ranks per peptide of the full test dataset for the TCRbase ensemble.

Peptides with 100% of positive observations coming from 10 X sequencing are highlighted in red. The model used in this figure is model 17 (TCRbase ensemble) in Supplementary file 1.

Figure 9 with 1 supplement
Percentage of correctly chosen true peptide-TCR pairs for each peptide in the limited dataset.

This was evaluated using the direct prediction score (blue) and the percentile rank (orange) of the TCRbase ensemble. KLGGALQAK, AVFDRKSDAK, NLVPMVATV, CTELKLSDY, RLRAEAQVK, RLPGVLPRA, and SLFNTVATLY were excluded from this analysis due to low predictive performance for these peptides (AUC 0.1<0.65). The numbers next to the peptides indicate the number of positive TCRs in the filtered dataset, and the dashed line indicates the expected value for a random prediction. The predictions are based on model 17 (TCRbase ensemble) in Supplementary file 1.

Figure 9—figure supplement 1
Boxplot of average rank per peptide for the final updated models.

The rank was evaluated on the limited dataset covering 21 peptides, that is excluding the peptides with low performance (KLGGALQAK, AVFDRKSDAK, NLVPMVATV, CTELKLSDY, RLRAEAQVK, RLPGVLPRA and SLFNTVATLY). The models used in this figure corresponds to model 21 (TCRbase), model 10 (NetTCR 2.2 - Pan), model 15 (NetTCR 2.2 - Peptide), model 16 (NetTCR 2.2 - Pre-trained), and model 17 (TCRbase ensemble) in Supplementary file 1.

Boxplot of percentile ranks per peptide in the rank test, with KLGGALQAK, NLVPMVATV, CTELKLSDY, RLRAEAQVK, RLPGVLPRA, and SLFNTVATLY excluded.

AVFDRKSDAK was included as an example of a peptide with a poor rank in the rank test. Top TP: Percentile rank of the correctly chosen pairs. Second TN: Percentile rank of the second-best pair, when the correct pair was chosen. Top FP: Percentile rank of the best scoring pair when the incorrect pair was chosen. FN: Percentile rank of the correct pair, when the incorrect pair was chosen. The predictions are based on model 17 in Supplementary file 1.

Figure 11 with 1 supplement
Per peptide performance of the old (NetTCR 2.1) and updated (NetTCR 2.2) pan-specific CNN models trained in a leave-one-out setup.

The performance was evaluated in terms of AUC on the full dataset. The performance shown in this figure is based on model 63 (NetTCR 2.1 - Leave one out) and model 19 (NetTCR 2.2 - Leave one out) in Supplementary file 1.

Figure 11—figure supplement 1
Per peptide performance of the old (NetTCR 2.1) and updated (NetTCR 2.2) pan-specific CNN models trained in a leave-one-out setup.

The performance was evaluated in terms of AUC on the full dataset. The performance shown in this figure is based on model 63 (NetTCR 2.1 - Leave one out) and model 19 (NetTCR 2.2 - Leave one out) in Supplementary file 1.

Figure 12 with 1 supplement
Performance in terms of AUC of various models trained on increasing amounts of data.

These models were trained on the following peptides: GILGFVFTL, RAKFKQLL, ELAGIGILTV, IVTDFSVIK, LLWNGPMAV, CINGVCWTV, GLCTLVAML, and SPRWYFYYL. The pre-trained models were based on the leave-one-out model, and afterwards fine-tuned and re-trained on the smaller training datasets. The performance shown is based on the predictions for model 24–51 in Supplementary file 1.

Figure 12—figure supplement 1
Performance in terms of AUC 0.1 of various models trained on increasing amounts of data.

These models were trained on the following peptides: GILGFVFTL, RAKFKQLL, ELAGIGILTV, IVTDFSVIK, LLWNGPMAV, CINGVCWTV, GLCTLVAML and SPRWYFYYL. The pre-trained models were based on the leave-one-out model, and afterwards fine-tuned and re-trained on the smaller training datasets. The performance shown is based on the predictions for model 24–51 in Supplementary file 1.

Figure 13 with 1 supplement
Boxplot of reported unweighted AUC per peptide for the models in the IMMREP benchmark, as well as the updated NetTCR 2.2 models.

Except for the updated NetTCR 2.2 models (NetTCR 2.2 - Pan, NetTCR 2.2 - Peptide, NetTCR 2.2 - Pre-trained and TCRbase ensemble) the performance of all models is equal to the reported performance in the IMMREP benchmark. The color of the bars indicates the type of input used by the model. Machine-learning models are labeled with black text, whereas distance-based models are labeled with blue text. Note that the TCRbase ensemble is a mixture between a machine-learning and distance-based model. The performance of the NetTCR 2.2 models is based on model 53 (NetTCR 2.2 - Pan), model 54 (NetTCR 2.2 - Peptide), model 55 (NetTCR 2.2 - Pre-trained), and model 56 (TCRbase ensemble) in Supplementary file 2. The performance of the remaining models are based on the values listed in the IMMREP 2022 GitHub repository at https://github.com/viragbioinfo/IMMREP_2022_TCRSpecificity/blob/main/evaluation/microaucs.csv.

Figure 13—figure supplement 1
Boxplot of average rank per peptide per model in the IMMREP test data, as reported in the IMMREP benchmark.

The updated NetTCR 2.2 models are included to the right. The color of the bars indicates the type of input used by the model. Machine-learning models are labeled with black text, whereas distance-based models are labeled with blue text. Note that the TCRbase ensemble is a mixture between a machine-learning and distance-based model. The mean rank of the NetTCR 2.2 models are based on model 53 (NetTCR 2.2 - Pan), model 54 (NetTCR 2.2 - Peptide), model 55 (NetTCR 2.2 - Pre-trained), and model 56 (TCRbase ensemble) in Supplementary file 2. The mean rank of the remaining models are based on the values listed in the IMMREP 2022 GitHub repository at https://github.com/viragbioinfo/IMMREP_2022_TCRSpecificity/blob/main/evaluation/epitoperank.csv.

Boxplot of unweighted AUC per peptide for the NetTCR 2.1 and 2.2 models, when trained and evaluated on the redundancy reduced dataset.

The evaluation was performed using a nested cross-validation setup. The performance is based on model 58 (NetTCR 2.1 - Peptide), model 59 (NetTCR 2.2 - Pan), model 60 (NetTCR 2.2 - Peptide), model 61 (NetTCR 2.2 - Pre-trained), and model 62 (TCRbase ensemble) in Supplementary file 2.

Tables

Table 1
Per peptide overview of the full positive training data.

The source organism for each epitope, as well as the MHC allele which they bind to, are here shown. Additionally, the number of observations discarded during each redundancy reduction step, as well as the total remaining number of observations, are also listed, along with the number of observations originating from 10 x sequencing.

PeptideOrganismMHCPre reduction countRemoved in first reductionRemoved in second reductionPost reduction countNot 10 X10 X
GILGFVFTLInfluenza A virusHLA-A*02:0118976451271125426699
RAKFKQLLEpstein Barr virusHLA-B*08:011065114179340934
KLGGALQAKHuman CMVHLA-A*03:01912829020902
AVFDRKSDAKEpstein Barr virusHLA-A*11:01725547160716
ELAGIGILTVMelanoma neoantigenHLA-A*02:014356342655371
NLVPMVATVHuman CMVHLA-A*02:013844311330154176
IVTDFSVIKEpstein Barr virusHLA-A*11:013231323080308
LLWNGPMAVYellow fever virusHLA-A*02:0132272212292290
CINGVCWTVHepatitis C virusHLA-A*02:012314122675151
GLCTLVAMLEpstein Barr virusHLA-A*02:0127859721295117
SPRWYFYYLSARS-CoV2HLA-B*07:02158451491490
ATDALMTGFHepatitis C virusHLA-A*01:011282141030103
DATYQRTRALVRInfluenza A virusHLA-A*68:011004393930
KSKRTPMGFHepatitis C virusHLA-B*57:01115141289089
YLQPRTFLLSARS-CoV2HLA-A*02:01696162548
HPVTKYIMHepatitis C virusHLA-B*08:01605253053
RFPLTFGWCFHIV-1HLA-A*24:02587051510
GPRLGVRATHepatitis C virusHLA-B*07:02513048048
CTELKLSDYInfluenza A virusHLA-A*01:01480048480
RLRAEAQVKEpstein Barr virusHLA-A*03:01470047047
RLPGVLPRAAML neoantigenHLA-A*02:01430043043
SLFNTVATLYHIV-1HLA-A*02:01380038038
RPPIFIRRLEpstein Barr virusHLA-B*07:024022362412
FEDLRLLSFInfluenza A virusHLA-B*37:01310031310
VLFGLGFAIT1D neoantigenHLA-A*02:01321031310
FEDLRVLSFInfluenza A virusHLA-B*37:013601323230
Table 2
Overview of number of TCRs for each peptide in the IMMREP 2022 training dataset before and after redundancy reduction.

The redundancy reduction was performed using a kernel similarity threshold of 95%.

PeptidePre reduction countPost reduction countPercent redundant
All2445196019.8%
GILGFVFTL54430144.7%
NLVPMVATV27424211.7%
YLQPRTFLL26722715.0%
TTDPSFLGRY1931873.1%
LLWNGPMAV1881756.9%
CINGVCWTV1831792.2%
GLCTLVAML1469137.7%
ATDALMTGF1047825.0%
LTDEMIAQY100946.0%
SPRWYFYYL92920.0%
KSKRTPMGF856325.9%
NQKLIANQF56535.4%
HPVTKYIM484114.6%
TPRVTGGGAM45442.2%
NYNYLYRLF44424.6%
GPRLGVRAT40377.5%
RAQAPPPSW361461.1%
Table 3
Pearson Correlation Coefficients (PCC) between the optimal α scaling factor and performance per peptide in terms of AUC and AUC 0.1 of the pre-trained CNN model and TCRbase model, respectively, for the validation partitions.

Each partition was considered as a separate sample. p-Values for the null hypothesis that the performance and optimal α are uncorrelated are also shown.

MetricPCC to optimal alphap-Value
CNN AUC–0.11010.2123
TCRbase AUC0.30560.0004
CNN AUC 0.1–0.08090.3602
TCRbase AUC 0.10.20680.0183
Table 4
Degree of redundancy between the IMMREP test and training data, when using a 95% kernel similarity threshold for redundancy within each peptide.

The redundancy reduction was performed on both positive and negative observations. The counts and percentages, however, only refers to the positive observations.

PeptidePre reduction countPost reduction countPercent redundant
All61946724.56%
GILGFVFTL1365857.35%
NLVPMVATV695421.74%
YLQPRTFLL675320.90%
TTDPSFLGRY49474.08%
LLWNGPMAV47446.38%
CINGVCWTV46460.00%
GLCTLVAML372337.84%
ATDALMTGF262215.38%
LTDEMIAQY25238.00%
SPRWYFYYL24240.00%
KSKRTPMGF221340.91%
NQKLIANQF15150.00%
TPRVTGGGAM12120.00%
HPVTKYIM121016.67%
NYNYLYRLF12925.00%
GPRLGVRAT11110.00%
RAQAPPPSW9366.67%

Additional files

Supplementary file 1

Overview of training data, model parameters, predictions and performance of the models trained and evaluated in this article, excluding the models trained and evaluated on the IMMREP 2022 dataset.

The listed Model Number for each model can be used to find the source data for the figures in this article (see the figure legends).

https://cdn.elifesciences.org/articles/93934/elife-93934-supp1-v1.xlsx
Supplementary file 2

Overview of training data, model parameters, predictions and performance of the models trained and evaluated on the IMMREP 2022 dataset.

The listed Model Number for each model can be used to find the source data for the figures in this article (see the figure legends).

https://cdn.elifesciences.org/articles/93934/elife-93934-supp2-v1.xlsx
MDAR checklist
https://cdn.elifesciences.org/articles/93934/elife-93934-mdarchecklist1-v1.docx

Download links

A two-part list of links to download the article, or parts of the article, in various formats.

Downloads (link to download the article as PDF)

Open citations (links to open the citations from this article in various online reference manager services)

Cite this article (links to download the citations from this article in formats compatible with various reference manager tools)

  1. Mathias Fynbo Jensen
  2. Morten Nielsen
(2024)
Enhancing TCR specificity predictions by combined pan- and peptide-specific training, loss-scaling, and sequence similarity integration
eLife 12:RP93934.
https://doi.org/10.7554/eLife.93934.3