by the AdamW optimizer with weight decay [Loshchilov and Hutter, 2019], learning rate 0.001, for 500 epochs.

### 5.4.5 k-NN based classifier

Following [Weber et al., 2021], we built a k-Nearest Neighbours (k-NN) based classifier to distinguish TCRs recognizing a specific antigen from generic ones. It works by computing the Levenshtein distance of the CDR3β under analysis with respect to a set of positive examples (training set of antigen-specific CDR3β) and to a set of negative examples (training set of bulk repertoire CDR3β). In the computation of the Levenshtein distance, the V and J segments are used as well (different V or J segments increase the distance by 1). Then the average distances from the k nearest neighbours are computed for both the positive and negative examples, and a score is computed as the difference between the two average distances.

The only parameter of this model, *k*, has been fixed for the largest dataset of positive examples (TCRs reactive to the NLVPMVATV peptide) by cross-validation. We split the positive and negative data in 50 independent training and test sets (with respectively 80% and 20% of the sequences); from each training set, a portion of 20% of its data is held out as validation set. Next *k*, for each partition, is fixed by maximizing the model performance on the validation set, and the model with the best *k* is evaluated on the test set. For the other datasets of positive examples, which are smaller, we used *k* = 26, obtained as the *k* for which the average AUC on the validation set is maximal (Figure S18). The performance of the k-NN based classifier was evaluated as described in section 5.5.

### 5.4.6 NetTCR-2.0

NetTCR-2.0 [Montemurro et al., 2021] is a convolutional neural network method trained from sets of pairs of peptides and cognate TCR sequences (β chain only or α + β chains). To re-train and evaluate it with our datasets in the β chain only version, we replaced the sets of CDR3β specific to the 4 epitopes of interest (M1<sub>58</sub>, pp65<sub>495</sub>, BMLF1<sub>280</sub>, S<sub>269</sub>) with our VDJdb-derived datasets. We kept all the other NetTCR training data (the 3 peptides different from our 4 peptides of interest with their specific CDR3β as well as their control data for these additional peptides). Re-training NetTCR-2.0 with only the 4 epitope-specific sets of CDR3β we considered gave AUCs in the same range of values as for the case with 7 peptides. In all cases our training of NetTCR-2.0 uses the same default settings as [Montemurro et al., 2021].

## 5.5 Classification performance

Having found the optimal diffRBM architecture (section 5.3) for the immunogenicity model, for each of the 3 HLA types considered, we trained 50 HLA-specific models on the original training sets (consisting of the 80% of the full datasets available) and we assessed their average performance over the corresponding 50 choices of the test set. In particular, we tested the ability of the HLA-specific immunogenicity models to identify new immunogenic peptides by the Receiver Operating Characteristic curve (ROC). For each of the 50 repetitions, we assigned scores of immunogenicity predicted by a given HLA-specific model (given by the diffRBM units' score $L^d$ of equation 11) to the sequences of the test set of positives (immunogenic peptides with the HLA type under consideration) and of negatives (a test set of non-immunogenic peptides presented by the same HLA). Varying the threshold score value to discriminate positives from negatives, we obtained the ROC curve describing the fraction of immunogenic peptides predicted by the models' scores, against the fraction of predicted non-immunogenic ones. We took the Area Under the Curve (AUC) as a metric of the models' ability to discriminate immunogenic from non-immunogenic peptides. We performed the same validation for all the RBM-based approaches (section 5.1, Figure 6), using their corresponding output scores (equation 9 for the full RBM, 10 for background RBM). The performance of the full RBM obtained through the score (9) is by far and large equivalent to the one of an RBM with the same hyperparameters entirely trained, in one step only, from the selected dataset (Figure S10), confirming that there is a gain in performance with the differential learning strategy only
by the AdamW optimizer with weight decay [Loshchilov and Hutter, 2019], learning rate 0.001, for 500 epochs.

### 5.4.5 k-NN based classifier

Following [Weber et al., 2021], we built a k-Nearest Neighbours (k-NN) based classifier to distinguish TCRs recognizing a specific antigen from generic ones. It works by computing the Levenshtein distance of the CDR3β under analysis with respect to a set of positive examples (training set of antigen-specific CDR3β) and to a set of negative examples (training set of bulk repertoire CDR3β). In the computation of the Levenshtein distance, the V and J segments are used as well (different V or J segments increase the distance by 1). Then the average distances from the k nearest neighbours are computed for both the positive and negative examples, and a score is computed as the difference between the two average distances.

The only parameter of this model, *k*, has been fixed for the largest dataset of positive examples (TCRs reactive to the NLVPMVATV peptide) by cross-validation. We split the positive and negative data in 50 independent training and test sets (with respectively 80% and 20% of the sequences); from each training set, a portion of 20% of its data is held out as validation set. Next *k*, for each partition, is fixed by maximizing the model performance on the validation set, and the model with the best *k* is evaluated on the test set. For the other datasets of positive examples, which are smaller, we used *k* = 26, obtained as the *k* for which the average AUC on the validation set is maximal (Figure S18). The performance of the k-NN based classifier was evaluated as described in section 5.5.

### 5.4.6 NetTCR-2.0

NetTCR-2.0 [Montemurro et al., 2021] is a convolutional neural network method trained from sets of pairs of peptides and cognate TCR sequences (β chain only or α + β chains). To re-train and evaluate it with our datasets in the β chain only version, we replaced the sets of CDR3β specific to the 4 epitopes of interest (M1<sub>58</sub>, pp65<sub>495</sub>, BMLF1<sub>280</sub>, S<sub>269</sub>) with our VDJdb-derived datasets. We kept all the other NetTCR training data (the 3 peptides different from our 4 peptides of interest with their specific CDR3β as well as their control data for these additional peptides). Re-training NetTCR-2.0 with only the 4 epitope-specific sets of CDR3β we considered gave AUCs in the same range of values as for the case with 7 peptides. In all cases our training of NetTCR-2.0 uses the same default settings as [Montemurro et al., 2021].

## 5.5 Classification performance

Having found the optimal diffRBM architecture (section 5.3) for the immunogenicity model, for each of the 3 HLA types considered, we trained 50 HLA-specific models on the original training sets (consisting of the 80% of the full datasets available) and we assessed their average performance over the corresponding 50 choices of the test set. In particular, we tested the ability of the HLA-specific immunogenicity models to identify new immunogenic peptides by the Receiver Operating Characteristic curve (ROC). For each of the 50 repetitions, we assigned scores of immunogenicity predicted by a given HLA-specific model (given by the diffRBM units' score $L^d$ of equation 11) to the sequences of the test set of positives (immunogenic peptides with the HLA type under consideration) and of negatives (a test set of non-immunogenic peptides presented by the same HLA). Varying the threshold score value to discriminate positives from negatives, we obtained the ROC curve describing the fraction of immunogenic peptides predicted by the models' scores, against the fraction of predicted non-immunogenic ones. We took the Area Under the Curve (AUC) as a metric of the models' ability to discriminate immunogenic from non-immunogenic peptides. We performed the same validation for all the RBM-based approaches (section 5.1, Figure 6), using their corresponding output scores (equation 9 for the full RBM, 10 for background RBM). The performance of the full RBM obtained through the score (9) is by far and large equivalent to the one of an RBM with the same hyperparameters entirely trained, in one step only, from the selected dataset (Figure S10), confirming that there is a gain in performance with the differential learning strategy only
when we focus on the differential units and their parameters. For the diffRBM linear approach (section 5.4), the scores (9) and (11) contain, for the differential part, only fields $g_i^d(\sigma_i)$; in the PWM-based approach, we used (16) (Figure S7).

We also performed a leave-one-organism-out cross validation, whereby we divided peptides by the organism of origin, we held out as test set only the immunogenic and non-immunogenic peptides from the same organism and trained the models on the peptides from all the other organisms (Figure S9). We considered in the test sets only the organisms for which at least 15 immunogenic and non-immunogenic peptides could be retrieved from IEDB. HLA-A\*02:01 is the only allele for which we found sufficient data for this validation.

Also negatives were randomly divided into 50 training and test sets. Training sets of negatives were used to train diffRBM units for non-immunogenic peptides (assigning scores that we will denote as $\mathcal{L}^{\text{d,neg}}(\boldsymbol{\sigma})$ to distinguish it from the scores of immunogenicity $\mathcal{L}^{\text{d}}(\boldsymbol{\sigma})$) and the classifiers of immunogenicity (section 5.4.4). The classifiers output a probability of being immunogenic which is used as the score of immunogenicity for calculating the AUC on the 50 test sets of positives and negatives. To evaluate the AUC for the approach denoted as ‘diffRBM units (difference)’ (Figures 4, S12), we considered the score given, for each sequence in the test sets $\boldsymbol{\sigma}$, by the difference $\mathcal{L}^{\text{d}}(\boldsymbol{\sigma}) - \mathcal{L}^{\text{d,neg}}(\boldsymbol{\sigma})$. Given that the background model is the same for both the sets of differential units, it can be seen from equations (9) and (11) that the score $\mathcal{L}^{\text{d}}(\boldsymbol{\sigma}) - \mathcal{L}^{\text{d,neg}}(\boldsymbol{\sigma})$ gives the same result as the difference of the full RBM scores $\mathcal{L}(\boldsymbol{\sigma}) - \mathcal{L}^{\text{neg}}(\boldsymbol{\sigma})$ (Figure S10).

We followed the same procedure to train and evaluate the models of T-cell response specificity (Figures 6, S16, S17, S19). In particular, to test the T-cell specificity models’ ability to identify new peptide-specific receptors, we performed an AUC-based assessment of predictive performance analogous to the one described above for peptides, using, as positives, the receptors with the same peptide-specificity from the held-out test sets and, as negatives, a subset of generic receptors from the bulk repertoire (either from [Emerson et al., 2017] or [Dean et al., 2015]), randomly drawn at each repetition with the same size as the positive test set and with no overlap with the 10⁶ sequences of the training set of the background model. All the approaches (diffRBM and alternatives versions, SONIA, k-NN, NetTCR-2.0, TCRex) are trained and tested on 50 independent random partitions of both positives and negatives into training and test sets, and the performance shown in Figures 6, S16, S17, S19 is the average AUC over these 50 partitions. As negative set to train the supervised approaches (k-NN, NetTCR-2.0) we took, for each training repetition, a subset of the bulk-repertoire dataset from [Emerson et al., 2017] with the same size as the positive training set.

## 5.6 PRIME tool

PRIME [Schmidt et al., 2021] was downloaded from https://github.com/GfellerLab/PRIME. Being it not possible to re-train PRIME on our datasets for a fair comparison of performance, we simply evaluated it on the set of immunogenic and non-immunogenic peptides we collected and we obtained a discrimination performance with AUC=0.53 for peptides specific to HLA-A\*02:01, AUC=0.45 for HLA-B\*07:02 and AUC=0.56 for HLA-B\*35:01. Since we set out to predict immunogenicity conditioned on binding to a given HLA allele, PRIME was run in the mono-allelic mode (e.g. with option -a A0201 for the case of HLA-A\*02:01); in general, however, different results are obtained by adding more alleles, where then the best presenting allele according to the predictor is taken.

## 5.7 Contact prediction

### 5.7.1 Definition of single-site factors

Given the TCR-pMHC structures retrieved from IEDB, we estimated the peptide sites in contact with the HLA and the TCR, as well as the positions of the receptor's CDR3β region in contact with the peptides (section 5.2.4). For these sequences annotated with structural information, we assessed whether differential models can predict contact positions. To this end, we defined single-site factors $T_i$ from the
when we focus on the differential units and their parameters. For the diffRBM linear approach (section 5.4), the scores (9) and (11) contain, for the differential part, only fields $g_i^d(\sigma_i)$; in the PWM-based approach, we used (16) (Figure S7).

We also performed a leave-one-organism-out cross validation, whereby we divided peptides by the organism of origin, we held out as test set only the immunogenic and non-immunogenic peptides from the same organism and trained the models on the peptides from all the other organisms (Figure S9). We considered in the test sets only the organisms for which at least 15 immunogenic and non-immunogenic peptides could be retrieved from IEDB. HLA-A*02:01 is the only allele for which we found sufficient data for this validation.

Also negatives were randomly divided into 50 training and test sets. Training sets of negatives were used to train diffRBM units for non-immunogenic peptides (assigning scores that we will denote as $\mathcal{L}^{\text{d,neg}}(\boldsymbol{\sigma})$ to distinguish it from the scores of immunogenicity $\mathcal{L}^{\text{d}}(\boldsymbol{\sigma})$) and the classifiers of immunogenicity (section 5.4.4). The classifiers output a probability of being immunogenic which is used as the score of immunogenicity for calculating the AUC on the 50 test sets of positives and negatives. To evaluate the AUC for the approach denoted as ‘diffRBM units (difference)’ (Figures 4, S12), we considered the score given, for each sequence in the test sets $\boldsymbol{\sigma}$, by the difference $\mathcal{L}^{\text{d}}(\boldsymbol{\sigma}) - \mathcal{L}^{\text{d,neg}}(\boldsymbol{\sigma})$. Given that the background model is the same for both the sets of differential units, it can be seen from equations (9) and (11) that the score $\mathcal{L}^{\text{d}}(\boldsymbol{\sigma}) - \mathcal{L}^{\text{d,neg}}(\boldsymbol{\sigma})$ gives the same result as the difference of the full RBM scores $\mathcal{L}(\boldsymbol{\sigma}) - \mathcal{L}^{\text{neg}}(\boldsymbol{\sigma})$ (Figure S10).

We followed the same procedure to train and evaluate the models of T-cell response specificity (Figures 6, S16, S17, S19). In particular, to test the T-cell specificity models’ ability to identify new peptide-specific receptors, we performed an AUC-based assessment of predictive performance analogous to the one described above for peptides, using, as positives, the receptors with the same peptide-specificity from the held-out test sets and, as negatives, a subset of generic receptors from the bulk repertoire (either from [Emerson et al., 2017] or [Dean et al., 2015]), randomly drawn at each repetition with the same size as the positive test set and with no overlap with the 10⁶ sequences of the training set of the background model. All the approaches (diffRBM and alternatives versions, SONIA, k-NN, NetTCR-2.0, TCRex) are trained and tested on 50 independent random partitions of both positives and negatives into training and test sets, and the performance shown in Figures 6, S16, S17, S19 is the average AUC over these 50 partitions. As negative set to train the supervised approaches (k-NN, NetTCR-2.0) we took, for each training repetition, a subset of the bulk repertoire dataset from [Emerson et al., 2017] with the same size as the positive training set.

## 5.6 PRIME tool

PRIME [Schmidt et al., 2021] was downloaded from https://github.com/GfellerLab/PRIME. Being it not possible to re-train PRIME on our datasets for a fair comparison of performance, we simply evaluated it on the set of immunogenic and non-immunogenic peptides we collected and we obtained a discrimination performance with AUC=0.53 for peptides specific to HLA-A*02:01, AUC=0.45 for HLA-B*07:02 and AUC=0.56 for HLA-B*35:01. Since we set out to predict immunogenicity conditioned on binding to a given HLA allele, PRIME was run in the mono-allelic mode (e.g. with option -a A0201 for the case of HLA-A*02:01); in general, however, different results are obtained by adding more alleles, where then the best presenting allele according to the predictor is taken.

## 5.7 Contact prediction

### 5.7.1 Definition of single-site factors

Given the TCR-pMHC structures retrieved from IEDB, we estimated the peptide sites in contact with the HLA and the TCR, as well as the positions of the receptor's CDR3β region in contact with the peptides (section 5.2.4). For these sequences annotated with structural information, we assessed whether differential models can predict contact positions. To this end, we defined single-site factors $T_i$ from the
models’ parameters to be evaluated on each sequence σ as:

$$T_i(\sigma_i) = g_i^d(\sigma_i) + \sum_{\mu'=1}^{M^d} w_{i\mu'}^d(\sigma_i) \langle h_{\mu'}^d | \sigma \rangle \quad (17)$$

where the average over the differential hidden units $\langle h_{\mu'}^d | \sigma \rangle$ is estimated from a distribution conditional on the sequence σ that is $\sim \exp(-U_{\mu'}^d(h_{\mu'}^d) + h_{\mu'}^d \sum_i w_{i\mu'}^d(\sigma_i))$. The $T_i$ factors reduce to $T_i(\sigma_i) = g_i^d(\sigma_i)$ for the diffRBM linear model (Figures S4A-B, S15A-B). From the definition (17), it is clear that single-site factors measure more generally whether, under a diffRBM model, the amino acid $\sigma_i$ at position $i$, in the sequence context provided by σ, has high probability to occur among selected sequences, for instance among HLA-specific immunogenic peptides, hence we have used them to quantify residue-specific contributions to immunogenicity (Figure 3).

For the estimation of contacts, the sequence σ in (17) is represented by either peptides or by receptors’ CDR3β sequences when we predict, respectively, the peptide sites in contact with the TCR through the models of immunogenicity (Figure 2C-D) and the CDR3β sites in contact with peptides through the models of epitope specificity (Figure 5B-C). Since we interested in a prediction at the level of residues, the models of epitope specificity used here are defined only on the CDR3β amino acid sequence (disregarding the V and J identity). To evaluate contact predictions, for each peptide we use the immunogenicity model corresponding to its HLA type and for each CDR3β we use the model corresponding to its epitope specificity. Given the set of $T_i(\sigma_i)$ from the models for each sequence position $i$, we rank them according to their magnitude and we take the top ranking positions as the model’s prediction on contacts for the sequence σ. In the case of CDR3β sequences, we consider only non-gap positions for such ranking.

As a term of comparison, we considered, single-site factors estimated from models which assume all positions independent (section 5.4.2). Here the single-site factors reduce to the log-likelihood ratio:

$$T_i(\sigma_i) = \log \frac{P_i(\sigma_i)}{P_i^b(\sigma_i)} \quad (18)$$

where that $P_i(\sigma_i)$ and $P_i^b(\sigma_i)$ are given by PWMs (section 5.4.2) and hence represent position-specific amino acid frequencies. In the case of the immunogenicity model, the prediction by (18) simply describes the log ratio between the frequency of amino acids in immunogenic peptides relative to the amino acid frequency of all presented peptides from the background dataset (we refer to it as ‘AA frequency ratio (to all presented)’, see Figure 2C-D); in the case of the TCR specificity model (18) gives the log ratio between the frequency of amino acids in peptide-specific CDR3β repertoires relative to the amino acid frequency in bulk repertoire (we refer to it as ‘AA frequency ratio (to bulk)’, see Figure 5B-C). In both cases the prediction indicated as ‘Amino acid frequency’ is obtained by estimating and ranking the single-site factors:

$$T_i(\sigma_i) = \log P_i(\sigma_i) \quad (19)$$

In the case of the immunogenicity model, we have also learnt an independent-site model from non-immunogenic data (that we call $P_i^{\text{NI}}(\sigma_i)$) and we have looked at the single-site factors:

$$T_i(\sigma_i) = \log \frac{P_i(\sigma_i)}{P_i^{\text{NI}}(\sigma_i)} \quad (20)$$

which represents a log ratio of amino acid frequency in immunogenic data relative to non-immunogenic data (this prediction is labelled ‘AA frequency ratio (to non-immunogenic)’ in Figure 2C-D and 3B).

To identify the sites of binding to the HLA, we resort to single-site factors capturing amino acid usage in presented peptides defined as:

$$T_i(\sigma_i) = \log P_i^b(\sigma_i) \quad (21)$$

In this case, we look also at the parameters of background RBM, which is learnt to reproduce the amino acid statistics in presented peptides. In particular, consistently with previous analyses [Bravi et al.,
models’ parameters to be evaluated on each sequence σ as:

$$T_i(\sigma_i) = g_i^d(\sigma_i) + \sum_{\mu'=1}^{M^d} w_{i\mu'}^d(\sigma_i) \langle h_{\mu'}^d | \sigma \rangle \quad (17)$$

where the average over the differential hidden units $\langle h_{\mu'}^d | \sigma \rangle$ is estimated from a distribution conditional on the sequence σ that is $\sim \exp(-U_{\mu'}^d(h_{\mu'}^d) + h_{\mu'}^d \sum_i w_{i\mu'}^d(\sigma_i))$. The $T_i$ factors reduce to $T_i(\sigma_i) = g_i^d(\sigma_i)$ for the diffRBM linear model (Figures S4A-B, S15A-B). From the definition (17), it is clear that single-site factors measure more generally whether, under a diffRBM model, the amino acid $\sigma_i$ at position $i$, in the sequence context provided by σ, has high probability to occur among selected sequences, for instance among HLA-specific immunogenic peptides, hence we have used them to quantify residue-specific contributions to immunogenicity (Figure 3).

For the estimation of contacts, the sequence σ in (17) is represented by either peptides or by receptors’ CDR3β sequences when we predict, respectively, the peptide sites in contact with the TCR through the models of immunogenicity (Figure 2C-D) and the CDR3β sites in contact with peptides through the models of epitope specificity (Figure 5B-C). Since we interested in a prediction at the level of residues, the models of epitope specificity used here are defined only on the CDR3β amino acid sequence (disregarding the V and J identity). To evaluate contact predictions, for each peptide we use the immunogenicity model corresponding to its HLA type and for each CDR3β we use the model corresponding to its epitope specificity. Given the set of $T_i(\sigma_i)$ from the models for each sequence position $i$, we rank them according to their magnitude and we take the top ranking positions as the model’s prediction on contacts for the sequence σ. In the case of CDR3β sequences, we consider only non-gap positions for such ranking.

As a term of comparison, we considered, single-site factors estimated from models which assume all positions independent (section 5.4.2). Here the single-site factors reduce to the log-likelihood ratio:

$$T_i(\sigma_i) = \log \frac{P_i(\sigma_i)}{P_i^b(\sigma_i)} \quad (18)$$

where that $P_i(\sigma_i)$ and $P_i^b(\sigma_i)$ are given by PWMs (section 5.4.2) and hence represent position-specific amino acid frequencies. In the case of the immunogenicity model, the prediction by (18) simply describes the log ratio between the frequency of amino acids in immunogenic peptides relative to the amino acid frequency of all presented peptides from the background dataset (we refer to it as ‘AA frequency ratio (to all presented)’, see Figure 2C-D); in the case of the TCR specificity model (18) gives the log ratio between the frequency of amino acids in peptide-specific CDR3β repertoires relative to the amino acid frequency in bulk repertoire (we refer to it as ‘AA frequency ratio (to bulk)’, see Figure 5B-C). In both cases the prediction indicated as ‘Amino acid frequency’ is obtained by estimating and ranking the single-site factors:

$$T_i(\sigma_i) = \log P_i(\sigma_i) \quad (19)$$

In the case of the immunogenicity model, we have also learnt an independent-site model from non-immunogenic data (that we call $P_i^{\text{NI}}(\sigma_i)$) and we have looked at the single-site factors:

$$T_i(\sigma_i) = \log \frac{P_i(\sigma_i)}{P_i^{\text{NI}}(\sigma_i)} \quad (20)$$

which represents a log ratio of amino acid frequency in immunogenic data relative to non-immunogenic data (this prediction is labelled ‘AA frequency ratio (to non-immunogenic)’ in Figure 2C-D and 3B).

To identify the sites of binding to the HLA, we resort to single-site factors capturing amino acid usage in presented peptides defined as:

$$T_i(\sigma_i) = \log P_i^b(\sigma_i) \quad (21)$$

In this case, we look also at the parameters of background RBM, which is learnt to reproduce the amino acid statistics in presented peptides. In particular, consistently with previous analyses [Bravi et al.,
2021b], we find that the fields alone identify the anchor sites of binding to the HLA, while the weights tend to capture second-order effects, concentrated at positions 4-8, presumably related to amino acid differences at these positions that might reflect peptide's conformation in the binding pocket. A case in point was discussed in [Bravi et al., 2021b], where we found that the weights of a single-allele RBM presentation model could capture different binding modes within peptides of the same HLA specificity. Hence we conclude that fields alone are more appropriate for contact prediction and in Figure 2B we use the single-site factors from a fields-only RBM model ($T_i(\sigma_i) = g_i^b(\sigma_i)$) as predictors. In Figure S5A-B we report the comparison to the prediction by a full RBM model ($T_i(\sigma_i) = g_i^b(\sigma_i) + \sum_{\mu=1}^{M^b} w_{i\mu}^b(\sigma_i)\langle h_\mu | \sigma \rangle$), showing only a minimal decrease in performance compared to the fields-only prediction, due to the weights-related effects being mainly second-order ones.

Finally, we have explored an alternative, more general measure of site-specific amino acid importance from the differential units:

$$ \tilde{T}_i(\sigma_i) = \mathcal{L}^d(\sigma) - \frac{1}{q} \sum_{\sigma'_i=1}^{q} \mathcal{L}^d(\sigma'_i|\sigma) \quad (22) $$

where $\mathcal{L}^d(\sigma'_i|\sigma)$ is the differential units' score of the sequence $\sigma$ where position $i$ has been mutated from $\sigma_i$ to $\sigma'_i$, $\mathcal{L}^d$ is calculated using equation (11) and $q$ is the number of values that $\sigma'_i$ can take. $\tilde{T}_i(\sigma_i)$ can be hence seen as a measure of the importance of amino acid $\sigma_i$ at position $i$ obtained by comparing its contribution to the likelihood to the one of all other possible $q$ amino acids. The diffRBM single-site factors (17) can be derived as a small-weight approximation of the more general definition (22), whose advantage is that *per se* does not depend on the RBM structure of the probability $P(\sigma)$. Overall, at the numerical level, the predictions of contacts obtained by ranking sites by (22) are comparable to the ones by (17), see Figures S4A-B, S5A-B, S15A-B.

### 5.7.2 Prediction assessment via the Positive Predictive Value

Given the models' predictions of putative contact sites, we assessed their quality by estimating the Positive Predictive Value (Figures 2D, 5C, S4, S5, S15). The Positive Predictive Value for sequence $\sigma$ at the ranked position $p$ ($PPV_\sigma^p$) is given by the number of top $p$ ranked positions that is included among the contact positions of $\sigma$ (true positives), divided by $p$ or by number of contacts when this is lower than $p$ (all the positives). $PPV_\sigma^p$ hence hits 1 when $p$ is equal to the full length of sequence $\sigma$. For a given $PPV_\sigma^p$, the associated random expectation corresponds to drawing uniformly at random $p$ positions and using them to predict the contact positions of $\sigma$. The summary values reported in Figures 2D and 5C correspond to the average of $PPV_\sigma^p$ over all the sequences $\sigma$ under consideration (respectively, peptides and CDR3$\beta$) as a function of the number $p$ of ranked sequence positions. To correct for the over-representation among the available resolved structures of certain sequences (for example the same peptide and its one-point mutants in contact with different TCRs, or sets of highly similar CDR3$\beta$s specific to the Influenza peptide GILGFVFTL), we calculate the average $PPV^p$ at each position $p$ as a weighted average:

$$ PPV^p = \frac{1}{R_{\text{eff}}} \sum_{r=1}^{R} \frac{1}{n_{\sigma^r}} PPV_{\sigma^r}^p \quad (23) $$

where we reweight the contribution of each sequence to the PPV by a factor $1/n_\sigma$, taking $n_\sigma$ as the number of sequences that are equal to or mutation away from $\sigma$. In (23) we have denoted by $R$ the total number of entries under consideration and by $R_{\text{eff}}$ their effective number obtained as $R_{\text{eff}} = \sum_{r=1}^{R} 1/n_{\sigma^r}$. Retaining only unique combinations of sequence and contact positions at the chosen distance cutoffs (4 Å for peptide-TCR contacts, 3.5 Å for peptide-HLA contacts), the number of structures considered for: (i) the prediction of contacts with the TCR along the peptide is $R = 46$ (4 for HLA-B*35:01, 41 for HLA-A*02:01, 1 for HLA-B*07:02); (ii) the prediction of contacts with the HLA along the peptide is $R = 53$ (5 for HLA-B*35:01, 47 for HLA-A*02:01, 1 for HLA-B*07:02); (iii) the prediction of contacts with the peptide along the CDR3$\beta$ is $R = 12$ (2 for YLQPRTFLL, 3 for NLVPMVATV, 1 for GLCTLVAML, 6 for GILGFVFTL). The corresponding effective numbers are $R_{\text{eff}} = 22.7$ for (i) and (ii), and $R_{\text{eff}} = 10.3$ for (iii). In Figures S4A-B, S5A-B, S15A-B we report the comparison of the average reweighted PPV
2021b], we find that the fields alone identify the anchor sites of binding to the HLA, while the weights tend to capture second-order effects, concentrated at positions 4-8, presumably related to amino acid differences at these positions that might reflect peptide's conformation in the binding pocket. A case in point was discussed in [Bravi et al., 2021b], where we found that the weights of a single-allele RBM presentation model could capture different binding modes within peptides of the same HLA specificity. Hence we conclude that fields alone are more appropriate for contact prediction and in Figure 2B we use the single-site factors from a fields-only RBM model ($T_i(\sigma_i) = g_i^b(\sigma_i)$) as predictors. In Figure S5A-B we report the comparison to the prediction by a full RBM model ($T_i(\sigma_i) = g_i^b(\sigma_i) + \sum_{\mu=1}^{M^b} w_{i\mu}^b(\sigma_i)\langle h_\mu | \sigma \rangle$), showing only a minimal decrease in performance compared to the fields-only prediction, due to the weights-related effects being mainly second-order ones.

Finally, we have explored an alternative, more general measure of site-specific amino acid importance from the differential units:

$$ \tilde{T}_i(\sigma_i) = \mathcal{L}^d(\sigma) - \frac{1}{q} \sum_{\sigma'_i=1}^{q} \mathcal{L}^d(\sigma'_i|\sigma) \quad (22) $$

where $\mathcal{L}^d(\sigma'_i|\sigma)$ is the differential units' score of the sequence $\sigma$ where position $i$ has been mutated from $\sigma_i$ to $\sigma'_i$, $\mathcal{L}^d$ is calculated using equation (11) and $q$ is the number of values that $\sigma'_i$ can take. $\tilde{T}_i(\sigma_i)$ can be hence seen as a measure of the importance of amino acid $\sigma_i$ at position $i$ obtained by comparing its contribution to the likelihood to the one of all other possible $q$ amino acids. The diffRBM single-site factors (17) can be derived as a small-weight approximation of the more general definition (22), whose advantage is that per se does not depend on the RBM structure of the probability $P(\sigma)$. Overall, at the numerical level, the predictions of contacts obtained by ranking sites by (22) are comparable to the ones by (17), see Figures S4A-B, S5A-B, S15A-B.

### 5.7.2 Prediction assessment via the Positive Predictive Value

Given the models' predictions of putative contact sites, we assessed their quality by estimating the Positive Predictive Value (Figures 2D, 5C, S4, S5, S15). The Positive Predictive Value for sequence $\sigma$ at the ranked position $p$ ($PPV_\sigma^p$) is given by the number of top $p$ ranked positions that is included among the contact positions of $\sigma$ (true positives), divided by $p$ or by number of contacts when this is lower than $p$ (all the positives). $PPV_\sigma^p$ hence hits 1 when $p$ is equal to the full length of sequence $\sigma$. For a given $PPV_\sigma^p$, the associated random expectation corresponds to drawing uniformly at random $p$ positions and using them to predict the contact positions of $\sigma$. The summary values reported in Figures 2D and 5C correspond to the average of $PPV_\sigma^p$ over all the sequences $\sigma$ under consideration (respectively, peptides and CDR3$\beta$) as a function of the number $p$ of ranked sequence positions. To correct for the over-representation among the available resolved structures of certain sequences (for example the same peptide and its one-point mutants in contact with different TCRs, or sets of highly similar CDR3$\beta$s specific to the Influenza peptide GILGFVFTL), we calculate the average $PPV^p$ at each position $p$ as a weighted average:

$$ PPV^p = \frac{1}{R_{\text{eff}}} \sum_{r=1}^{R} \frac{1}{n_{\sigma^r}} PPV_{\sigma^r}^p \quad (23) $$

where we reweight the contribution of each sequence to the PPV by a factor $1/n_\sigma$, taking $n_\sigma$ as the number of sequences that are equal to or mutation away from $\sigma$. In (23) we have denoted by $R$ the total number of entries under consideration and by $R_{\text{eff}}$ their effective number obtained as $R_{\text{eff}} = \sum_{r=1}^{R} 1/n_{\sigma^r}$. Retaining only unique combinations of sequence and contact positions at the chosen distance cutoffs (4 Å for peptide-TCR contacts, 3.5 Å for peptide-HLA contacts), the number of structures considered for: (i) the prediction of contacts with the TCR along the peptide is $R = 46$ (4 for HLA-B*35:01, 41 for HLA-A*02:01, 1 for HLA-B*07:02); (ii) the prediction of contacts with the HLA along the peptide is $R = 53$ (5 for HLA-B*35:01, 47 for HLA-A*02:01, 1 for HLA-B*07:02); (iii) the prediction of contacts with the peptide along the CDR3$\beta$ is $R = 12$ (2 for YLQPRTFLL, 3 for NLVPMVATV, 1 for GLCTLVAML, 6 for GILGFVFTL). The corresponding effective numbers are $R_{\text{eff}} = 22.7$ for (i) and (ii), and $R_{\text{eff}} = 10.3$ for (iii). In Figures S4A-B, S5A-B, S15A-B we report the comparison of the average reweighted PPV
(equation 23) to the average PPV calculated without reweighting (PPV<sup>p</sup> = <sup>1</sup>/<sub>R</sub> &Sigma;<sup>R</sup><sub>r=1</sub> PPV<sub>&sigma;<sup>r</sup></sub><sup>p</sup>), showing that the reweighting does not affect the ranking of performance between different methods.

## 5.8 Mutation costs

The experiments of [Luksza et al., 2022] on how TCRs cross-react between the NLVPMVATV peptide and its mutants consisted of the following steps: the wild-type peptide (WT) was mutated to every amino acid at every position to obtain 171 mutants (MT); for each MT, its concentration was varied across a 10,000-fold range and the degree activation of 3 WT-specific TCRs was monitored as relative percentage of CD137 expression to determine the TCR cross-reactivity:

$$ \text{TCR cross-reactivity} = \log \frac{EC_{50}^{MT}}{EC_{50}^{WT}} \qquad (24) $$

from the WT and MT half maximal effective concentration $EC_{50}^{WT}$ and $EC_{50}^{MT}$ (both measured in $\mu g/ml$). We took these reported values of TCR cross-reactivity as the experimental mutation costs for each TCR/mutation pair (in the case of what we referred to as ‘non-lethal’ mutations). We defined ‘lethal’ the mutations that were associated to a formally infinite $EC_{50}^{MT}$ in a given TCR context (i.e., whereby TCR response could not be recovered even at the highest concentrations).

For a mutation in sequence $\sigma$ at position $i$ changing $\sigma_i$ to $\sigma'_i$, we estimated the model prediction of the mutation cost as:

$$ \text{Predicted mutation cost} = T_i(\sigma_i) - T_i(\sigma'_i) \qquad (25) $$

where we took $T_i$ as the single-site factors of (17) for lethal mutations (Figure 3E) and of background RBM (21) for non-lethal mutations (Figure 3G).

To assess whether the distribution towards positive values for lethal mutations is significantly higher than the expectation for generic, non immunogenicity-impacting mutations, we estimated the mutation cost distribution of a ‘control’ case (see Figure 3E) where we drew at random 3000 HLA-A*02:01-presented peptides from the background dataset, and we calculated the costs of all possible amino acid substitutions at each position. The p-value for the difference in these distributions was estimated by the Mann-Whitney U test.
(equation 23) to the average PPV calculated without reweighting (PPV<sup>p</sup> = <sup>1</sup>/<sub>R</sub> &Sigma;<sup>R</sup><sub>r=1</sub> PPV<sub>&sigma;<sup>r</sup></sub><sup>p</sup>), showing that the reweighting does not affect the ranking of performance between different methods.

## 5.8 Mutation costs

The experiments of [Luksza et al., 2022] on how TCRs cross-react between the NLVPMVATV peptide and its mutants consisted of the following steps: the wild-type peptide (WT) was mutated to every amino acid at every position to obtain 171 mutants (MT); for each MT, its concentration was varied across a 10,000-fold range and the degree activation of 3 WT-specific TCRs was monitored as relative percentage of CD137 expression to determine the TCR cross-reactivity:

$$ \text{TCR cross-reactivity} = \log \frac{EC_{50}^{MT}}{EC_{50}^{WT}} \qquad (24) $$

from the WT and MT half maximal effective concentration $EC_{50}^{WT}$ and $EC_{50}^{MT}$ (both measured in $\mu g/ml$). We took these reported values of TCR cross-reactivity as the experimental mutation costs for each TCR/mutation pair (in the case of what we referred to as ‘non-lethal’ mutations). We defined ‘lethal’ the mutations that were associated to a formally infinite $EC_{50}^{MT}$ in a given TCR context (i.e., whereby TCR response could not be recovered even at the highest concentrations).

For a mutation in sequence $\sigma$ at position $i$ changing $\sigma_i$ to $\sigma'_i$, we estimated the model prediction of the mutation cost as:

$$ \text{Predicted mutation cost} = T_i(\sigma_i) - T_i(\sigma'_i) \qquad (25) $$

where we took $T_i$ as the single-site factors of (17) for lethal mutations (Figure 3E) and of background RBM (21) for non-lethal mutations (Figure 3G).

To assess whether the distribution towards positive values for lethal mutations is significantly higher than the expectation for generic, non immunogenicity-impacting mutations, we estimated the mutation cost distribution of a ‘control’ case (see Figure 3E) where we drew at random 3000 HLA-A*02:01-presented peptides from the background dataset, and we calculated the costs of all possible amino acid substitutions at each position. The p-value for the difference in these distributions was estimated by the Mann-Whitney U test.
Acknowledgements

We thank Julien Racle, Nathanael Spisak, Francesco Camaglia, Marta Łuksza, Morten Nielsen and Vadim Karnaukhov for discussions. We are particularly grateful to Giulio Isacchini for help with the data and software. A.D.G. is supported by the European Union's Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement No 101026293. JFdCD acknowledges funding from ANR-19 Decrypted CE30-0021-01 and ANR-17 RBMPro CE30-0021-01. This research was also supported by the European Research Council COG 724208 and ANR-19-CE45-0018 'RESP-REP' from the Agence Nationale de la Recherche.
Acknowledgements

We thank Julien Racle, Nathanael Spisak, Francesco Camaglia, Marta Łuksza, Morten Nielsen and Vadim Karnaukhov for discussions. We are particularly grateful to Giulio Isacchini for help with the data and software. A.D.G. is supported by the European Union's Horizon 2020 research and innovation programme under the Marie Sklodowska-Curie grant agreement No 101026293. JFdCD acknowledges funding from ANR-19 Decrypted CE30-0021-01 and ANR-17 RBMPro CE30-0021-01. This research was also supported by the European Research Council COG 724208 and ANR-19-CE45-0018 'RESP-REP' from the Agence Nationale de la Recherche.
## References

[Akbar et al., 2022] Akbar, R., Robert, P. A., Weber, C. R., Widrich, M., Frank, R., Pavlović, M., Scheffer, L., Chernigovskaya, M., Snapkov, I., Slabodkin, A., Mehta, B. B., Miho, E., Lund-Johansen, F., Andersen, J. T., Hochreiter, S., Hobæk Haff, I., Klambauer, G., Sandve, G. K., and Greiff, V. (2022). In silico proof of principle of machine learning-based antibody design at unconstrained scale. *mAbs*, 14(1):2031482.

[Arnold, 2018] Arnold, F. H. (2018). Directed Evolution: Bringing New Chemistry to Life. *Angewandte Chemie International Edition*, 57(16):4143-4148.

[Bagaev et al., 2020] Bagaev, D. V., Vroomans, R. M. A., Samir, J., Stervbo, U., Rius, C., Dolton, G., Greenshields-Watson, A., Attaf, M., Egorov, E. S., Zvyagin, I. V., Babel, N., Cole, D. K., Godkin, A. J., Sewell, A. K., Kesmir, C., Chudakov, D. M., Luciani, F., and Shugay, M. (2020). VDJdb in 2019: Database extension, new analysis infrastructure and a T-cell receptor motif compendium. *Nucleic Acids Research*, 48(D1):D1057–D1062.

[Berman et al., 2000] Berman, H. M., Westbrook, J., Feng, Z., Gilliland, G., Bhat, T. N., Weissig, H., Shindyalov, I. N., and Bourne, P. E. (2000). The Protein Data Bank. *Nucleic Acids Research*, 28(1):235-242.

[Bjerregaard et al., 2017] Bjerregaard, A.-M., Nielsen, M., Jurtz, V., Barra, C. M., Hadrup, S. R., Szallasi, Z., and Eklund, A. C. (2017). An Analysis of Natural T Cell Responses to Predicted Tumor Neoepitopes. *Frontiers in Immunology*, 8.

[Bravi et al., 2021a] Bravi, B., Balachandran, V. P., Greenbaum, B. D., Walczak, A. M., Mora, T., Monasson, R., and Cocco, S. (2021a). Probing T-cell response by sequence-based probabilistic modeling. *PLOS Computational Biology*, 17(9):e1009297.

[Bravi et al., 2021b] Bravi, B., Tubiana, J., Cocco, S., Monasson, R., Mora, T., and Walczak, A. M. (2021b). RBM-MHC: A Semi-Supervised Machine-Learning Method for Sample-Specific Prediction of Antigen Presentation by HLA-I Alleles. *Cell Systems*, 12(2):195-202.e9.

[Buckley et al., 2022] Buckley, P. R., Lee, C. H., Ma, R., Woodhouse, I., Woo, J., Tsvetkov, V. O., Shcherbinin, D. S., Antanaviciute, A., Shughay, M., Rei, M., Simmons, A., and Koohy, H. (2022). Evaluating performance of existing computational models in predicting CD8+ T cell pathogenic epitopes and cancer neoantigens. *Briefings in Bioinformatics*, 23(3):bbac141.

[Calis et al., 2012] Calis, J. J. A., de Boer, R. J., and Keşmir, C. (2012). Degenerate T-cell Recognition of Peptides on MHC Molecules Creates Large Holes in the T-cell Repertoire. *PLOS Computational Biology*, 8(3):e1002412.

[Calis et al., 2013] Calis, J. J. A., Maybeno, M., Greenbaum, J. A., Weiskopf, D., Silva, A. D. D., Sette, A., Keşmir, C., and Peters, B. (2013). Properties of MHC Class I Presented Peptides That Enhance Immunogenicity. *PLOS Computational Biology*, 9(10):e1003266.

[Carter et al., 2019] Carter, J. A., Preall, J. B., Grigaityte, K., Goldfless, S. J., Jeffery, E., Briggs, A. W., Vigneault, F., and Atwal, G. S. (2019). Single T Cell Sequencing Demonstrates the Functional Role of Aβ TCR Pairing in Cell Lineage and Antigen Specificity. *Frontiers in Immunology*, 10.

[Chaudhury et al., 2010] Chaudhury, S., Lyskov, S., and Gray, J. J. (2010). PyRosetta: A script-based interface for implementing molecular modeling algorithms using Rosetta. *Bioinformatics* (*Oxford, England*), 26(5):689-691.

[Chowell et al., 2015] Chowell, D., Krishna, S., Becker, P. D., Cocita, C., Shu, J., Tan, X., Greenberg, P. D., Klavinskis, L. S., Blattman, J. N., and Anderson, K. S. (2015). TCR contact residue hydrophobicity is a hallmark of immunogenic CD8+ T cell epitopes. *Proceedings of the National Academy of Sciences*, 112(14):E1754-E1762.
References

[Akbar et al., 2022] Akbar, R., Robert, P. A., Weber, C. R., Widrich, M., Frank, R., Pavlović, M., Scheffer, L., Chernigovskaya, M., Snapkov, I., Slabodkin, A., Mehta, B. B., Miho, E., Lund-Johansen, F., Andersen, J. T., Hochreiter, S., Hobæk Haff, I., Klambauer, G., Sandve, G. K., and Greiff, V. (2022). In silico proof of principle of machine learning-based antibody design at unconstrained scale. *mAbs*, 14(1):2031482.

[Arnold, 2018] Arnold, F. H. (2018). Directed Evolution: Bringing New Chemistry to Life. *Angewandte Chemie International Edition*, 57(16):4143-4148.

[Bagaev et al., 2020] Bagaev, D. V., Vroomans, R. M. A., Samir, J., Stervbo, U., Rius, C., Dolton, G., Greenshields-Watson, A., Attaf, M., Egorov, E. S., Zvyagin, I. V., Babel, N., Cole, D. K., Godkin, A. J., Sewell, A. K., Kesmir, C., Chudakov, D. M., Luciani, F., and Shugay, M. (2020). VDJdb in 2019: Database extension, new analysis infrastructure and a T-cell receptor motif compendium. *Nucleic Acids Research*, 48(D1):D1057–D1062.

[Berman et al., 2000] Berman, H. M., Westbrook, J., Feng, Z., Gilliland, G., Bhat, T. N., Weissig, H., Shindyalov, I. N., and Bourne, P. E. (2000). The Protein Data Bank. *Nucleic Acids Research*, 28(1):235-242.

[Bjerregaard et al., 2017] Bjerregaard, A.-M., Nielsen, M., Jurtz, V., Barra, C. M., Hadrup, S. R., Szallasi, Z., and Eklund, A. C. (2017). An Analysis of Natural T Cell Responses to Predicted Tumor Neoepitopes. *Frontiers in Immunology*, 8.

[Bravi et al., 2021a] Bravi, B., Balachandran, V. P., Greenbaum, B. D., Walczak, A. M., Mora, T., Monasson, R., and Cocco, S. (2021a). Probing T-cell response by sequence-based probabilistic modeling. *PLOS Computational Biology*, 17(9):e1009297.

[Bravi et al., 2021b] Bravi, B., Tubiana, J., Cocco, S., Monasson, R., Mora, T., and Walczak, A. M. (2021b). RBM-MHC: A Semi-Supervised Machine-Learning Method for Sample-Specific Prediction of Antigen Presentation by HLA-I Alleles. *Cell Systems*, 12(2):195-202.e9.

[Buckley et al., 2022] Buckley, P. R., Lee, C. H., Ma, R., Woodhouse, I., Woo, J., Tsvetkov, V. O., Shcherbinin, D. S., Antanaviciute, A., Shughay, M., Rei, M., Simmons, A., and Koohy, H. (2022). Evaluating performance of existing computational models in predicting CD8+ T cell pathogenic epitopes and cancer neoantigens. *Briefings in Bioinformatics*, 23(3):bbac141.

[Calis et al., 2012] Calis, J. J. A., de Boer, R. J., and Keçmir, C. (2012). Degenerate T-cell Recognition of Peptides on MHC Molecules Creates Large Holes in the T-cell Repertoire. *PLOS Computational Biology*, 8(3):e1002412.

[Calis et al., 2013] Calis, J. J. A., Maybeno, M., Greenbaum, J. A., Weiskopf, D., Silva, A. D. D., Sette, A., Keçmir, C., and Peters, B. (2013). Properties of MHC Class I Presented Peptides That Enhance Immunogenicity. *PLOS Computational Biology*, 9(10):e1003266.

[Carter et al., 2019] Carter, J. A., Preall, J. B., Grigaityte, K., Goldfless, S. J., Jeffery, E., Briggs, A. W., Vigneault, F., and Atwal, G. S. (2019). Single T Cell Sequencing Demonstrates the Functional Role of Aβ TCR Pairing in Cell Lineage and Antigen Specificity. *Frontiers in Immunology*, 10.

[Chaudhury et al., 2010] Chaudhury, S., Lyskov, S., and Gray, J. J. (2010). PyRosetta: A script-based interface for implementing molecular modeling algorithms using Rosetta. *Bioinformatics* (*Oxford, England*), 26(5):689-691.

[Chowell et al., 2015] Chowell, D., Krishna, S., Becker, P. D., Cocita, C., Shu, J., Tan, X., Greenberg, P. D., Klavinskis, L. S., Blattman, J. N., and Anderson, K. S. (2015). TCR contact residue hydrophobicity is a hallmark of immunogenic CD8+ T cell epitopes. *Proceedings of the National Academy of Sciences*, 112(14):E1754-E1762.
[Chronister et al., 2021] Chronister, W. D., Crinklaw, A., Mahajan, S., Vita, R., Koşaloğlu-Yalçın, Z., Yan, Z., Greenbaum, J. A., Jessen, L. E., Nielsen, M., Christley, S., Cowell, L. G., Sette, A., and Peters, B. (2021). TCRMatch: Predicting T-Cell Receptor Specificity Based on Sequence Similarity to Previously Characterized Receptors. *Frontiers in Immunology*, 12.

[Cinelli et al., 2017] Cinelli, M., Sun, Y., Best, K., Heather, J. M., Reich-Zeliger, S., Shifrut, E., Friedman, N., Shawe-Taylor, J., and Chain, B. (2017). Feature selection using a one dimensional naïve Bayes' classifier increases the accuracy of support vector machine classification of CDR3 repertoires. *Bioinformatics* (*Oxford, England*), 33(7):951–955.

[Cocco et al., 2018] Cocco, S., Feinauer, C., Figliuzzi, M., Monasson, R., and Weigt, M. (2018). Inverse statistical physics of protein sequences: A key issues review. *Reports on Progress in Physics*, 81(3):032601.

[Croft et al., 2019] Croft, N. P., Smith, S. A., Pickering, J., Sidney, J., Peters, B., Faridi, P., Witney, M. J., Sebastian, P., Flesch, I. E. A., Heading, S. L., Sette, A., Gruta, N. L. L., Purcell, A. W., and Tscharke, D. C. (2019). Most viral peptides displayed by class I MHC on infected cells are immunogenic. *Proceedings of the National Academy of Sciences*, 116(8):3112–3117.

[Dash et al., 2017] Dash, P., Fiore-Gartland, A. J., Hertz, T., Wang, G. C., Sharma, S., Souquette, A., Crawford, J. C., Clemens, E. B., Nguyen, T. H. O., Kedzierska, K., La Gruta, N. L., Bradley, P., and Thomas, P. G. (2017). Quantifiable predictive features define epitope-specific T cell receptor repertoires. *Nature*, 547(7661):89–93.

[Davidsen et al., 2019] Davidsen, K., Olson, B. J., DeWitt, III, W. S., Feng, J., Harkins, E., Bradley, P., and Matsen, IV, F. A. (2019). Deep generative models for T cell receptor protein sequences. *eLife*, 8:e46935.

[Dean et al., 2015] Dean, J., Emerson, R. O., Vignali, M., Sherwood, A. M., Rieder, M. J., Carlson, C. S., and Robins, H. S. (2015). Annotation of pseudogenic gene segments by massively parallel sequencing of rearranged lymphocyte receptor loci. *Genome Medicine*, 7(1):123.

[Elhanati et al., 2014] Elhanati, Y., Murugan, A., Callan, C. G., Mora, T., and Walczak, A. M. (2014). Quantifying selection in immune receptor repertoires. *Proceedings of the National Academy of Sciences*, 111(27):9875–9880.

[Ellington and Szostak, 1990] Ellington, A. D. and Szostak, J. W. (1990). In vitro selection of RNA molecules that bind specific ligands. *Nature*, 346(6287):818–822.

[Emerson et al., 2017] Emerson, R. O., DeWitt, W. S., Vignali, M., Gravley, J., Hu, J. K., Osborne, E. J., Desmarais, C., Klinger, M., Carlson, C. S., Hansen, J. A., Rieder, M., and Robins, H. S. (2017). Immunosequencing identifies signatures of cytomegalovirus exposure history and HLA-mediated effects on the T cell repertoire. *Nature Genetics*, 49(5):659–665.

[Gao et al., 2020] Gao, A., Chen, Z., Segal, F. P., Carrington, M., Streeck, H., Chakraborty, A. K., and Julg, B. (2020). Predicting the Immunogenicity of T cell epitopes: From HIV to SARS-CoV-2.

[Gfeller et al., 2018] Gfeller, D., Guillaume, P., Michaux, J., Pak, H.-S., Daniel, R. T., Racle, J., Coukos, G., and Bassani-Sternberg, M. (2018). The Length Distribution and Multiple Specificity of Naturally Presented HLA-I Ligands. *The Journal of Immunology*, 201(12):3705–3716.

[Gielis et al., 2019] Gielis, S., Moris, P., Bittremieux, W., De Neuter, N., Ogunjimi, B., Laukens, K., and Meysman, P. (2019). Detection of Enriched T Cell Epitope Specificity in Full T Cell Receptor Sequence Repertoires. *Frontiers in Immunology*, 10.

[Glanville et al., 2017] Glanville, J., Huang, H., Nau, A., Hatton, O., Wagar, L. E., Rubelt, F., Ji, X., Han, A., Krams, S. M., Pettus, C., Haas, N., Arlehamn, C. S. L., Sette, A., Boyd, S. D., Scriba, T. J., Martinez, O. M., and Davis, M. M. (2017). Identifying specificity groups in the T cell receptor repertoire. *Nature*, 547(7661):94–98.
[Chronister et al., 2021] Chronister, W. D., Crinklaw, A., Mahajan, S., Vita, R., Koşaloğlu-Yalçın, Z., Yan, Z., Greenbaum, J. A., Jessen, L. E., Nielsen, M., Christley, S., Cowell, L. G., Sette, A., and Peters, B. (2021). TCRMatch: Predicting T-Cell Receptor Specificity Based on Sequence Similarity to Previously Characterized Receptors. *Frontiers in Immunology*, 12.

[Cinelli et al., 2017] Cinelli, M., Sun, Y., Best, K., Heather, J. M., Reich-Zeliger, S., Shifrut, E., Friedman, N., Shawe-Taylor, J., and Chain, B. (2017). Feature selection using a one dimensional naïve Bayes' classifier increases the accuracy of support vector machine classification of CDR3 repertoires. *Bioinformatics* (*Oxford, England*), 33(7):951–955.

[Cocco et al., 2018] Cocco, S., Feinauer, C., Figliuzzi, M., Monasson, R., and Weigt, M. (2018). Inverse statistical physics of protein sequences: A key issues review. *Reports on Progress in Physics*, 81(3):032601.

[Croft et al., 2019] Croft, N. P., Smith, S. A., Pickering, J., Sidney, J., Peters, B., Faridi, P., Witney, M. J., Sebastian, P., Flesch, I. E. A., Heading, S. L., Sette, A., Gruta, N. L. L., Purcell, A. W., and Tscharke, D. C. (2019). Most viral peptides displayed by class I MHC on infected cells are immunogenic. *Proceedings of the National Academy of Sciences*, 116(8):3112–3117.

[Dash et al., 2017] Dash, P., Fiore-Gartland, A. J., Hertz, T., Wang, G. C., Sharma, S., Souquette, A., Crawford, J. C., Clemens, E. B., Nguyen, T. H. O., Kedzierska, K., La Gruta, N. L., Bradley, P., and Thomas, P. G. (2017). Quantifiable predictive features define epitope-specific T cell receptor repertoires. *Nature*, 547(7661):89–93.

[Davidsen et al., 2019] Davidsen, K., Olson, B. J., DeWitt, III, W. S., Feng, J., Harkins, E., Bradley, P., and Matsen, IV, F. A. (2019). Deep generative models for T cell receptor protein sequences. *eLife*, 8:e46935.

[Dean et al., 2015] Dean, J., Emerson, R. O., Vignali, M., Sherwood, A. M., Rieder, M. J., Carlson, C. S., and Robins, H. S. (2015). Annotation of pseudogenic gene segments by massively parallel sequencing of rearranged lymphocyte receptor loci. *Genome Medicine*, 7(1):123.

[Elhanati et al., 2014] Elhanati, Y., Murugan, A., Callan, C. G., Mora, T., and Walczak, A. M. (2014). Quantifying selection in immune receptor repertoires. *Proceedings of the National Academy of Sciences*, 111(27):9875–9880.

[Ellington and Szostak, 1990] Ellington, A. D. and Szostak, J. W. (1990). In vitro selection of RNA molecules that bind specific ligands. *Nature*, 346(6287):818–822.

[Emerson et al., 2017] Emerson, R. O., DeWitt, W. S., Vignali, M., Gravley, J., Hu, J. K., Osborne, E. J., Desmarais, C., Klinger, M., Carlson, C. S., Hansen, J. A., Rieder, M., and Robins, H. S. (2017). Immunosequencing identifies signatures of cytomegalovirus exposure history and HLA-mediated effects on the T cell repertoire. *Nature Genetics*, 49(5):659–665.

[Gao et al., 2020] Gao, A., Chen, Z., Segal, F. P., Carrington, M., Streeck, H., Chakraborty, A. K., and Julg, B. (2020). Predicting the Immunogenicity of T cell epitopes: From HIV to SARS-CoV-2.

[Gfeller et al., 2018] Gfeller, D., Guillaume, P., Michaux, J., Pak, H.-S., Daniel, R. T., Racle, J., Coukos, G., and Bassani-Sternberg, M. (2018). The Length Distribution and Multiple Specificity of Naturally Presented HLA-I Ligands. *The Journal of Immunology*, 201(12):3705–3716.

[Gielis et al., 2019] Gielis, S., Moris, P., Bittremieux, W., De Neuter, N., Ogunjimi, B., Laukens, K., and Meysman, P. (2019). Detection of Enriched T Cell Epitope Specificity in Full T Cell Receptor Sequence Repertoires. *Frontiers in Immunology*, 10.

[Glanville et al., 2017] Glanville, J., Huang, H., Nau, A., Hatton, O., Wagar, L. E., Rubelt, F., Ji, X., Han, A., Krams, S. M., Pettus, C., Haas, N., Arlehamn, C. S. L., Sette, A., Boyd, S. D., Scriba, T. J., Martinez, O. M., and Davis, M. M. (2017). Identifying specificity groups in the T cell receptor repertoire. *Nature*, 547(7661):94–98.
[Goncharov et al., 2022] Goncharov, M. M., Bryushkova, E. A., Sharaev, N. I., Skatova, V. D., Baryshnikova, A. M., Sharonov, G. V., Karnaukhov, V., Vakhitova, M. T., Samoylenko, I. V., Demidov, L. V., Lukyanov, S., Chudakov, D. M., and Serebrovskaya, E. O. (2022). Pinpointing the tumor-specific T cells via TCR clusters. *eLife*, 11:e77274.

[Hinton, 2002] Hinton, G. E. (2002). Training Products of Experts by Minimizing Contrastive Divergence. *Neural Computation*, 14(8):1771–1800.

[Hinton and Salakhutdinov, 2006] Hinton, G. E. and Salakhutdinov, R. R. (2006). Reducing the Dimensionality of Data with Neural Networks. *Science*, 313(5786):504–507.

[Hoof et al., 2010] Hoof, I., Pérez, C. L., Buggert, M., Gustafsson, R. K. L., Nielsen, M., Lund, O., and Karlsson, A. C. (2010). Interdisciplinary analysis of HIV-specific CD8+ T cell responses against variant epitopes reveals restricted TCR promiscuity. *Journal of Immunology (Baltimore, Md.: 1950)*, 184(9):5383–5391.

[Huang et al., 2020] Huang, H., Wang, C., Rubelt, F., Scriba, T. J., and Davis, M. M. (2020). Analyzing the Mycobacterium tuberculosis immune response by T-cell receptor clustering with GLIPH2 and genome-wide antigen screening. *Nature Biotechnology*, 38(10):1194–1202.

[Isacchini et al., 2021] Isacchini, G., Walczak, A. M., Mora, T., and Nourmohammad, A. (2021). Deep generative selection models of T and B cell receptor repertoires with soNNia. *Proceedings of the National Academy of Sciences*, 118(14).

[Jäckel et al., 2008] Jäckel, C., Kast, P., and Hilvert, D. (2008). Protein design by directed evolution. *Annual Review of Biophysics*, 37:153–173.

[Jokinen et al., 2019] Jokinen, E., Huuhtanen, J., Mustjoki, S., Heinonen, M., and Lähdesmäki, H. (2019). Determining epitope specificity of T cell receptors with TCRGP. *bioRxiv*, 10.1101/542332, page 542332.

[Karnaukhov et al., 2022] Karnaukhov, V. K., Shcherbinin, D. S., Chugunov, A. O., Chudakov, D. M., Efremov, R. G., Zvyagin, I. V., and Shugay, M. (2022). Predicting TCR-peptide recognition based on residue-level pairwise statistical potential.

[Kristensen et al., 2022] Kristensen, N. P., Heeke, C., Tvingsholm, S. A., Borch, A., Draghi, A., Crowther, M. D., Carri, I., Munk, K. K., Holm, J. S., Bjerregaard, A.-M., Bentzen, A. K., Marquard, A. M., Szallasi, Z., McGranahan, N., Andersen, R., Nielsen, M., Jönsson, G. B., Donia, M., Svane, I. M., and Hadrup, S. R. (2022). Neoantigen-reactive CD8+ T cells affect clinical outcome of adoptive cell therapy with tumor-infiltrating lymphocytes in melanoma. *The Journal of Clinical Investigation*, 132(2).

[Lin et al., 2021] Lin, X., George, J. T., Schafer, N. P., Ng Chau, K., Birnbaum, M. E., Clementi, C., Onuchic, J. N., and Levine, H. (2021). Rapid assessment of T-cell receptor specificity of the immune repertoire. *Nature Computational Science*, 1(5):362–373.

[Loshchilov and Hutter, 2019] Loshchilov, I. and Hutter, F. (2019). Decoupled Weight Decay Regularization. In *ICLR*.

[Lu et al., 2021] Lu, T., Zhang, Z., Zhu, J., Wang, Y., Jiang, P., Xiao, X., Bernatchez, C., Heymach, J. V., Gibbons, D. L., Wang, J., Xu, L., Reuben, A., and Wang, T. (2021). Deep learning-based prediction of the T cell receptor-antigen binding specificity. *Nature Machine Intelligence*, 3(10):864–875.

[Łuksza et al., 2017] Łuksza, M., Riaz, N., Makarov, V., Balachandran, V. P., Hellmann, M. D., Solovyov, A., Rizvi, N. A., Merghoub, T., Levine, A. J., Chan, T. A., Wolchok, J. D., and Greenbaum, B. D. (2017). A neoantigen fitness model predicts tumour response to checkpoint blockade immunotherapy. *Nature*, 551(7681):517–520.
[Goncharov et al., 2022] Goncharov, M. M., Bryushkova, E. A., Sharaev, N. I., Skatova, V. D., Baryshnikova, A. M., Sharonov, G. V., Karnaukhov, V., Vakhitova, M. T., Samoylenko, I. V., Demidov, L. V., Lukyanov, S., Chudakov, D. M., and Serebrovskaya, E. O. (2022). Pinpointing the tumor-specific T cells via TCR clusters. *eLife*, 11:e77274.

[Hinton, 2002] Hinton, G. E. (2002). Training Products of Experts by Minimizing Contrastive Divergence. *Neural Computation*, 14(8):1771-1800.

[Hinton and Salakhutdinov, 2006] Hinton, G. E. and Salakhutdinov, R. R. (2006). Reducing the Dimensionality of Data with Neural Networks. *Science*, 313(5786):504-507.

[Hoof et al., 2010] Hoof, I., Pérez, C. L., Buggert, M., Gustafsson, R. K. L., Nielsen, M., Lund, O., and Karlsson, A. C. (2010). Interdisciplinary analysis of HIV-specific CD8+ T cell responses against variant epitopes reveals restricted TCR promiscuity. *Journal of Immunology (Baltimore, Md.: 1950)*, 184(9):5383-5391.

[Huang et al., 2020] Huang, H., Wang, C., Rubelt, F., Scriba, T. J., and Davis, M. M. (2020). Analyzing the Mycobacterium tuberculosis immune response by T-cell receptor clustering with GLIPH2 and genome-wide antigen screening. *Nature Biotechnology*, 38(10):1194-1202.

[Isacchini et al., 2021] Isacchini, G., Walczak, A. M., Mora, T., and Nourmohammad, A. (2021). Deep generative selection models of T and B cell receptor repertoires with soNNia. *Proceedings of the National Academy of Sciences*, 118(14).

[Jäckel et al., 2008] Jäckel, C., Kast, P., and Hilvert, D. (2008). Protein design by directed evolution. *Annual Review of Biophysics*, 37:153-173.

[Jokinen et al., 2019] Jokinen, E., Huuhtanen, J., Mustjoki, S., Heinonen, M., and Lähdesmäki, H. (2019). Determining epitope specificity of T cell receptors with TCRGP. *bioRxiv*, 10.1101/542332, page 542332.

[Karnaukhov et al., 2022] Karnaukhov, V. K., Shcherbinin, D. S., Chugunov, A. O., Chudakov, D. M., Efremov, R. G., Zvyagin, I. V., and Shugay, M. (2022). Predicting TCR-peptide recognition based on residue-level pairwise statistical potential.

[Kristensen et al., 2022] Kristensen, N. P., Heeke, C., Tvingsholm, S. A., Borch, A., Draghi, A., Crowther, M. D., Carri, I., Munk, K. K., Holm, J. S., Bjerregaard, A.-M., Bentzen, A. K., Marquard, A. M., Szallasi, Z., McGranahan, N., Andersen, R., Nielsen, M., Jönsson, G. B., Donia, M., Svane, I. M., and Hadrup, S. R. (2022). Neoantigen-reactive CD8+ T cells affect clinical outcome of adoptive cell therapy with tumor-infiltrating lymphocytes in melanoma. *The Journal of Clinical Investigation*, 132(2).

[Lin et al., 2021] Lin, X., George, J. T., Schafer, N. P., Ng Chau, K., Birnbaum, M. E., Clementi, C., Onuchic, J. N., and Levine, H. (2021). Rapid assessment of T-cell receptor specificity of the immune repertoire. *Nature Computational Science*, 1(5):362-373.

[Loshchilov and Hutter, 2019] Loshchilov, I. and Hutter, F. (2019). Decoupled Weight Decay Regularization. In *ICLR*.

[Lu et al., 2021] Lu, T., Zhang, Z., Zhu, J., Wang, Y., Jiang, P., Xiao, X., Bernatchez, C., Heymach, J. V., Gibbons, D. L., Wang, J., Xu, L., Reuben, A., and Wang, T. (2021). Deep learning-based prediction of the T cell receptor-antigen binding specificity. *Nature Machine Intelligence*, 3(10):864-875.

[Łuksza et al., 2017] Łuksza, M., Riaz, N., Makarov, V., Balachandran, V. P., Hellmann, M. D., Solovyov, A., Rizvi, N. A., Merghoub, T., Levine, A. J., Chan, T. A., Wolchok, J. D., and Greenbaum, B. D. (2017). A neoantigen fitness model predicts tumour response to checkpoint blockade immunotherapy. *Nature*, 551(7681):517-520.
[Łuksza et al., 2022] Łuksza, M., Sethna, Z. M., Rojas, L. A., Lihm, J., Bravi, B., Elhanati, Y., Soares, K., Amisaki, M., Dobrin, A., Hoyos, D., Guasp, P., Zebboudj, A., Yu, R., Chandra, A. K., Waters, T., Odgerel, Z., Leung, J., Kappagantula, R., Makohon-Moore, A., Johns, A., Gill, A., Gigoux, M., Wolchok, J., Merghoub, T., Sadelain, M., Patterson, E., Monasson, R., Mora, T., Walczak, A. M., Cocco, S., Iacobuzio-Donahue, C., Greenbaum, B. D., and Balachandran, V. P. (2022). Neoantigen quality predicts immunoediting in survivors of pancreatic cancer. *Nature*, 606(7913):389–395.

[Luu et al., 2021] Luu, A. M., Leistico, J. R., Miller, T., Kim, S., and Song, J. S. (2021). Predicting TCR-Epitope Binding Specificity Using Deep Metric Learning and Multimodal Learning. *Genes*, 12(4):572.

[Maas et al., 2013] Maas, A. L., Hannun, A. Y., and Ng, A. Y. (2013). Rectifier Nonlinearities Improve Neural Network Acoustic Models. *Proceedings of the 30th International Conference on Machine Learning*, 28(3):6.

[Marchi et al., 2019] Marchi, J., Galpern, E. A., Espada, R., Ferreiro, D. U., Walczak, A. M., and Mora, T. (2019). Size and structure of the sequence space of repeat proteins. *PLOS Computational Biology*, 15(8):e1007282.

[Mayer-Blackwell et al., 2021] Mayer-Blackwell, K., Schattgen, S., Cohen-Lavi, L., Crawford, J. C., Souquette, A., Gaevert, J. A., Hertz, T., Thomas, P. G., Bradley, P., and Fiore-Gartland, A. (2021). TCR meta-clonotypes for biomarker discovery with tcrdist3 enabled identification of public, HLA-restricted clusters of SARS-CoV-2 TCRs. *eLife*, 10:e68605.

[Meysman et al., 2022] Meysman, P., Barton, J., Bravi, B., Cohen-Lavi, L., Karnaukhov, V., Lilleskov, E., Montemurro, A., Nielsen, M., Mora, T., Pereira, P., Postovskaya, A., Martínez, M. R., Fernandez-de-Cossio-Diaz, J., Vujkovic, A., Walczak, A. M., Weber, A., Yin, R., Eugster, A., and Sharma, V. (2022). Benchmarking solutions to the T-cell receptor epitope prediction problem: IMMREP22 workshop report.

[Meysman et al., 2019] Meysman, P., De Neuter, N., Gielis, S., Bui Thi, D., Ogunjimi, B., and Laukens, K. (2019). On the viability of unsupervised T-cell receptor sequence clustering for epitope preference. *Bioinformatics* (Oxford, England), 35(9):1461–1468.

[Milighetti et al., 2021] Milighetti, M., Shawe-Taylor, J., and Chain, B. (2021). Predicting T Cell Receptor Antigen Specificity From Structural Features Derived From Homology Models of Receptor-Peptide-Major Histocompatibility Complexes. *Frontiers in Physiology*, 12.

[Minervina et al., 2021] Minervina, A. A., Komech, E. A., Titov, A., Bensouda Koraichi, M., Rosati, E., Mamedov, I. Z., Franke, A., Efimov, G. A., Chudakov, D. M., Mora, T., Walczak, A. M., Lebedev, Y. B., and Pogorelyy, M. V. (2021). Longitudinal high-throughput TCR repertoire profiling reveals the dynamics of T-cell memory formation after mild COVID-19 infection. *eLife*, 10:e63502.

[Montemurro et al., 2021] Montemurro, A., Schuster, V., Povlsen, H. R., Bentzen, A. K., Jurtz, V., Chronister, W. D., Crinklaw, A., Hadrup, S. R., Winther, O., Peters, B., Jessen, L. E., and Nielsen, M. (2021). NetTCR-2.0 enables accurate prediction of TCR-peptide binding by using paired TCRα and β sequence data. *Communications Biology*, 4(1):1–13.

[Morcos et al., 2011] Morcos, F., Pagnani, A., Lunt, B., Bertolino, A., Marks, D. S., Sander, C., Zecchina, R., Onuchic, J. N., Hwa, T., and Weigt, M. (2011). Direct-coupling analysis of residue co-evolution captures native contacts across many protein families. *Proceedings of the National Academy of Sciences*, 108(49):E1293–E1301.

[Moris et al., 2021] Moris, P., De Pauw, J., Postovskaya, A., Gielis, S., De Neuter, N., Bittremieux, W., Ogunjimi, B., Laukens, K., and Meysman, P. (2021). Current challenges for unseen-epitope TCR interaction prediction and a new perspective derived from image classification. *Briefings in Bioinformatics*, 22(4):bbaa318.
[Łuksza et al., 2022] Łuksza, M., Sethna, Z. M., Rojas, L. A., Lihm, J., Bravi, B., Elhanati, Y., Soares, K., Amisaki, M., Dobrin, A., Hoyos, D., Guasp, P., Zebboudj, A., Yu, R., Chandra, A. K., Waters, T., Odgerel, Z., Leung, J., Kappagantula, R., Makohon-Moore, A., Johns, A., Gill, A., Gigoux, M., Wolchok, J., Merghoub, T., Sadelain, M., Patterson, E., Monasson, R., Mora, T., Walczak, A. M., Cocco, S., Iacobuzio-Donahue, C., Greenbaum, B. D., and Balachandran, V. P. (2022). Neoantigen quality predicts immunoediting in survivors of pancreatic cancer. *Nature*, 606(7913):389–395.

[Luu et al., 2021] Luu, A. M., Leistico, J. R., Miller, T., Kim, S., and Song, J. S. (2021). Predicting TCR-Epitope Binding Specificity Using Deep Metric Learning and Multimodal Learning. *Genes*, 12(4):572.

[Maas et al., 2013] Maas, A. L., Hannun, A. Y., and Ng, A. Y. (2013). Rectifier Nonlinearities Improve Neural Network Acoustic Models. *Proceedings of the 30th International Conference on Machine Learning*, 28(3):6.

[Marchi et al., 2019] Marchi, J., Galpern, E. A., Espada, R., Ferreiro, D. U., Walczak, A. M., and Mora, T. (2019). Size and structure of the sequence space of repeat proteins. *PLOS Computational Biology*, 15(8):e1007282.

[Mayer-Blackwell et al., 2021] Mayer-Blackwell, K., Schattgen, S., Cohen-Lavi, L., Crawford, J. C., Souquette, A., Gaevert, J. A., Hertz, T., Thomas, P. G., Bradley, P., and Fiore-Gartland, A. (2021). TCR meta-clonotypes for biomarker discovery with tcrdist3 enabled identification of public, HLA-restricted clusters of SARS-CoV-2 TCRs. *eLife*, 10:e68605.

[Meysman et al., 2022] Meysman, P., Barton, J., Bravi, B., Cohen-Lavi, L., Karnaukhov, V., Lilleskov, E., Montemurro, A., Nielsen, M., Mora, T., Pereira, P., Postovskaya, A., Martínez, M. R., Fernandez-de-Cossio-Diaz, J., Vujkovic, A., Walczak, A. M., Weber, A., Yin, R., Eugster, A., and Sharma, V. (2022). Benchmarking solutions to the T-cell receptor epitope prediction problem: IMMREP22 workshop report.

[Meysman et al., 2019] Meysman, P., De Neuter, N., Gielis, S., Bui Thi, D., Ogunjimi, B., and Laukens, K. (2019). On the viability of unsupervised T-cell receptor sequence clustering for epitope preference. *Bioinformatics* (Oxford, England), 35(9):1461–1468.

[Milighetti et al., 2021] Milighetti, M., Shawe-Taylor, J., and Chain, B. (2021). Predicting T Cell Receptor Antigen Specificity From Structural Features Derived From Homology Models of Receptor-Peptide-Major Histocompatibility Complexes. *Frontiers in Physiology*, 12.

[Minervina et al., 2021] Minervina, A. A., Komech, E. A., Titov, A., Bensouda Koraichi, M., Rosati, E., Mamedov, I. Z., Franke, A., Efimov, G. A., Chudakov, D. M., Mora, T., Walczak, A. M., Lebedev, Y. B., and Pogorelyy, M. V. (2021). Longitudinal high-throughput TCR repertoire profiling reveals the dynamics of T-cell memory formation after mild COVID-19 infection. *eLife*, 10:e63502.

[Montemurro et al., 2021] Montemurro, A., Schuster, V., Povlsen, H. R., Bentzen, A. K., Jurtz, V., Chronister, W. D., Crinklaw, A., Hadrup, S. R., Winther, O., Peters, B., Jessen, L. E., and Nielsen, M. (2021). NetTCR-2.0 enables accurate prediction of TCR-peptide binding by using paired TCRα and β sequence data. *Communications Biology*, 4(1):1–13.

[Morcos et al., 2011] Morcos, F., Pagnani, A., Lunt, B., Bertolino, A., Marks, D. S., Sander, C., Zecchina, R., Onuchic, J. N., Hwa, T., and Weigt, M. (2011). Direct-coupling analysis of residue co-evolution captures native contacts across many protein families. *Proceedings of the National Academy of Sciences*, 108(49):E1293–E1301.

[Moris et al., 2021] Moris, P., De Pauw, J., Postovskaya, A., Gielis, S., De Neuter, N., Bittremieux, W., Ogunjimi, B., Laukens, K., and Meysman, P. (2021). Current challenges for unseen-epitope TCR interaction prediction and a new perspective derived from image classification. *Briefings in Bioinformatics*, 22(4):bbaa318.
[Ogishi and Yotsuyanagi, 2019] Ogishi, M. and Yotsuyanagi, H. (2019). Quantitative Prediction of the Landscape of T Cell Epitope Immunogenicity in Sequence Space. *Frontiers in Immunology*, 10:827.

[Ostmeyer et al., 2019] Ostmeyer, J., Christley, S., Toby, I. T., and Cowell, L. G. (2019). Biophysico-chemical Motifs in T-cell Receptor Sequences Distinguish Repertoires from Tumor-Infiltrating Lymphocyte and Adjacent Healthy Tissue. *Cancer Research*, 79(7):1671–1680.

[Packer and Liu, 2015] Packer, M. S. and Liu, D. R. (2015). Methods for the directed evolution of proteins. *Nature Reviews Genetics*, 16(7):379–394.

[Papadopoulou et al., 2022] Papadopoulou, I., Nguyen, A.-P., Weber, A., and Martínez, M. R. (2022). DECODE: A computational pipeline to discover T cell receptor binding rules. *Bioinformatics*, 38(Supplement_1):i246–i254.

[Piepenbrink et al., 2013] Piepenbrink, K. H., Blevins, S. J., Scott, D. R., and Baker, B. M. (2013). The basis for limited specificity and MHC restriction in a T cell receptor interface. *Nature Communications*, 4(1):1948.

[Pogorelyy et al., 2019] Pogorelyy, M. V., Minervina, A. A., Shugay, M., Chudakov, D. M., Lebedev, Y. B., Mora, T., and Walczak, A. M. (2019). Detecting T cell receptors involved in immune responses from single repertoire snapshots. *PLOS Biology*, 17(6):e3000314.

[Pogorelyy and Shugay, 2019] Pogorelyy, M. V. and Shugay, M. (2019). A Framework for Annotation of Antigen Specificities in High-Throughput T-Cell Repertoire Sequencing Studies. *Frontiers in Immunology*, 10:2159.

[Reynisson et al., 2020] Reynisson, B., Alvarez, B., Paul, S., Peters, B., and Nielsen, M. (2020). NetMHCpan-4.1 and NetMHCIIpan-4.0: Improved predictions of MHC antigen presentation by concurrent motif deconvolution and integration of MS MHC eluted ligand data. *Nucleic Acids Research*, 48(W1):W449–W454.

[Riley et al., 2019] Riley, T. P., Keller, G. L. J., Smith, A. R., Davancaze, L. M., Arbuiso, A. G., Devlin, J. R., and Baker, B. M. (2019). Structure Based Prediction of Neoantigen Immunogenicity. *Frontiers in Immunology*, 10:2047.

[Rossjohn et al., 2015] Rossjohn, J., Gras, S., Miles, J. J., Turner, S. J., Godfrey, D. I., and McCluskey, J. (2015). T Cell Antigen Receptor Recognition of Antigen-Presenting Molecules. *Annual Review of Immunology*, 33(1):169–200.

[Rudolph et al., 2006] Rudolph, M. G., Stanfield, R. L., and Wilson, I. A. (2006). How TCRs bind MHCs, peptides, and coreceptors. *Annual Review of Immunology*, 24:419–466.

[Schaap-Johansen et al., 2021] Schaap-Johansen, A.-L., Vujović, M., Borch, A., Hadrup, S. R., and Marcatili, P. (2021). T Cell Epitope Prediction and Its Application to Immunotherapy. *Frontiers in Immunology*, 12:2994.

[Schenck et al., 2019] Schenck, R. O., Lakatos, E., Gatenbee, C., Graham, T. A., and Anderson, A. R. (2019). NeoPredPipe: High-throughput neoantigen prediction and recognition potential pipeline. *BMC Bioinformatics*, 20(1):264.

[Schmidt et al., 2021] Schmidt, J., Smith, A. R., Magnin, M., Racle, J., Devlin, J. R., Bobisse, S., Cesbron, J., Bonnet, V., Carmona, S. J., Huber, F., Ciriello, G., Speiser, D. E., Bassani-Sternberg, M., Coukos, G., Baker, B. M., Harari, A., and Gfeller, D. (2021). Prediction of neo-epitope immunogenicity reveals TCR recognition determinants and provides insight into immunoediting. *Cell Reports Medicine*, 2(2):100194.
[Ogishi and Yotsuyanagi, 2019] Ogishi, M. and Yotsuyanagi, H. (2019). Quantitative Prediction of the Landscape of T Cell Epitope Immunogenicity in Sequence Space. *Frontiers in Immunology*, 10:827.

[Ostmeyer et al., 2019] Ostmeyer, J., Christley, S., Toby, I. T., and Cowell, L. G. (2019). Biophysico-chemical Motifs in T-cell Receptor Sequences Distinguish Repertoires from Tumor-Infiltrating Lymphocyte and Adjacent Healthy Tissue. *Cancer Research*, 79(7):1671–1680.

[Packer and Liu, 2015] Packer, M. S. and Liu, D. R. (2015). Methods for the directed evolution of proteins. *Nature Reviews Genetics*, 16(7):379–394.

[Papadopoulou et al., 2022] Papadopoulou, I., Nguyen, A.-P., Weber, A., and Martínez, M. R. (2022). DECODE: A computational pipeline to discover T cell receptor binding rules. *Bioinformatics*, 38(Supplement_1):i246–i254.

[Piepenbrink et al., 2013] Piepenbrink, K. H., Blevins, S. J., Scott, D. R., and Baker, B. M. (2013). The basis for limited specificity and MHC restriction in a T cell receptor interface. *Nature Communications*, 4(1):1948.

[Pogorelyy et al., 2019] Pogorelyy, M. V., Minervina, A. A., Shugay, M., Chudakov, D. M., Lebedev, Y. B., Mora, T., and Walczak, A. M. (2019). Detecting T cell receptors involved in immune responses from single repertoire snapshots. *PLOS Biology*, 17(6):e3000314.

[Pogorelyy and Shugay, 2019] Pogorelyy, M. V. and Shugay, M. (2019). A Framework for Annotation of Antigen Specificities in High-Throughput T-Cell Repertoire Sequencing Studies. *Frontiers in Immunology*, 10:2159.

[Reynisson et al., 2020] Reynisson, B., Alvarez, B., Paul, S., Peters, B., and Nielsen, M. (2020). NetMHCpan-4.1 and NetMHCIIpan-4.0: Improved predictions of MHC antigen presentation by concurrent motif deconvolution and integration of MS MHC eluted ligand data. *Nucleic Acids Research*, 48(W1):W449–W454.

[Riley et al., 2019] Riley, T. P., Keller, G. L. J., Smith, A. R., Davancaze, L. M., Arbuiso, A. G., Devlin, J. R., and Baker, B. M. (2019). Structure Based Prediction of Neoantigen Immunogenicity. *Frontiers in Immunology*, 10:2047.

[Rossjohn et al., 2015] Rossjohn, J., Gras, S., Miles, J. J., Turner, S. J., Godfrey, D. I., and McCluskey, J. (2015). T Cell Antigen Receptor Recognition of Antigen-Presenting Molecules. *Annual Review of Immunology*, 33(1):169–200.

[Rudolph et al., 2006] Rudolph, M. G., Stanfield, R. L., and Wilson, I. A. (2006). How TCRs bind MHCs, peptides, and coreceptors. *Annual Review of Immunology*, 24:419–466.

[Schaap-Johansen et al., 2021] Schaap-Johansen, A.-L., Vujović, M., Borch, A., Hadrup, S. R., and Marcatili, P. (2021). T Cell Epitope Prediction and Its Application to Immunotherapy. *Frontiers in Immunology*, 12:2994.

[Schenck et al., 2019] Schenck, R. O., Lakatos, E., Gatenbee, C., Graham, T. A., and Anderson, A. R. (2019). NeoPredPipe: High-throughput neoantigen prediction and recognition potential pipeline. *BMC Bioinformatics*, 20(1):264.

[Schmidt et al., 2021] Schmidt, J., Smith, A. R., Magnin, M., Racle, J., Devlin, J. R., Bobisse, S., Cesbron, J., Bonnet, V., Carmona, S. J., Huber, F., Ciriello, G., Speiser, D. E., Bassani-Sternberg, M., Coukos, G., Baker, B. M., Harari, A., and Gfeller, D. (2021). Prediction of neo-epitope immunogenicity reveals TCR recognition determinants and provides insight into immunoediting. *Cell Reports Medicine*, 2(2):100194.
[Sehnal et al., 2018] Sehnal, D., Rose, A. S., Koča, J., Burley, S. K., and Velankar, S. (2018). Mol*: Towards a common library and tools for web molecular graphics. In *Proceedings of the Workshop on Molecular Graphics and Visual Analysis of Molecular Data*, MolVA '18, pages 29–33, Brno, Czech Republic. Eurographics Association.

[Sethna et al., 2020] Sethna, Z., Isacchini, G., Dupic, T., Mora, T., Walczak, A. M., and Elhanati, Y. (2020). Population variability in the generation and selection of T-cell repertoires. *PLOS Computational Biology*, 16(12):e1008394.

[Sette et al., 1994] Sette, A., Vitiello, A., Reherman, B., Fowler, P., Nayersina, R., Kast, W. M., Melief, C. J., Oseroff, C., Yuan, L., Ruppert, J., Sidney, J., del Guercio, M. F., Southwood, S., Kubo, R. T., Chesnut, R. W., Grey, H. M., and Chisari, F. V. (1994). The relationship between class I binding affinity and immunogenicity of potential cytotoxic T cell epitopes. *Journal of Immunology (Baltimore, Md.: 1950)*, 153(12):5586–5592.

[Sheriff et al., 1987] Sheriff, S., Hendrickson, W. A., and Smith, J. L. (1987). Structure of myohemerythrin in the azidomet state at 1.71.3Å resolution. *Journal of Molecular Biology*, 197(2):273–296.

[Shomuradova et al., 2020] Shomuradova, A. S., Vagida, M. S., Sheetikov, S. A., Zornikova, K. V., Kiryukhin, D., Titov, A., Peshkova, I. O., Khmelevskaya, A., Dianov, D. V., Malasheva, M., Shmelev, A., Serdyuk, Y., Bagaev, D. V., Pivnyuk, A., Shcherbinin, D. S., Maleeva, A. V., Shakirova, N. T., Pilunov, A., Malko, D. B., Khamaganova, E. G., Biderman, B., Ivanov, A., Shugay, M., and Efimov, G. A. (2020). SARS-CoV-2 Epitopes Are Recognized by a Public and Diverse Repertoire of Human T Cell Receptors. *Immunity*, 53(6):1245–1257.e5.

[Shugay et al., 2018] Shugay, M., Bagaev, D. V., Zvyagin, I. V., Vroomans, R. M., Crawford, J. C., Dolton, G., Komech, E. A., Sycheva, A. L., Koneva, A. E., Egorov, E. S., Eliseev, A. V., Van Dyk, E., Dash, P., Attaf, M., Rius, C., Ladell, K., McLaren, J. E., Matthews, K. K., Clemens, E. B., Douek, D. C., Luciani, F., van Baarle, D., Kedzierska, K., Kesmir, C., Thomas, P. G., Price, D. A., Sewell, A. K., and Chudakov, D. M. (2018). VDJdb: A curated database of T-cell receptor sequences with known antigen specificity. *Nucleic Acids Research*, 46(D1):D419–D427.

[Sidhom et al., 2021] Sidhom, J.-W., Larman, H. B., Pardoll, D. M., and Baras, A. S. (2021). DeepTCR is a deep learning framework for revealing sequence concepts within T-cell repertoires. *Nature Communications*, 12(1):1605.

[Smith et al., 2019] Smith, C. C., Chai, S., Washington, A. R., Lee, S. J., Landoni, E., Field, K., Garden, J., Bixby, L. M., Selitsky, S. R., Parker, J. S., Savoldo, B., Serody, J. S., and Vincent, B. G. (2019). Machine-Learning Prediction of Tumor Antigen Immunogenicity in the Selection of Therapeutic Epitopes. *Cancer Immunology Research*, 7(10):1591–1604.

[Sola et al., 2020] Sola, M., Menon, A. P., Moreno, B., Meraviglia-Crivelli, D., Soldevilla, M. M., Cartón-García, F., and Pastor, F. (2020). Aptamers Against Live Targets: Is In Vivo SELEX Finally Coming to the Edge? *Molecular Therapy - Nucleic Acids*, 21:192–204.

[Springer et al., 2020] Springer, I., Besser, H., Tickotsky-Moskovitz, N., Dvorkin, S., and Louzoun, Y. (2020). Prediction of Specific TCR-Peptide Binding From Large Dictionaries of TCR-Peptide Pairs. *Frontiers in Immunology*, 11.

[Thakkar and Bailey-Kellogg, 2019] Thakkar, N. and Bailey-Kellogg, C. (2019). Balancing sensitivity and specificity in distinguishing TCR groups by CDR sequence similarity. *BMC Bioinformatics*, 20(1):241.

[Trolle and Nielsen, 2014] Trolle, T. and Nielsen, M. (2014). NetTepi: An integrated method for the prediction of T cell epitopes. *Immunogenetics*, 66(7):449–456.

[Tubiana et al., 2019] Tubiana, J., Cocco, S., and Monasson, R. (2019). Learning protein constitutive motifs from sequence data. *eLife*, 8:e39397.
[Sehnal et al., 2018] Sehnal, D., Rose, A. S., Koča, J., Burley, S. K., and Velankar, S. (2018). Mol*: Towards a common library and tools for web molecular graphics. In *Proceedings of the Workshop on Molecular Graphics and Visual Analysis of Molecular Data*, MolVA '18, pages 29–33, Brno, Czech Republic. Eurographics Association.

[Sethna et al., 2020] Sethna, Z., Isacchini, G., Dupic, T., Mora, T., Walczak, A. M., and Elhanati, Y. (2020). Population variability in the generation and selection of T-cell repertoires. *PLOS Computational Biology*, 16(12):e1008394.

[Sette et al., 1994] Sette, A., Vitiello, A., Reherman, B., Fowler, P., Nayersina, R., Kast, W. M., Melief, C. J., Oseroff, C., Yuan, L., Ruppert, J., Sidney, J., del Guercio, M. F., Southwood, S., Kubo, R. T., Chesnut, R. W., Grey, H. M., and Chisari, F. V. (1994). The relationship between class I binding affinity and immunogenicity of potential cytotoxic T cell epitopes. *Journal of Immunology (Baltimore, Md.: 1950)*, 153(12):5586–5592.

[Sheriff et al., 1987] Sheriff, S., Hendrickson, W. A., and Smith, J. L. (1987). Structure of myohemerythrin in the azidomet state at 1.71.3Å resolution. *Journal of Molecular Biology*, 197(2):273–296.

[Shomuradova et al., 2020] Shomuradova, A. S., Vagida, M. S., Sheetikov, S. A., Zornikova, K. V., Kiryukhin, D., Titov, A., Peshkova, I. O., Khmelevskaya, A., Dianov, D. V., Malasheva, M., Shmelev, A., Serdyuk, Y., Bagaev, D. V., Pivnyuk, A., Shcherbinin, D. S., Maleeva, A. V., Shakirova, N. T., Pilunov, A., Malko, D. B., Khamaganova, E. G., Biderman, B., Ivanov, A., Shugay, M., and Efimov, G. A. (2020). SARS-CoV-2 Epitopes Are Recognized by a Public and Diverse Repertoire of Human T Cell Receptors. *Immunity*, 53(6):1245–1257.e5.

[Shugay et al., 2018] Shugay, M., Bagaev, D. V., Zvyagin, I. V., Vroomans, R. M., Crawford, J. C., Dolton, G., Komech, E. A., Sycheva, A. L., Koneva, A. E., Egorov, E. S., Eliseev, A. V., Van Dyk, E., Dash, P., Attaf, M., Rius, C., Ladell, K., McLaren, J. E., Matthews, K. K., Clemens, E. B., Douek, D. C., Luciani, F., van Baarle, D., Kedzierska, K., Kesmir, C., Thomas, P. G., Price, D. A., Sewell, A. K., and Chudakov, D. M. (2018). VDJdb: A curated database of T-cell receptor sequences with known antigen specificity. *Nucleic Acids Research*, 46(D1):D419–D427.

[Sidhom et al., 2021] Sidhom, J.-W., Larman, H. B., Pardoll, D. M., and Baras, A. S. (2021). DeepTCR is a deep learning framework for revealing sequence concepts within T-cell repertoires. *Nature Communications*, 12(1):1605.

[Smith et al., 2019] Smith, C. C., Chai, S., Washington, A. R., Lee, S. J., Landoni, E., Field, K., Garness, J., Bixby, L. M., Selitsky, S. R., Parker, J. S., Savoldo, B., Serody, J. S., and Vincent, B. G. (2019). Machine-Learning Prediction of Tumor Antigen Immunogenicity in the Selection of Therapeutic Epitopes. *Cancer Immunology Research*, 7(10):1591–1604.

[Sola et al., 2020] Sola, M., Menon, A. P., Moreno, B., Meraviglia-Crivelli, D., Soldevilla, M. M., Cartón-García, F., and Pastor, F. (2020). Aptamers Against Live Targets: Is In Vivo SELEX Finally Coming to the Edge? *Molecular Therapy - Nucleic Acids*, 21:192–204.

[Springer et al., 2020] Springer, I., Besser, H., Tickotsky-Moskovitz, N., Dvorkin, S., and Louzoun, Y. (2020). Prediction of Specific TCR-Peptide Binding From Large Dictionaries of TCR-Peptide Pairs. *Frontiers in Immunology*, 11.

[Thakkar and Bailey-Kellogg, 2019] Thakkar, N. and Bailey-Kellogg, C. (2019). Balancing sensitivity and specificity in distinguishing TCR groups by CDR sequence similarity. *BMC Bioinformatics*, 20(1):241.

[Trolle and Nielsen, 2014] Trolle, T. and Nielsen, M. (2014). NetTepi: An integrated method for the prediction of T cell epitopes. *Immunogenetics*, 66(7):449–456.

[Tubiana et al., 2019] Tubiana, J., Cocco, S., and Monasson, R. (2019). Learning protein constitutive motifs from sequence data. *eLife*, 8:e39397.
[Tuerk and Gold, 1990] Tuerk, C. and Gold, L. (1990). Systematic Evolution of Ligands by Exponential Enrichment: RNA Ligands to Bacteriophage T4 DNA Polymerase. *Science*, 249(4968):505-510.

[Valkiers et al., 2021] Valkiers, S., Van Houcke, M., Laukens, K., and Meysman, P. (2021). ClusTCR: A python interface for rapid clustering of large sets of CDR3 sequences with unknown antigen specificity. *Bioinformatics*, 37(24):4865-4867.

[van der Plas et al., 2022] van der Plas, T. L., Tubiana, J., Goc, G. L., Migault, G., Kunst, M., Baier, H., Bormuth, V., Englitz, B., and Debrégeas, G. (2022). Neural assemblies uncovered by generative modeling explain whole-brain activity statistics and reflect structural connectivity.

[Vita et al., 2019] Vita, R., Mahajan, S., Overton, J. A., Dhanda, S. K., Martini, S., Cantrell, J. R., Wheeler, D. K., Sette, A., and Peters, B. (2019). The Immune Epitope Database (IEDB): 2018 update. *Nucleic Acids Research*, 47(D1):D339–D343.

[Weber et al., 2021] Weber, A., Born, J., and Rodriguez Martínez, M. (2021). TITAN: T-cell receptor specificity prediction with bimodal attention networks. *Bioinformatics*, 37(Supplement_1):i237-i244.

[Wells et al., 2020] Wells, D. K., van Buuren, M. M., Dang, K. K., Hubbard-Lucey, V. M., Sheehan, K. C. F., Campbell, K. M., Lamb, A., Ward, J. P., Sidney, J., Blazquez, A. B., Rech, A. J., Zaretsky, J. M., Comin-Anduix, B., Ng, A. H. C., Chour, W., Yu, T. V., Rizvi, H., Chen, J. M., Manning, P., Steiner, G. M., Doan, X. C., Khan, A. A., Lugade, A., Lazic, A. M. M., Frentzen, A. A. E., Tadmor, A. D., Sasson, A. S., Rao, A. A., Pei, B., Schrörs, B., Berent-Maoz, B., Carreno, B. M., Song, B., Peters, B., Li, B., Higgs, B. W., Stevenson, B. J., Iseli, C., Miller, C. A., Morehouse, C. A., Melief, C. J. M., Puig-Saus, C., van Beek, D., Balli, D., Gfeller, D., Haussler, D., Jäger, D., Cortes, E., Esaulova, E., Sherafat, E., Arcila, F., Bartha, G., Liu, G., Coukos, G., Richard, G., Chang, H., Si, H., Zörnig, I., Xenarios, I., Mandoiu, I., Kooi, I., Conway, J. P., Kessler, J. H., Greenbaum, J. A., Perera, J. F., Harris, J., Hundal, J., Shelton, J. M., Wang, J., Wang, J., Greshock, J., Blake, J., Szustakowski, J., Kodysh, J., Forman, J., Wei, L., Lee, L. J., Fanchi, L. F., Slagter, M., Lang, M., Mueller, M., Lower, M., Vormehr, M., Artyomov, M. N., Kuziora, M., Princiotta, M., Bassani-Sternberg, M., Macabali, M., Kojicic, M. R., Yang, N., Raicevic, N. M. I., Guex, N., Robine, N., Halama, N., Skundric, N. M., Milicevic, O. S., Gellert, P., Jongeneel, P., Charoentong, P., Srivastava, P. K., Tanden, P., Shah, P., Hu, Q., Gupta, R., Chen, R., Petit, R., Ziman, R., Hilker, R., Shukla, S. A., Al Seesi, S., Boyle, S. M., Qiu, S., Sarkizova, S., Salama, S., Liu, S., Wu, S., Sridhar, S., Ketelaars, S. L. C., Jhunjhunwala, S., Shcheglova, T., Schuepbach, T., Creasy, T. H., Josipovic, V., Kovacevic, V. B., Fu, W., Krebber, W.-J., Hsu, Y.-H., Sebastian, Y., Yalcin, Z. K., Huang, Z., Merghoub, T., Guinney, J., Kolom, A., Selinsky, C., Ribas, A., Hellmann, M. D., Hacohen, N., Sette, A., Heath, J. R., Bhardwaj, N., Ramsdell, F., Schreiber, R. D., Schumacher, T. N., Kvistborg, P., and Defranoux, N. A. (2020). Key Parameters of Tumor Epitope Immunogenicity Revealed Through a Consortium Approach Improve Neoantigen Prediction. *Cell*, 183(3):818-834.e13.

[Yates, 2014] Yates, A. (2014). Theories and Quantification of Thymic Selection. *Frontiers in Immunology*, 5.

[Zhang et al., 2021] Zhang, W., Hawkins, P. G., He, J., Gupta, N. T., Liu, J., Choonoo, G., Jeong, S. W., Chen, C. R., Dhanik, A., Dillon, M., Deering, R., Macdonald, L. E., Thurston, G., and Atwal, G. S. (2021). A framework for highly multiplexed dextramer mapping and prediction of T cell receptor sequences to antigen specificity. *Science Advances*, 7(20):eabf5835.
[Tuerk and Gold, 1990] Tuerk, C. and Gold, L. (1990). Systematic Evolution of Ligands by Exponential Enrichment: RNA Ligands to Bacteriophage T4 DNA Polymerase. *Science*, 249(4968):505-510.

[Valkiers et al., 2021] Valkiers, S., Van Houcke, M., Laukens, K., and Meysman, P. (2021). ClusTCR: A python interface for rapid clustering of large sets of CDR3 sequences with unknown antigen specificity. *Bioinformatics*, 37(24):4865-4867.

[van der Plas et al., 2022] van der Plas, T. L., Tubiana, J., Goc, G. L., Migault, G., Kunst, M., Baier, H., Bormuth, V., Englitz, B., and Debrégeas, G. (2022). Neural assemblies uncovered by generative modeling explain whole-brain activity statistics and reflect structural connectivity.

[Vita et al., 2019] Vita, R., Mahajan, S., Overton, J. A., Dhanda, S. K., Martini, S., Cantrell, J. R., Wheeler, D. K., Sette, A., and Peters, B. (2019). The Immune Epitope Database (IEDB): 2018 update. *Nucleic Acids Research*, 47(D1):D339–D343.

[Weber et al., 2021] Weber, A., Born, J., and Rodriguez Martínez, M. (2021). TITAN: T-cell receptor specificity prediction with bimodal attention networks. *Bioinformatics*, 37(Supplement_1):i237-i244.

[Wells et al., 2020] Wells, D. K., van Buuren, M. M., Dang, K. K., Hubbard-Lucey, V. M., Sheehan, K. C. F., Campbell, K. M., Lamb, A., Ward, J. P., Sidney, J., Blazquez, A. B., Rech, A. J., Zaretsky, J. M., Comin-Anduix, B., Ng, A. H. C., Chour, W., Yu, T. V., Rizvi, H., Chen, J. M., Manning, P., Steiner, G. M., Doan, X. C., Khan, A. A., Lugade, A., Lazic, A. M. M., Frentzen, A. A. E., Tadmor, A. D., Sasson, A. S., Rao, A. A., Pei, B., Schrörs, B., Berent-Maoz, B., Carreno, B. M., Song, B., Peters, B., Li, B., Higgs, B. W., Stevenson, B. J., Iseli, C., Miller, C. A., Morehouse, C. A., Melief, C. J. M., Puig-Saus, C., van Beek, D., Balli, D., Gfeller, D., Haussler, D., Jäger, D., Cortes, E., Esaulova, E., Sherafat, E., Arcila, F., Bartha, G., Liu, G., Coukos, G., Richard, G., Chang, H., Si, H., Zörnig, I., Xenarios, I., Mandoiu, I., Kooi, I., Conway, J. P., Kessler, J. H., Greenbaum, J. A., Perera, J. F., Harris, J., Hundal, J., Shelton, J. M., Wang, J., Wang, J., Greshock, J., Blake, J., Szustakowski, J., Kodysh, J., Forman, J., Wei, L., Lee, L. J., Fanchi, L. F., Slagter, M., Lang, M., Mueller, M., Lower, M., Vormehr, M., Artyomov, M. N., Kuziora, M., Princiotta, M., Bassani-Sternberg, M., Macabali, M., Kojicic, M. R., Yang, N., Raicevic, N. M. I., Guex, N., Robine, N., Halama, N., Skundric, N. M., Milicevic, O. S., Gellert, P., Jongeneel, P., Charoentong, P., Srivastava, P. K., Tanden, P., Shah, P., Hu, Q., Gupta, R., Chen, R., Petit, R., Ziman, R., Hilker, R., Shukla, S. A., Al Seesi, S., Boyle, S. M., Qiu, S., Sarkizova, S., Salama, S., Liu, S., Wu, S., Sridhar, S., Ketelaars, S. L. C., Jhunjhunwala, S., Shcheglova, T., Schuepbach, T., Creasy, T. H., Josipovic, V., Kovacevic, V. B., Fu, W., Krebber, W.-J., Hsu, Y.-H., Sebastian, Y., Yalcin, Z. K., Huang, Z., Merghoub, T., Guinney, J., Kolom, A., Selinsky, C., Ribas, A., Hellmann, M. D., Hacohen, N., Sette, A., Heath, J. R., Bhardwaj, N., Ramsdell, F., Schreiber, R. D., Schumacher, T. N., Kvistborg, P., and Defranoux, N. A. (2020). Key Parameters of Tumor Epitope Immunogenicity Revealed Through a Consortium Approach Improve Neoantigen Prediction. *Cell*, 183(3):818-834.e13.

[Yates, 2014] Yates, A. (2014). Theories and Quantification of Thymic Selection. *Frontiers in Immunology*, 5.

[Zhang et al., 2021] Zhang, W., Hawkins, P. G., He, J., Gupta, N. T., Liu, J., Choonoo, G., Jeong, S. W., Chen, C. R., Dhanik, A., Dillon, M., Deering, R., Macdonald, L. E., Thurston, G., and Atwal, G. S. (2021). A framework for highly multiplexed dextramer mapping and prediction of T cell receptor sequences to antigen specificity. *Science Advances*, 7(20):eabf5835.
Supporting Information

Learning the differences: a transfer-learning approach to
predict antigen immunogenicity and T-cell receptor specificity

Barbara Bravi<fnref n="1" />,<fnref n="2" />, Andrea Di Gioacchino<fnref n="2" />, Jorge Fernandez-de-Cossio-Diaz<fnref n="2" />, Aleksandra M. Walczak<fnref n="2" />, Thierry Mora<fnref n="2" />, Simona Cocco<fnref n="2" />, Rémi Monasson<fnref n="2" />

<footnote n="1">¹ Department of Mathematics, Imperial College London, London, SW7 2AZ United Kingdom</footnote>

<footnote n="2">²Laboratoire de Physique de l'Ecole Normale Supérieure, ENS, Université PSL, CNRS, Sorbonne Université, Université de Paris, F-75005 Paris, France</footnote>
Supporting Information

Learning the differences: a transfer-learning approach to
predict antigen immunogenicity and T-cell receptor specificity

Barbara Bravi<fnref n="1" />,<fnref n="2" />, Andrea Di Gioacchino<fnref n="2" />, Jorge Fernandez-de-Cossio-Diaz<fnref n="2" />, Aleksandra M. Walczak<fnref n="2" />, Thierry Mora<fnref n="2" />, Simona Cocco<fnref n="2" />, Rémi Monasson<fnref n="2" />

<footnote n="1">¹ Department of Mathematics, Imperial College London, London, SW7 2AZ United Kingdom</footnote>

<footnote n="2">²Laboratoire de Physique de l'Ecole Normale Supérieure, ENS, Université PSL, CNRS, Sorbonne Université, Université de Paris, F-75005 Paris, France</footnote>
<figure><img src="image_15.png" /><figcaption>Figure S1: **DiffRBM architecture** recapitulating the mathematical notation used in Methods. In this cartoon example, we have assumed $M^d = 2$, $M^b = 4$ and $N = 9$ (corresponding to the length of the actual sequence input in the case of peptides, see Figures 2A and S2).</figcaption></figure>

<figure><img src="image_16.png" /><figcaption>Figure S2: Schematic summary of the construction of a diffRBM model of immunogenicity.</figcaption></figure>
<figure><img src="image_13.png" /><figcaption>Figure S1: **DiffRBM architecture** recapitulating the mathematical notation used in Methods. In this cartoon example, we have assumed $M^d = 2$, $M^b = 4$ and $N = 9$ (corresponding to the length of the actual sequence input in the case of peptides, see Figures 2A and S2).</figcaption></figure>

<figure><img src="image_14.png" /><figcaption>Figure S2: Schematic summary of the construction of a diffRBM model of immunogenicity.</figcaption></figure>
<figure><img src="image_17.png" /><figcaption>Figure S3: **Hyperparametric search for the diffRBM model of immunogenicity.** A-B: The hyperparametric search for the diffRBM model of immunogenicity is performed by monitoring the value of the diffRBM units' score (equation 11) as a function of the number of differential hidden units ($N^h$) and the regularization ($\lambda_1^2$). The score values plotted are averages over 50 randomly selected partitions into a training (A) and validation set (B), see Methods. Dataset used: immunogenic peptides presented on HLA-A*02:01 ($|\mathcal{D}^s| = 1682$). The optimal combination of $N^h$ and $\lambda_1^2$ is marked by the black bold dot. C: AUC of discrimination between immunogenic and non-immunogenic in the test set (averaged over 50 random training-test set partitions) given by diffRBMs with different $N^h$ and $\lambda_1^2$ parameters. D: Control of sampling effects on the predictive power of diffRBM with the optimal parameters ($N^h = 10, \lambda_1^2 = 0.01$), its version where the differential part is linear (diffRBM lin.) and a PWM approach. Here PWM refers to the approaches described in Methods (section 5.4.2), whereby the equivalent of the differential model part is given by the ratio of the PWM learnt on selected data and the PWM learnt on the background data. Differential models are trained on a randomly drawn portion of the background dataset of size $|\mathcal{D}^s|$, for varying $|\mathcal{D}^s|$, instead of a training set of immunogenic-only sequences, and then the differential part is used to estimate the AUC of discrimination between immunogenic and non-immunogenic sequences in the test set. Differential models, as expected in this control dataset, have no power at discriminating immunogenic from non-immunogenic peptides (AUC ~ 0.5) for all values of the ratio $|\mathcal{D}^s|/|\mathcal{D}^b|$.</figcaption></figure>
<figure><img src="image_15.png" /><figcaption>Figure S3: **Hyperparametric search for the diffRBM model of immunogenicity.** A-B: The hyperparametric search for the diffRBM model of immunogenicity is performed by monitoring the value of the diffRBM units' score (equation 11) as a function of the number of differential hidden units ($N^h$) and the regularization ($\lambda_1^2$). The score values plotted are averages over 50 randomly selected partitions into a training (A) and validation set (B), see Methods. Dataset used: immunogenic peptides presented on HLA-A*02:01 ($|\mathcal{D}^s| = 1682$). The optimal combination of $N^h$ and $\lambda_1^2$ is marked by the black bold dot. C: AUC of discrimination between immunogenic and non-immunogenic in the test set (averaged over 50 random training-test set partitions) given by diffRBMs with different $N^h$ and $\lambda_1^2$ parameters. D: Control of sampling effects on the predictive power of diffRBM with the optimal parameters ($N^h = 10, \lambda_1^2 = 0.01$), its version where the differential part is linear (diffRBM lin.) and a PWM approach. Here PWM refers to the approaches described in Methods (section 5.4.2), whereby the equivalent of the differential model part is given by the ratio of the PWM learnt on selected data and the PWM learnt on the background data. Differential models are trained on a randomly drawn portion of the background dataset of size $|\mathcal{D}^s|$, for varying $|\mathcal{D}^s|$, instead of a training set of immunogenic-only sequences, and then the differential part is used to estimate the AUC of discrimination between immunogenic and non-immunogenic sequences in the test set. Differential models, as expected in this control dataset, have no power at discriminating immunogenic from non-immunogenic peptides (AUC ~ 0.5) for all values of the ratio $|\mathcal{D}^s|/|\mathcal{D}^b|$.</figcaption></figure>
<figure><img src="image_18.png" /><figcaption>Figure S4: **Prediction of peptide contact positions with the TCR.** A: The average PPV shown in Figure 2D is compared to the PPV obtained from: the single-site factors from diffRBM units with fields only ('diffRBM units (lin.)', dashed-dotted line); a prediction based on a difference of diffRBM units' scores (equation 22). The later is marked as 'diffRBM units (score diff.)' (dashed line) to distinguish it from the prediction by diffRBM single-site factors (17) (simply denoted as 'diffRBM units'). B is the same plot as A but obtained without applying the reweighting to account for peptide sequence similarity (Methods). C: Same plot as Figure 2D, where predictions are divided by HLA allele. The number of structures considered is as follows: 4 structures for HLA-B*35:01, 41 for HLA-A*02:01, and 1 for HLA-B*07:02. D: Same plot as Figure 2D varying the threshold in Å to define a contact. In all plots, the blue dotted line marks the result of predicting at random the contact positions (Methods).</figcaption></figure>
<figure><img src="image_16.png" /><figcaption>Figure S4: **Prediction of peptide contact positions with the TCR.** A: The average PPV shown in Figure 2D is compared to the PPV obtained from: the single-site factors from diffRBM units with fields only ('diffRBM units (lin.)', dashed-dotted line); a prediction based on a difference of diffRBM units' scores (equation 22). The later is marked as 'diffRBM units (score diff.)' (dashed line) to distinguish it from the prediction by diffRBM single-site factors (17) (simply denoted as 'diffRBM units'). B is the same plot as A but obtained without applying the reweighting to account for peptide sequence similarity (Methods). C: Same plot as Figure 2D, where predictions are divided by HLA allele. The number of structures considered is as follows: 4 structures for HLA-B*35:01, 41 for HLA-A*02:01, and 1 for HLA-B*07:02. D: Same plot as Figure 2D varying the threshold in Å to define a contact. In all plots, the blue dotted line marks the result of predicting at random the contact positions (Methods).</figcaption></figure>
<figure><img src="image_19.png" /><figcaption>Figure S5: **Prediction of peptide contact positions with the HLA.** A: The average PPV of contact prediction shown in Figure 2B (inset) is compared to the PPV obtained from: the single-site factors from a background RBM with all parameters (bold gray line); a prediction based on a difference of background RBM log-likelihoods ('background RBM (score diff.)', dashed line). B is the same plot as A but obtained without applying the reweighting to account for peptide sequence similarity (Methods). C: Same plot as Figure 2B (inset) where the prediction is shown separately for each HLA (4 structures for HLA-B*35:01, 41 for HLA-A*02:01, and 1 for HLA-B*07:02). D: Same plot as Figure 2B (inset) varying the threshold in Å to define a contact. In all plots, the blue dotted line marks the result of predicting at random the contact positions (Methods).</figcaption></figure>
<figure><img src="image_17.png" /><figcaption>Figure S5: **Prediction of peptide contact positions with the HLA.** A: The average PPV of contact prediction shown in Figure 2B (inset) is compared to the PPV obtained from: the single-site factors from a background RBM with all parameters (bold gray line); a prediction based on a difference of background RBM log-likelihoods ('background RBM (score diff.)', dashed line). B is the same plot as A but obtained without applying the reweighting to account for peptide sequence similarity (Methods). C: Same plot as Figure 2B (inset) where the prediction is shown separately for each HLA (4 structures for HLA-B*35:01, 41 for HLA-A*02:01, and 1 for HLA-B*07:02). D: Same plot as Figure 2B (inset) varying the threshold in Å to define a contact. In all plots, the blue dotted line marks the result of predicting at random the contact positions (Methods).</figcaption></figure>
<figure><img src="image_20.png" /><figcaption>B</figcaption></figure>

<figure><img src="image_21.png" /></figure>

Figure S6: **Prediction of immunogenicity-related residues and mutation costs.** A: Same as Figure 3B for all the key residues: W at position 5 (39 sequences) and position 6 (20 sequences), F at position 5 (104 sequences) and position 7 (107 sequences); M at position 5 (33 sequences); Y at position 8 (90 sequences). B: Experimental *vs* predicted mutation costs of non-lethal mutations (like in Figure 3G) for all 3 TCRs analyzed in [Luksza et al., 2022], showing the predictions both by background RBM and the diffRBM units. The Spearman correlation coefficient *r* for the predictions by background RBM is significant across the 3 TCRs (p-value ≤ 10⁻⁶).
<figure><img src="image_18.png" /><figcaption>B</figcaption></figure>

<figure><img src="image_19.png" /></figure>

**Figure S6: Prediction of immunogenicity-related residues and mutation costs.** A: Same as Figure 3B for all the key residues: W at position 5 (39 sequences) and position 6 (20 sequences), F at position 5 (104 sequences) and position 7 (107 sequences); M at position 5 (33 sequences); Y at position 8 (90 sequences). B: Experimental *vs* predicted mutation costs of non-lethal mutations (like in Figure 3G) for all 3 TCRs analyzed in [Luksza et al., 2022], showing the predictions both by background RBM and the diffRBM units. The Spearman correlation coefficient *r* for the predictions by background RBM is significant across the 3 TCRs (p-value ≤ 10⁻⁶).
Performance at discriminating immunogenic vs non-immunogenic

<figure><img src="image_22.png" /></figure>

<figure><img src="image_23.png" /></figure>

<figure><img src="image_24.png" /></figure>

Figure S7: Comparison of performance of differential models of immunogenicity. Comparison of performance, in terms of the AUC of immunogenic vs non-immunogenic discrimination, between diffRBM, its version where the differential part is linear (diffRBM lin.) and a PWM approach. Here PWM refers to the approaches described in Methods (section 5.4.2), where the ‘Full model’ is given by the PWM learnt on the selected data (immunogenic peptides) while the ‘Differential part’ corresponds to the ratio of the PWM learnt on selected data and the PWM learnt on the background data. AUCs are averages over 50 training-test partitions and error bars give the corresponding standard deviation (Methods).
Performance at discriminating immunogenic vs non-immunogenic

<figure><img src="image_20.png" /><figcaption>Figure S7: Comparison of performance of differential models of immunogenicity. Comparison of performance, in terms of the AUC of immunogenic vs non-immunogenic discrimination, between diffRBM, its version where the differential part is linear (diffRBM lin.) and a PWM approach. Here PWM refers to the approaches described in Methods (section 5.4.2), where the ‘Full model’ is given by the PWM learnt on the selected data (immunogenic peptides) while the ‘Differential part’ corresponds to the ratio of the PWM learnt on selected data and the PWM learnt on the background data. AUCs are averages over 50 training-test partitions and error bars give the corresponding standard deviation (Methods).</figcaption></figure>
<figure><img src="image_25.png" /><figcaption>Figure S8: Score comparison between immunogenic peptides and peptides from the human proteome. We have drawn at random 10⁵ peptides from all the possible 9-mers in the human proteome and we have assigned to them scores under the HLA-specific models listed in the legend. We have measured via the AUC the extent to which scores assigned by these models to HLA-specific immunogenic peptides are higher than the ones assigned either to all the 10⁵ human proteome peptides (A) or only to the ones among them predicted to be presented on the corresponding HLA by NetMHCpan4.1 (B). AUCs are averages over 50 training-test partitions and error bars give the corresponding standard deviation (Methods).</figcaption></figure>

<figure><img src="image_26.png" /><figcaption>Figure S9: Leave-one-organism-out cross-validation for HLA-A\*02:01-specific model (Methods). The case of *Trypanosoma cruzi* visibly constitutes an outlier, whereby the binding affinity to the HLA alone discriminates accurately immunogenic and non immunogenic antigens (AUC=0.85). This result is confirmed by scoring the peptides via NetMHCpan4.1 (AUC=0.85). Excluding this case, the average diffRBM units AUC=0.68, which is comparable to the AUC obtained via standard validation (average AUC=0.66, Figure 4B).</figcaption></figure>
A

<figure><img src="image_21.png" /></figure>

B

<figure><img src="image_22.png" /></figure>

Figure S8: Score comparison between immunogenic peptides and peptides from the human proteome. We have drawn at random 10⁵ peptides from all the possible 9-mers in the human proteome and we have assigned to them scores under the HLA-specific models listed in the legend. We have measured via the AUC the extent to which scores assigned by these models to HLA-specific immunogenic peptides are higher than the ones assigned either to all the 10⁵ human proteome peptides (A) or only to the ones among them predicted to be presented on the corresponding HLA by NetMHCpan4.1 (B). AUCs are averages over 50 training-test partitions and error bars give the corresponding standard deviation (Methods).

<figure><img src="image_23.png" /></figure>

Figure S9: Leave-one-organism-out cross-validation for HLA-A\*02:01-specific model (Methods). The case of *Trypanosoma cruzi* visibly constitutes an outlier, whereby the binding affinity to the HLA alone discriminates accurately immunogenic and non immunogenic antigens (AUC=0.85). This result is confirmed by scoring the peptides via NetMHCpan4.1 (AUC=0.85). Excluding this case, the average diffRBM units AUC=0.68, which is comparable to the AUC obtained via standard validation (average AUC=0.66, Figure 4B).
Performance at discriminating immunogenic vs non-immunogenic

<figure><img src="image_27.png" /></figure>

Figure S10: Further comparison of diffRBM and RBM scores. Upper row: the AUC of classification of immunogenic *vs* non-immunogenic peptides given by the full RBM (trained in part on the background dataset and in part on the selected data and indicated as 'RBM (differential)') is essentially the same as the one of an RBM with the same hyperparameters trained only on selected data (denoted as 'RBM (non-differential)'). The comparison is made separately for each HLA. In these scatter plots every point gives the AUC of discrimination of the two models compared for one of the 50 random partitions into training and test sets of the corresponding HLA-specific dataset (Methods). Bottom row: we consider the AUC of immunogenic *vs* non-immunogenic classification obtained through the difference of scores between the diffRBM units trained on immunogenic peptides and the ones trained on non-immunogenic peptides. The scatter plots show that such performance (on the *y*-axis), as it should, is equivalent to the one attained by the difference of the full RBM log-likelihoods (*x*-axis).
Performance at discriminating immunogenic vs non-immunogenic

<figure><img src="image_24.png" /></figure>

Figure S10: Further comparison of diffRBM and RBM scores. Upper row: the AUC of classification of immunogenic *vs* non-immunogenic peptides given by the full RBM (trained in part on the background dataset and in part on the selected data and indicated as 'RBM (differential)') is essentially the same as the one of an RBM with the same hyperparameters trained only on selected data (denoted as 'RBM (non-differential)'). The comparison is made separately for each HLA. In these scatter plots every point gives the AUC of discrimination of the two models compared for one of the 50 random partitions into training and test sets of the corresponding HLA-specific dataset (Methods). Bottom row: we consider the AUC of immunogenic *vs* non-immunogenic classification obtained through the difference of scores between the diffRBM units trained on immunogenic peptides and the ones trained on non-immunogenic peptides. The scatter plots show that such performance (on the *y*-axis), as it should, is equivalent to the one attained by the difference of the full RBM log-likelihoods (*x*-axis).
<figure><img src="image_28.png" /><figcaption>Figure S11: **Hyperparametric search for the classifier of immunogenicity.** The hyperparametric search for the classifier is based on the optimal performance on the validation dataset at discriminating immunogenic vs non-immunogenic peptides as measured by the AUC. We show the mean AUC over 50 random partitions into training set (A) and validation set (B). The labels on the x-axis denote different classifier architectures, which are described in Table S2.</figcaption></figure>

<table><caption>Table S2: **Tested architectures for the classifier of immunogenicity.** All classifiers alternate dense linear layers with LeakyReLU [Maas et al., 2013] activation functions. The models differ in the number of layers (column *Depth*) and the width of intermediate layers (column *Intermediate widths*). The first layer is always of input size 180 = 21 × 9, and corresponds to one-hot encoded sequences of length 9 with 20 amino-acid + 1 gap letters. The last layer always has an output of size 1 giving the predicted log-odds that the input sequence is immunogenic. Model C1 has no intermediate layers and corresponds to the linear classifier whose results are shown in Figure 4.</caption><thead><tr><th>Id.</th><th>Depth</th><th>Input</th><th>Intermediate widths</th><th>Output</th></tr></thead><tbody><tr><td>C1</td><td>2</td><td>180</td><td>-</td><td>1</td></tr><tr><td>C2</td><td>3</td><td>180</td><td>2</td><td>1</td></tr><tr><td>C3</td><td>3</td><td>180</td><td>4</td><td>1</td></tr><tr><td>C4</td><td>3</td><td>180</td><td>8</td><td>1</td></tr><tr><td>C5</td><td>3</td><td>180</td><td>16</td><td>1</td></tr><tr><td>C6</td><td>3</td><td>180</td><td>32</td><td>1</td></tr><tr><td>C7</td><td>3</td><td>180</td><td>64</td><td>1</td></tr><tr><td>C8</td><td>3</td><td>180</td><td>128</td><td>1</td></tr><tr><td>C9</td><td>4</td><td>180</td><td>16, 8</td><td>1</td></tr><tr><td>C10</td><td>4</td><td>180</td><td>32, 8</td><td>1</td></tr><tr><td>C11</td><td>4</td><td>180</td><td>64, 8</td><td>1</td></tr><tr><td>C12</td><td>4</td><td>180</td><td>128, 8</td><td>1</td></tr><tr><td>C13</td><td>4</td><td>180</td><td>32, 16</td><td>1</td></tr><tr><td>C14</td><td>4</td><td>180</td><td>64, 16</td><td>1</td></tr><tr><td>C15</td><td>4</td><td>180</td><td>128, 16</td><td>1</td></tr><tr><td>C16</td><td>5</td><td>180</td><td>32, 16, 8</td><td>1</td></tr><tr><td>C17</td><td>5</td><td>180</td><td>64, 16, 8</td><td>1</td></tr><tr><td>C18</td><td>5</td><td>180</td><td>64, 32, 16</td><td>1</td></tr><tr><td>C19</td><td>5</td><td>180</td><td>128, 32, 16</td><td>1</td></tr><tr><td>C20</td><td>5</td><td>180</td><td>128, 64, 16</td><td>1</td></tr><tr><td>C21</td><td>5</td><td>180</td><td>128, 64, 32</td><td>1</td></tr><tr><td>C22</td><td>6</td><td>180</td><td>128, 64, 32, 8</td><td>1</td></tr><tr><td>C23</td><td>6</td><td>180</td><td>128, 64, 32, 16</td><td>1</td></tr></tbody></table>
<figure><img src="image_25.png" /><figcaption>Figure S11: **Hyperparametric search for the classifier of immunogenicity.** The hyperparametric search for the classifier is based on the optimal performance on the validation dataset at discriminating immunogenic vs non-immunogenic peptides as measured by the AUC. We show the mean AUC over 50 random partitions into training set (A) and validation set (B). The labels on the x-axis denote different classifier architectures, which are described in Table S2.</figcaption></figure>

<table><caption>Table S2: **Tested architectures for the classifier of immunogenicity.** All classifiers alternate dense linear layers with LeakyReLU [Maas et al., 2013] activation functions. The models differ in the number of layers (column *Depth*) and the width of intermediate layers (column *Intermediate widths*). The first layer is always of input size 180 = 21 × 9, and corresponds to one-hot encoded sequences of length 9 with 20 amino-acid + 1 gap letters. The last layer always has an output of size 1 giving the predicted log-odds that the input sequence is immunogenic. Model C1 has no intermediate layers and corresponds to the linear classifier whose results are shown in Figure 4.</caption><thead><tr><th>Id.</th><th>Depth</th><th>Input</th><th>Intermediate widths</th><th>Output</th></tr></thead><tbody><tr><td>C1</td><td>2</td><td>180</td><td>-</td><td>1</td></tr><tr><td>C2</td><td>3</td><td>180</td><td>2</td><td>1</td></tr><tr><td>C3</td><td>3</td><td>180</td><td>4</td><td>1</td></tr><tr><td>C4</td><td>3</td><td>180</td><td>8</td><td>1</td></tr><tr><td>C5</td><td>3</td><td>180</td><td>16</td><td>1</td></tr><tr><td>C6</td><td>3</td><td>180</td><td>32</td><td>1</td></tr><tr><td>C7</td><td>3</td><td>180</td><td>64</td><td>1</td></tr><tr><td>C8</td><td>3</td><td>180</td><td>128</td><td>1</td></tr><tr><td>C9</td><td>4</td><td>180</td><td>16, 8</td><td>1</td></tr><tr><td>C10</td><td>4</td><td>180</td><td>32, 8</td><td>1</td></tr><tr><td>C11</td><td>4</td><td>180</td><td>64, 8</td><td>1</td></tr><tr><td>C12</td><td>4</td><td>180</td><td>128, 8</td><td>1</td></tr><tr><td>C13</td><td>4</td><td>180</td><td>32, 16</td><td>1</td></tr><tr><td>C14</td><td>4</td><td>180</td><td>64, 16</td><td>1</td></tr><tr><td>C15</td><td>4</td><td>180</td><td>128, 16</td><td>1</td></tr><tr><td>C16</td><td>5</td><td>180</td><td>32, 16, 8</td><td>1</td></tr><tr><td>C17</td><td>5</td><td>180</td><td>64, 16, 8</td><td>1</td></tr><tr><td>C18</td><td>5</td><td>180</td><td>64, 32, 16</td><td>1</td></tr><tr><td>C19</td><td>5</td><td>180</td><td>128, 32, 16</td><td>1</td></tr><tr><td>C20</td><td>5</td><td>180</td><td>128, 64, 16</td><td>1</td></tr><tr><td>C21</td><td>5</td><td>180</td><td>128, 64, 32</td><td>1</td></tr><tr><td>C22</td><td>6</td><td>180</td><td>128, 64, 32, 8</td><td>1</td></tr><tr><td>C23</td><td>6</td><td>180</td><td>128, 64, 32, 16</td><td>1</td></tr></tbody></table>
<figure><img src="image_29.png" /></figure>

<figure><img src="image_30.png" /><figcaption>Figure S12: Performance of differential models of immunogenicity with sample reweighting.
Performance at discriminating immunogenic *vs* non-immunogenic peptides (like in Figure 4) where a reweighting scheme based on sequence similarity is applied during training (Methods).</figcaption></figure>

<figure><img src="image_31.png" /><figcaption>Figure S13: Schematic summary of the construction of a diffRBM model of TCR epitope-specificity.</figcaption></figure>
<figure><img src="image_26.png" /></figure>

<figure><img src="image_27.png" /><figcaption>Figure S12: Performance of differential models of immunogenicity with sample reweighting.
Performance at discriminating immunogenic *vs* non-immunogenic peptides (like in Figure 4) where a reweighting scheme based on sequence similarity is applied during training (Methods).</figcaption></figure>

<figure><img src="image_28.png" /><figcaption>Figure S13: Schematic summary of the construction of a diffRBM model of TCR epitope-specificity.</figcaption></figure>
A

<figure><img src="image_32.png" /></figure>

B

<figure><img src="image_33.png" /></figure>

C

<figure><img src="image_34.png" /></figure>

D

<figure><img src="image_35.png" /></figure>

E

<figure><img src="image_36.png" /></figure>

F

<figure><img src="image_37.png" /></figure>

Figure S14: Hyperparametric search for the diffRBM model of TCR specificity. A-B: Hyperparametric search for the background RBM model using the dataset from [Emerson et al., 2017] (Methods). The black bold dot in A-B and C-E marks the combination of $N^h$ and $\lambda_1^2$ chosen, respectively, for background RBM ($N^h = 100, \lambda_1^2 = 0.001$) and diffRBM units ($N^h = 20, \lambda_1^2 = 0.01$). The hyperparametric search for diffRBM is performed in the same way as for the immunogenicity model (Figure S3A-B). The diffRBM units' scores plotted are averages over 50 random partitions into a training (C) and validation set (D), see Methods. Dataset used: set of sequences specific to the CMV peptide NLVPMVAT ($|D^s| = 4548$). E: AUC of discrimination between epitope-specific and generic sequences in the test set (averaged over 50 random training-test set partitions) varying $N^h$ and $\lambda_1^2$. F: As a control, differential models are trained on a randomly drawn portion of the background dataset of size $|D^s|$, for varying $|D^s|$, instead of a training set of epitope-specific sequences, and then their differential part is used to estimate the AUC of discrimination between epitope-specific and generic sequences in the test set, see the caption of Figure S3D.
A

<figure><img src="image_29.png" /></figure>

B

<figure><img src="image_30.png" /></figure>

C

<figure><img src="image_31.png" /></figure>

D

<figure><img src="image_32.png" /></figure>

E

<figure><img src="image_33.png" /></figure>

F

<figure><img src="image_34.png" /></figure>

Figure S14: Hyperparametric search for the diffRBM model of TCR specificity. A-B: Hyperparametric search for the background RBM model using the dataset from [Emerson et al., 2017] (Methods). The black bold dot in A-B and C-E marks the combination of $N^h$ and $\lambda_1^2$ chosen, respectively, for background RBM ($N^h = 100, \lambda_1^2 = 0.001$) and diffRBM units ($N^h = 20, \lambda_1^2 = 0.01$). The hyperparametric search for diffRBM is performed in the same way as for the immunogenicity model (Figure S3A-B). The diffRBM units' scores plotted are averages over 50 random partitions into a training (C) and validation set (D), see Methods. Dataset used: set of sequences specific to the CMV peptide NLVPMVAT ($|D^s| = 4548$). E: AUC of discrimination between epitope-specific and generic sequences in the test set (averaged over 50 random training-test set partitions) varying $N^h$ and $\lambda_1^2$. F: As a control, differential models are trained on a randomly drawn portion of the background dataset of size $|D^s|$, for varying $|D^s|$, instead of a training set of epitope-specific sequences, and then their differential part is used to estimate the AUC of discrimination between epitope-specific and generic sequences in the test set, see the caption of Figure S3D.
<figure><img src="image_38.png" /><figcaption>Figure S15: **Prediction of CDR3β contact positions with the peptide.** A: Similarly to Figure S4A, the average PPV of contact prediction shown in Figure 5C is compared to the PPV by two alternative predictors, the expression (22) ('diffRBM units (score diff.)', dashed line) and the single-site factors from diffRBM units with fields only ('diffRBM units (lin.)', dashed-dotted line). B is the same plot as A but obtained without applying the reweighting to account for peptide sequence similarity (Methods). C: Same plot as Figure 5C, where predictions are divided by epitope specificity. The number of structures considered is as follows: 2 structures for YLQPRTFLL, 3 for NLVPMVATV, 1 for GLCTLVAML, and 6 for GILGFVFTL. D: Same plot as Figure 5C varying the threshold in Å to define a contact. The cutoff 5 Å is the one used in [Calis et al., 2012, Glanville et al., 2017, Ostmeyer et al., 2019, Milighetti et al., 2021]. In all plots, the blue dotted line marks the result of predicting at random the contact positions (Methods).</figcaption></figure>
<figure><img src="image_35.png" /><figcaption>Figure S15: **Prediction of CDR3β contact positions with the peptide.** A: Similarly to Figure S4A, the average PPV of contact prediction shown in Figure 5C is compared to the PPV by two alternative predictors, the expression (22) ('diffRBM units (score diff.)', dashed line) and the single-site factors from diffRBM units with fields only ('diffRBM units (lin.)', dashed-dotted line). B is the same plot as A but obtained without applying the reweighting to account for peptide sequence similarity (Methods). C: Same plot as Figure 5C, where predictions are divided by epitope specificity. The number of structures considered is as follows: 2 structures for YLQPRTFLL, 3 for NLVPMVATV, 1 for GLCTLVAML, and 6 for GILGFVFTL. D: Same plot as Figure 5C varying the threshold in Å to define a contact. The cutoff 5 Å is the one used in [Calis et al., 2012, Glanville et al., 2017, Ostmeyer et al., 2019, Milighetti et al., 2021]. In all plots, the blue dotted line marks the result of predicting at random the contact positions (Methods).</figcaption></figure>
Performance at discriminating specific vs bulk CDR3β

<figure><img src="image_39.png" /><figcaption>Figure S16: Comparison of performance of differential models of TCR specificity. Comparison of performance, in terms of the AUC of epitope-specific *vs* bulk sequences discrimination, between diffRBM, its version where the differential part is linear (diffRBM lin.) and a PWM approach, see caption of Figure S7.</figcaption></figure>
Performance at discriminating specific vs bulk CDR3β

<figure><img src="image_36.png" /><figcaption>Figure S16: Comparison of performance of differential models of TCR specificity. Comparison of performance, in terms of the AUC of epitope-specific *vs* bulk sequences discrimination, between diffRBM, its version where the differential part is linear (diffRBM lin.) and a PWM approach, see caption of Figure S7.</figcaption></figure>
Performance at discriminating specific vs bulk CDR3β (different background datasets)

<figure><img src="image_40.png" /><figcaption>Figure S17: Comparison of performance of differential models of TCR specificity with different background datasets. The plots show, for each epitope, the AUC of discrimination between the epitope-specific and naive sequences for the diffRBM units, full RBM and background RBM in the case where the background dataset is drawn from the [Dean et al., 2015] dataset, compared to the values obtained for a background dataset from [Emerson et al., 2017] (the one used in Figure 6). AUCs are averages over 50 training-test partitions and error bars give the corresponding standard deviation (Methods).</figcaption></figure>

<figure><img src="image_41.png" /><figcaption>Figure S18: Hyperparametric search of the optimal *k* for the *k*-NN algorithm. The optimal *k* (*k*=26, indicated by the black bold dot) is chosen by looking at the maximal AUC of discrimination between epitope-specific and background sequences in the validation set. For each *k*, the plot shows the average AUC over 50 independent partitions into training and validation sets (Methods). Dataset used: set of sequences specific to the CMV peptide NLVPMVATV (|D<sup>s</sup>|=4548).</figcaption></figure>
Performance at discriminating specific vs bulk CDR3β (different background datasets)

<figure><img src="image_37.png" /><figcaption>Figure S17: Comparison of performance of differential models of TCR specificity with different background datasets. The plots show, for each epitope, the AUC of discrimination between the epitope-specific and naive sequences for the diffRBM units, full RBM and background RBM in the case where the background dataset is drawn from the [Dean et al., 2015] dataset, compared to the values obtained for a background dataset from [Emerson et al., 2017] (the one used in Figure 6). AUCs are averages over 50 training-test partitions and error bars give the corresponding standard deviation (Methods).</figcaption></figure>

<figure><img src="image_38.png" /><figcaption>Figure S18: Hyperparametric search of the optimal *k* for the *k*-NN algorithm. The optimal *k* (*k*=26, indicated by the black bold dot) is chosen by looking at the maximal AUC of discrimination between epitope-specific and background sequences in the validation set. For each *k*, the plot shows the average AUC over 50 independent partitions into training and validation sets (Methods). Dataset used: set of sequences specific to the CMV peptide NLVPMVATV (|D<sup>s</sup>|=4548).</figcaption></figure>
Performance at discriminating specific vs bulk CDR3β (amino acid only)

<figure><img src="image_42.png" /><figcaption>Figure S19: Comparison of performance of models of TCR specificity without V and J type. Given that NetTCR2.0 [Montemurro et al., 2021] does not account for V and J type in its input, we report the performance of the diffRBM units, full RBM and background RBM for the 4 epitope-specific models under consideration when only the CDR3β amino acid sequence has been used to train and test the models. AUCs are averages over 50 training-test partitions and error bars give the corresponding standard deviation (Methods).</figcaption></figure>
Performance at discriminating specific vs bulk CDR3β (amino acid only)

<figure><img src="image_39.png" /><figcaption>Figure S19: Comparison of performance of models of TCR specificity without V and J type. Given that NetTCR2.0 [Montemurro et al., 2021] does not account for V and J type in its input, we report the performance of the diffRBM units, full RBM and background RBM for the 4 epitope-specific models under consideration when only the CDR3β amino acid sequence has been used to train and test the models. AUCs are averages over 50 training-test partitions and error bars give the corresponding standard deviation (Methods).</figcaption></figure>
A

<figure><img src="image_43.png" /></figure>

B

<figure><img src="image_44.png" /></figure>

C

<figure><img src="image_45.png" /></figure>

D

<table><thead><tr><td>Data</td><td>Fraction</td></tr></thead><tbody><tr><td>HLA-A*02:01</td><td>0.30 ± 0.18</td></tr><tr><td>HLA-B*07:02</td><td>0.14 ± 0.20</td></tr><tr><td>HLA-B*35:01</td><td>0.05 ± 0.09</td></tr><tr><td>GILGFVFTL</td><td>0.19 ± 0.07</td></tr><tr><td>NLVPMVATV</td><td>0.94 ± 0.35</td></tr><tr><td>GLCTLVAML</td><td>0.14 ± 0.11</td></tr><tr><td>YLQPRTFLL</td><td>0.00020 ± 0.00017</td></tr></tbody></table>

**Figure S20: Model-based entropy estimation.** A: Entropy *S* (expressed in nats, see Methods) of the space of HLA-specific presented antigens (evaluated by background RBM) and of HLA-specific immunogenic antigens (evaluated by the full RBM) for the 3 HLAs. Error bars represent the uncertainty on the estimated entropy coming from limited sampling and was calculated as in [Marchi et al., 2019]. B: The entropy of the background dataset (CDR3β bulk repertoire) obtained from background RBM is compared to the entropy of epitope-specific CDR3β obtained from the full RBM models of TCR specificity to GILGFVFTL, NLVPMVATV, GLCTLVAML and YLQPRTFLL. C: The entropies calculated from background RBM and the full RBM plotted in A and B is lower than the one estimated from independent-site models of the same data (Entropy PWM), because RBM models can account for correlations between sequence sites, hence for additional constraints on sequence diversity. Colors are the same as in A, B.

**D: Reduction in diversity in selected data.** For each type of data, given the entropy *S*, $exp(S)$ gives an estimate of the effective size of the corresponding sequence space, hence the ratio $exp(S^{RBM})/exp(S^{Background})$ gives an estimate of the effective fraction of sequences retained in selected data compared to background ones. The table shows that the reduction in diversity quantified by this fraction is typically less than one order of magnitude, with the exception of the YLQPRTFLL-specific CDR3β repertoire. However, the uncertainty from sampling is substantial (especially for the smallest datasets HLA-B*07:02, HLA-B*35:01 and YLQPRTFLL), and prevents us from estimating the reduction in diversity with high accuracy. The first 3 rows refer to the HLA-specific models of immunogenicity (entropy values plotted in A) while the last 4 rows refer to the epitope-specific models of TCR specificity (entropy values in B).
A

<figure><img src="image_40.png" /></figure>

B

<figure><img src="image_41.png" /></figure>

C

<figure><img src="image_42.png" /></figure>

D

<table><thead><tr><td>Data</td><td>Fraction</td></tr></thead><tbody><tr><td>HLA-A*02:01</td><td>0.30 ± 0.18</td></tr><tr><td>HLA-B*07:02</td><td>0.14 ± 0.20</td></tr><tr><td>HLA-B*35:01</td><td>0.05 ± 0.09</td></tr><tr><td>GILGFVFTL</td><td>0.19 ± 0.07</td></tr><tr><td>NLVPMVATV</td><td>0.94 ± 0.35</td></tr><tr><td>GLCTLVAML</td><td>0.14 ± 0.11</td></tr><tr><td>YLQPRTFLL</td><td>0.00020 ± 0.00017</td></tr></tbody></table>

**Figure S20: Model-based entropy estimation.** A: Entropy *S* (expressed in nats, see Methods) of the space of HLA-specific presented antigens (evaluated by background RBM) and of HLA-specific immunogenic antigens (evaluated by the full RBM) for the 3 HLAs. Error bars represent the uncertainty on the estimated entropy coming from limited sampling and was calculated as in [Marchi et al., 2019]. B: The entropy of the background dataset (CDR3β bulk repertoire) obtained from background RBM is compared to the entropy of epitope-specific CDR3β obtained from the full RBM models of TCR specificity to GILGFVFTL, NLVPMVATV, GLCTLVAML and YLQPRTFLL. C: The entropies calculated from background RBM and the full RBM plotted in A and B is lower than the one estimated from independent-site models of the same data (Entropy PWM), because RBM models can account for correlations between sequence sites, hence for additional constraints on sequence diversity. Colors are the same as in A, B.

**D: Reduction in diversity in selected data.** For each type of data, given the entropy *S*, exp(*S*) gives an estimate of the effective size of the corresponding sequence space, hence the ratio exp(*S*<sup>RBM</sup>)/exp(*S*<sup>Background</sup>) gives an estimate of the effective fraction of sequences retained in selected data compared to background ones. The table shows that the reduction in diversity quantified by this fraction is typically less than one order of magnitude, with the exception of the YLQPRTFLL-specific CDR3β repertoire. However, the uncertainty from sampling is substantial (especially for the smallest datasets HLA-B*07:02, HLA-B*35:01 and YLQPRTFLL), and prevents us from estimating the reduction in diversity with high accuracy. The first 3 rows refer to the HLA-specific models of immunogenicity (entropy values plotted in A) while the last 4 rows refer to the epitope-specific models of TCR specificity (entropy values in B).