Abstract
T cells are crucial in the immune response to cancer, with their antigen specificity largely determined by T cell receptors (TCRs). The similarity in TCR sequences often reflects shared antigen specificity and functional roles, providing a basis for computational prediction of cancer from repertoire data. Although machine learning models have shown promise in this area, achieving robust and interpretable cancer detection using TCR sequences remains a significant challenge. In this study, we present a novel graph neural network (GNN) framework that leverages TCR sequence similarity to construct individual-specific graphs, integrating graph attention mechanisms for biologically interpretable feature learning. Our approach dynamically models the relational structure within TCR repertoires, overcoming limitations of previous convolutional methods. Through systematic comparison of graph construction strategies and similarity metrics, we identified an optimal model configuration. Evaluated on cohorts of lung cancer and thyroid cancer patients alongside healthy individuals, our model demonstrated superior predictive accuracy, achieving near-perfect classification performance. These results affirm that GNNs can effectively decode the complex relationship between TCR repertoire patterns and cancer status, offering a powerful and translatable tool for cancer detection.
Keywords: T cell receptors (TCR); graph neural networks; attention mechanisms; cancer diagnostics; computational immunology
Introduction
The global burden of cancer remains substantial, with incidence rates exhibiting significant variation across different age groups, as highlighted by the 2021 cancer statistics, as shown in Figure 1. T cells of the immune system play a prominent role when a patient contracts cancer. While they are able to detect and destroy tumor antigens, T cells may also promote tumor growth by giving them a more favorable environment or causing tumor cells to be more fit for survival1. The exact interaction between T cells and pathogens greatly depends on the TCR sequences2, which makes studying TCR a practical way for understanding and predicting cancer. Research also indicated that there exist shared TCR sequences between healthy individuals or cancer patients3 and that these shared or similar sequences would signify the correspondence in antigen specificity of the T cell. It is further proven that T cells that respond to the same antigen often contain similar TCR sequences, emphasizing the importance of TCR similarity within their repertoires4. To accomplish the task of predicting disease, especially cancer, through TCR sequence, many previous studies have utilized machine learning to analyze relationships between TCR sequences.
For instance, the DeepCat method in 20205 trained a CNN model using TCR sequences grouped based on similarity. The result of the model after being used for prediction is a cancer score which could be used to classify the TCR repertoire as either associated with cancer or not. However, the DeepCat method, though being an ingenious method for cancer prediction and achieving high accuracy, did not consider the weight of distinct TCR sequences within one repertoire. Improving on this method, the DeepLion5 method assigned weight to each sequence during prediction in addition to merely using a CNN. Furthermore, DeepLion also applied kernels of different sizes throughout its CNN in order to extract TCR motifs with various lengths, eventually generating a superior result. Although both models have made advancements in the field, the usage of CNNs might not be the most beneficial way when analyzing TCR sequences. CNNs are able to capture local structural motifs through their convolution layers but are not able to excel at capturing long range interactions6. Moreover, CNNs often require fixed, grid-structured input which is not propitious when dealing with TCR sequences with biological implications7.
Building on this notion, several other models wielded Graph Neural Networks (GNNs) for their study. The HeteroTCR model8 used a heterogeneous GNN model to enhance the accuracy of TCR prediction. It constructed a graph based on the interaction between TCR sequences and peptides, or the chemical bond and physical distance between sequences, and focused specifically on the CDR3β chain. It also applied a CNN model to extract features and improve performance. A similar model LZ-TCR9 creates a GNN based on the physical and logical connections between TCR sequences while applying a Lempel-Ziv subpattern for data extraction. While these GNN-based methods better capture structural relationships, they often rely heavily on predefined physical or chemical features, which may limit their ability to learn higher-order semantic interactions directly from sequence data. Another study called MixTCRpred10 has combined both CNN and GNN into its model, where a CNN is used to extract features from the original TCR sequence and a GNN is used to represent the spatial relationship of the sequences. Although this method provides intuitive insight into cancer associated TCR prediction, it might be faced with challenges in combining the result from the two neural networks. It does not involve a specific method to balance the contributions of GNN and CNN and, by doing so, has the risk of overfitting.
As a result, despite numerous achievements already made in this field, further improvements could be made to current methodologies for predicting cancer-associated TCR sequences. We designed a method to attain this goal of enhanced prediction. Our approach involves converting the original TCR sequence data into graph representations that encode richer relational information compared to matrices used in CNN models. We constructed a graph per person with nodes representing the TCR sequences and edges representing their normalized similarity.
This paper is grounded in the established knowledge that TCR similarity influences antigen specificity and shows correlation11. By using similarity between sequences to construct graphs12, we aim to comprehensively and accurately represent the biological information behind those sequences. We then applied a graph neural network that utilizes attention mechanisms to extract important features and assign dynamic weights to different nodes and edges. We incorporated global attention pooling to aggregate features at the graph level. We assessed our model using data from patients with lung cancer and thyroid cancer together with data from healthy individuals to evaluate its performance. Overall, the hypothesis behind our study is that a GNN leveraging similarity-based graph construction could enhance cancer prediction accuracy.
Unlike a convolutional neural network working with isolated data, a GNN is capable of representing the functional relationships between TCR sequences and connecting them by their similarity. These additional edge features provide a relational inductive bias that is not present in other neural networks, constituting a key advantage for our model. Therefore, a graph representation can offer more valuable insights for a model to learn and represents a promising method for TCR-based cancer prediction.
Method
Data Source and Preprocessing
This study focused on the CDR3β chain within TCR sequences. Since this section of TCR holds a crucial function in the antigen binding process, and its sequence series could be attained relatively easily, it was a common focus of TCR related research and past studies. It offers valuable information for computational TCR analysis and is utilized as the target of this research13.Our research utilized TCR-seq data from two major sources: (1) the publicly available immuneACCESS database in Adaptive Biotechnologies (IA), and (2) the clinical database of Geneplus Technology Ltd. in Shenzhen14. The dataset comprises TCR sequences of healthy individuals and patients diagnosed with lung or thyroid cancer (THCA). Raw data was structured in a standard format, with each record containing the amino acid sequence of the CDR3β chain of the individual and an identifier for whether the individual is healthy or has cancer.
A summary of the raw data gathered is presented in table 1 while examples of a portion of sample data are shown in figure 2. From the raw data we selected a balanced subset to form the final cohort. In this process, we ensured that every individual had a representative number of sequences for graph construction.
| Cohort | Number of Subjects | Total Sequences | Source |
| Healthy Donors | 260 | 2600000 | IA & Geneplus |
| Lung Cancer (LC) | 184 | 1800000 | Geneplus |
| Thyroid Cancer (THCA) | 169 | 1700000 | Geneplus |
Past research has shown that similar CDR3β sequences in TCR commonly share antigen specificity and biological functions4,11, meaning that humans’ collective immune response is, especially in the context of cancer, correlated with functions of groups of structurally similar TCR clones with similar function. These clones are likely to identify the same type of tumor-associated antigens and therefore hold a similar function. Consequently, to study this interaction, extract trends within TCR repertoires, and associate these trends with cancer detection, we decided to use a graph neural network with graphs constructed based on similarity between TCR sequences. In order to convert the aforementioned amino acid sequences and their biological implications into a computational framework, we need to first establish a graph representation of the data. Unlike a plain set of sequences or a matrix structure used in CNNs, a graph explicitly encodes the relationships between sequences and therefore provides the most natural representation in the case of this research. In a graph structure, every node would represent a certain sequence with edges connecting the nodes, delineating the similarity between them, and being assigned various weights based on such similarity, allowing the Graph Neural Network (GNN) to propagate information between biologically related TCRs. Through this method, the model can learn the entire TCR repertoire’s topology, instead of analyzing individual sequences. For instance, the model would be able to identify dense clusters of similar sequences that may be indicative of an antigen-specific expansion. This method aligns more closely with the biological nature of the immune system and TCR sequences, which resemble a network in comparison to models that assess sequences in isolation from each other.

To ensure data quality and biological relevance, we applied rigorous filtering to the given raw TCR sequences, taking into consideration immunological principles and the process of feature engineering15. First, we retained only sequences with lengths between 10 and 24 amino acids. Applying this range would exclude sequences that are too short to provide functional antigen binding loops, while also eliminating abnormally long sequences. Long sequences are relatively rare and are typically sequencing artifacts or the result of non-functional rearrangements. Secondly, we removed sequences containing any non-canonical amino acid characters (e.g., *, X, -), as these typically indicate sequencing errors, low-quality reads, or non-productive rearrangements, and could serve as distractions when the model trains on them. Third, we discarded sequences that did not begin with a conserved cysteine (‘C’) and end with a conserved phenylalanine (‘F’), following standards of ImMunoGeneTics (IMGT) nomenclature. These amino acids are crucial for the formation of the disulfide bond that stabilizes the TCR CDR3 loop, and their absence likely suggests that the sequence is not functional. To further increase cancer specific signals in the data, we excluded 20,000 sequences that are frequently shared between patients diagnosed with cancer and healthy individuals. These sequences, which are prevalent across subjects regardless of cancer status and are referred to as public sequences, are more closely related to common infections or innate immunity than to cancer specific immune responses. Through eliminating these sequences, we hoped that our model would be more capable of identifying characteristics of sequences that are preferentially expanded in the cancer cohort. After eliminating sequences, we padded all remaining ones with “X” at the C-terminus until they all had a length of 24 amino acids. These “X” characters were encoded as zero vectors in the model’s input so that they would neither contribute meaningful biochemical information nor interfere with the model’s performance.
Since we are utilizing a graph neural network, it is neither reasonable nor possible to input raw TCR sequences in the form of letters standing for amino acids. We need to transform the sequences into graph datasets using similarity between sequences as edge features. In order to create the best model, we attempted several methods for graph construction and calculating similarity between sequences. For similarity calculation, we tested three different methods, being Levenshtein distance16, Hamming distance17, and Needleman-Wunsch Algorithm. All three methods have been widely implemented in other research regarding TCR sequences for the purpose of feature extraction and in general resulted in favorable results in those studies.
Using each of the three similarity calculation methods, we constructed graph representations for TCR of each individual. For each person, a connected graph was constructed with each node corresponding to one sequence in the form of a graph and edge features weighted by pairwise similarity. Next, to construct node features, we modified amino acid sequences into fixed size numerical sequences that can be processed by a neural network. As the TCR sequences used in this study were standardized to a length of 24 amino acids through the aforementioned data preprocessing, we used the AAindex database18 to map the amino acids of the TCR sequences to biophysicochemical properties. The purpose of this transformation is to encode functional properties such as antigen-binding affinity in the sequence data. Here we used the AAindex embeddings to incorporate prior biochemical knowledge of hydrophobicity, charge, side chain volume, etc., all of which are known to influence TCR epitope interactions5.
However, because the full AAindex database contains 566 indices, many of which are strongly correlated or contain repeated and redundant information, we employed feature selection and compression in order to decrease data dimensionality and the risk of overfitting following established procedures19. First, we got rid of indices with more than 20% missing values. Then, we calculated pairwise correlations between remaining indices, retaining only one index from each pair that has a correlation factor of |r| > 0.95 with the goal of minimizing redundancy. Finally, we applied Principal Component Analysis to the remaining set, retaining the top 15 principal components which collectively explain over 95% of variance. Overall, each amino acid was represented by a 15-dimensional feature vector, and each TCR sequence constituted a 24×15 feature matrix. This form of representation with a 24×15 feature matrix would be capable of preserving important biological information while ensuring computational efficiency. As a side note, we identified and removed one incomplete THCA patient record to ensure data integrity prior to model input. A summary of the data preprocessing process could be seen in figure 3.
Graph construction
To execute our proposed method for TCR based cancer prediction, we used Python 3.8 to design our model, applying PyTorch and PyTorch Geometric to construct the neural network and using scikit-learn to assess the model. All research and experiments were conducted on a Mac computer with an M2 Pro CPU.
Graph construction is an indispensable part of this study, and the way we design the graph is of utmost importance to the performance of the model as it determines the value of the data input. In the beginning of this research, we proposed four distinct graph construction methodologies. The first method was to assemble the graph according to physical and spatial properties of TCR sequences. However, as discussed in the introduction section, relying on spatial representations of the CDR3β chain could lead to information loss. Consequently, we did not employ this method.
The second method constructed one graph per individual through similarity calculations. However, before implementing this method, we needed to normalize similarity scores. The distances computed by Levenshtein, Hamming, and Needleman-Wunsch algorithms are on different scales and therefore cannot be compared directly, nor can they be used as edge weights as they are. Therefore, we normalized the distances into similarity scores ranging from 0 to 1. For each distance metric d between two sequences, we computed the normalized similarity score through s = 1 – (d / d_max), where d_max is the maximum possible distance for the given metric. This normalization enables us to compare graph constructions based on different metrics on equal terms and to train models on graphs with edge weights on a consistent scale. We ultimately adopted this method and the specifics of graph constructions are documented in a later part of this section.
In the third method, we planned to construct one comprehensive graph containing TCR sequences from all patients and healthy individuals of our dataset. This method was abandoned due to its incompatibility with the prediction goal of our study. The purpose of our model is to generate cancer prediction scores specific to individuals, and combining sequences from multiple entities into one graph would introduce considerable redundant information, concealing person-specific signals.
In the fourth method, we explored the potential of contrastive learning, grouping sequences based on predictions of pretrained models from previous studies. We discarded this method due to several concerns while designing. First, graph construction would depend highly on the accuracy of pretrained models, which potentially induces error. Moreover, such grouping of sequences based on pretrained labels could obscure the relationships specific to one individual and disregard the similarity connections we identified to be important. As a result, we did not pursue this method.
After evaluation from a designing perspective, we employed the second method with similarity-based graph construction. This approach is capable of capturing biological interactions between TCR sequences while maintaining computational complexity and tractability in a reasonable range. We considered both biological and computational needs when designing the graph construction strategy. Immunological studies have shown that T cells’ responses to cancer are often characterized by clusters of clonally related sequences that share antigen specificity. In order to align with and capture useful information from this clustered structure, we implemented a k-nearest neighbor (k-NN) approach.
We selected k=10 after testing values of K ranging from 5 to 50 through ablation studies. We found that, at k=10, the model achieved the best performance in balancing two competing objectives: (1) retaining biologically meaningful linkage and ensuring that every sequence is connected to the most relevant neighbors, and (2) keeping appropriate computational practicability without overly complicated graphs. Compared to a smaller k-value, k=10 reduces the possibility of the emergence of disconnected graph components; compared with larger values of k, k=10 decreases the inducement of data noise which could result from connections that are weak and have little biological meaning. In experiments, k=10 generally performed better than other values, and we validated that this form of graph construction succeeds in identifying local topological structure of TCR repertoires, where antigen-driven expansion typically creates localized clusters of similar sequences. In conclusion, one graph for each individual was constructed, in which each node corresponds to one TCR sequence, and edges connect each node to its ten most similar neighbors based on the normalized similarity scores.
Furthermore, we recognize that the type of similarity calculation metric could have a considerable impact on the model’s performance. Therefore, we investigated three methods for similarity calculation: Levenshtein distance, Hamming distance, and the Needleman-Wunsch algorithm, as detailed in the Data Preprocessing section. Through comparison between these three methods, we hoped to exploit the advantages of each and understand their suitability for TCR based graph construction.
Neural network construction
In the process of creating the graph neural network, we attempted several methods. As we hoped to incorporate an attention mechanism to analyze weight, we experimented with various techniques and layers, implementing methods such as Set2Set and residual connections and adjusting the number of layers in the network. We also considered adding layers of a convolutional neural network to study whether it would bring an edge to the model and ameliorate the result of feature extraction. Through testing different versions of the model, we found that its complexity does not necessarily correlate in a positive way with its performance. In fact, the more cumbersome and convoluted models combining several algorithms and multiple layers all failed to attain a desirable result when used to predict cancer. With further attempts and adjustments, we designed a relatively simple, yet effective model, as illustrated by figure 4.

As explained in the Graph Construction section, we modified raw data into graph structures for each individual. We connected every sequence to its 10 closest neighbors. As it is proven by previous research that resemblance between TCR sequences indicates a similar function and relation to cancer, the graph was constructed based on similarity.
A Convolutional Neural Network (CNN) has been proven to effectively accomplish prediction tasks regarding health and diseases. Based on this idea from research precursors, we took a step further to investigate the performance of a different network known as the Graph Neural Network (GNN). Different from a traditional CNN, a GNN is able to directly process preconstructed graphs, extracting information to train itself20. Building upon the basics of a conventional GNN, the Graph Attention Network (GAT) utilized in our study exploited the potential of the attention mechanism to assess and assign weights to each node’s neighbor dynamically, allowing the model to learn more meaningful information. The architecture of this GAT-based model is composed of two GAT layers, a global attention pooling layer, and two fully connected layers. The first layer of the model is a graph attention convolution layer (GATConv), which computes the attention coefficient for each edge feature. These coefficients would determine how much impact the neighboring node would have on the current node during feature aggregation. Assuming hi represents the feature vector of node I, then the attention coefficient αij can be calculated through the following equation.
Within the equation, W represents the learnable weight matrix; a is used to define the learnable vector of the attention mechanism; || symbolizes concatenation; and softmaxj ensures that the attention coefficients of all neighboring nodes j for node i sum to 1. Through this calculation, the model can focus on neighboring nodes that are most closely related when aggregating information. The outputs of this layer are the transformed node feature representations, as calculated with the equation below.
In it, σ represents the non-linear activation function, in this case, ReLU activation. The first GAT layer turns the original 360-dimensional input features into a 128-dimensional output. More specifically, two attention heads were utilized, with each of them producing 64 dimensions, and their outputs are concatenated to form the 128-dimensional output.
On the basis of the first layer’s node embeddings, the second GAT layer again used an attention mechanism to further extract and optimize node features. Through concatenating outputs of two attention heads, with each producing a 16-dimensional output, the overall output is condensed to 32 dimensions. Such concatenation of the two heads ensures that the model captures diverse perspectives regarding the graph structure.
After the processing of two GAT layers, we applied a global attention pooling mechanism, aggregating node embeddings into a graph-level representation. This pooling process utilized a learnable gating function g, as shown below.
This allows the graph to assign more weight to important nodes while aggregating all node features, so that there will be more focus on nodes that have a greater influence on the prediction result.
For the graph representation H, we used two fully connected layers. The first layer maps the 32-dimensional embedding to 16 dimensions, using ReLU activation. Dropout is used to prevent overfitting by randomly dropping out some of the activations during training. The second layer maps to two logits, one for healthy and one for cancer. Softmax is then used to convert the logits to probabilities.
in which zc is the logit for class c and C=2. The class with the higher probability is taken as the prediction. Training uses the cross-entropy loss
where yic equals 1 if sample i belongs to class c and 0 otherwise, and Hi is the graph-level representation of sample i.
In conclusion, the GAT model combines a graph attention mechanism and global pooling, enabling it to extract features from both the node and graph levels concurrently. The attention mechanism granted it the ability to focus on relevant neighboring nodes when generating node embeddings, and assign weight to better represent actual biological interactions and correlations. By capturing information from data, this architecture could effectively classify individuals as healthy or as having cancer based on their TCR repertoires.
Results and Analysis
Using data from a cohort of healthy individuals and patients, we were able to evaluate the success of our model. The data we used to assess our model’s capability in predicting lung cancer are publicly available TCR-seq data from the Adaptive Biotechnologies immuneACCESS online database (IA). We also used TCR-seq data from the clinical database of Geneplus Technology Ltd. in Shenzhen (Geneplus)21. We tested the three most commonly used optimization methods, namely Adam, Adadelta and RMSprop, using an initial learning rate of 0.001 for each of them. Our experiments showed that the Adam optimizer with β1=0.9 and β2=0.999 is the most stable optimization method, and thus we used it in all our experiments. To further enhance training efficiency and prevent overfitting, we implemented a comprehensive early stopping mechanism that monitored validation loss with a patience of 25 epochs. Additionally, we employed the ReduceLROnPlateau scheduler, which reduced the learning rate by a factor of 0.5 when no improvement was observed for 15 consecutive epochs. This combination of techniques ensured that training automatically terminated when performance plateaued while maintaining the ability to escape local minima through learning rate adjustments. Through ablation studies, we found that this optimized training strategy reduced the average number of required epochs by 35% compared to fixed-epoch training while improving model generalization.
Despite having a relatively small training and testing data size of only a few hundred individuals, our model was capable of correctly gathering the correlation between TCR sequences and achieved higher accuracy when compared to many other currently available models. Our data were also split into 80 percent for training and the remaining 20 percent for testing. The model was applied to two different cancer types, lung and thyroid cancer. To prevent data leakage and ensure a rigorous evaluation of model generalizability, we implemented patient-level data splitting rather than sequence-level splitting. All TCR sequences from a single individual were exclusively assigned to either the training set or the test set. This strict separation guarantees that the model is evaluated on completely unseen patients, providing a realistic assessment of its performance in a true diagnostic scenario where new patients are presented.
Specifically, we first split the entire cohort of individuals (e.g., 260 healthy donors and 184 lung cancer patients) into an 80% training cohort and a 20% held-out test cohort, ensuring that the class distribution was preserved in both splits (stratified splitting). This approach eliminates the risk of highly similarity sequences from the same patient appearing in both training and testing phases, thereby upholding the integrity of our performance metrics.
For lung cancer, we utilized a dataset of 260 healthy individuals and 184 patients with 100 TCR sequences from each individual. After running the data through our model, we achieved an accuracy, recall, precision, and f1-score all close to 1.00, showing that it is capable of predicting cancer with relatively no error (Tables 2 & 4) (Figure 5). For THCA cancer, we gathered data from 260 healthy individuals and 169 patients with our model also being able to accurately predict cancer (Tables 3 & 5) (Figure 5). We further investigated the impact of different similarity calculation methods on model performance (Table 5). Notably, the consistent superiority of the Adam optimizer across all similarity metrics confirmed its robustness for our graph-based learning task. The early stopping mechanism proved particularly valuable in the Hamming distance condition, where training automatically terminated after approximately 80 epochs due to validation performance plateauing, preventing further overfitting to the suboptimal similarity representation. While Levenshtein distance and the Needleman-Wunsch algorithm consistently yielded perfect results across both cancer types, Hamming distance showed notably inferior performance specifically in THCA cancer prediction (Accuracy = 0.61, F1-score = 0.02). This performance discrepancy highlights the significance of selecting appropriate similarity metrics in graph construction and suggests that Hamming distance may be less suitable for capturing the biological relevance in certain cancer types, possibly due to its limitation in handling sequence variations.
| DeepCAT | DeepLion | Our Model | |
| Accuracy | 0.698 | 0.818 | 1.00 |
| Sensitivity | 0.625 | 0.730 | 1.00 |
| Specificity | 0.750 | 0.882 | 1.00 |
| AUC | 0.736 | 0.899 | 1.00 |
| DeepCAT | DeepLion | Our Model | |
| Accuracy | 0.693 | 0.872 | 1.00 |
| Sensitivity | 0.488 | 0.775 | 1.00 |
| Specificity | 0.827 | 0.957 | 1.00 |
| AUC | 0.692 | 0.974 | 1.00 |
| Levenshtein distance | Hamming distance | Needleman–Wunsch | |
| Accuracy | 1.00 | 1.00 | 1.00 |
| Precision | 1.00 | 1.00 | 1.00 |
| Recall | 1.00 | 1.00 | 1.00 |
| F1 score | 1.00 | 1.00 | 1.00 |
| Levenshtein distance | Hamming distance | Needleman–Wunsch | |
| Accuracy | 1.00 | 0.61 | 1.00 |
| Precision | 1.00 | 0.01 | 1.00 |
| Recall | 1.00 | 0.50 | 1.00 |
| F1 score | 1.00 | 0.02 | 1.00 |
As shown in the results, our model is capable of achieving almost 100 percent accuracy in predicting Lung and THCA cancer. Although we have a relatively small dataset of only a few hundred people, this result still proves our model to be a valuable innovation and supports our hypothesis that a graph neural network with graph data constructed based on similarity would succeed in cancer prediction. Despite this promising result, we do recognize that 100 percent accuracy is extremely hard to achieve. Therefore, a 5-fold cross-validation test was conducted on our model using Levenshtein distance with its resulting confusion matrix displayed (Figure 7). The sample was split into 5 folds, and all folds generated the same confusion matrix with high scores.
Through this opportunity, we also provided further justification for the biological knowledge behind our model which is that similar TCR sequences provide a similar contribution to the presence of cancer in an individual. In the process of graph construction, we calculated the similarity between TCR sequences. Since our results demonstrated that this method is practicable, they also show the importance of similarity in TCR. As a result, to further exploit the use of this experiment, we compiled sequences that appear more than once or in different individuals, proposing that these sequences are likely key sequences to the development of cancer.
Conclusion
The use of T-cell receptor (TCR) analysis as a method of identifying and forecasting cancer is a rapidly developing field of study that combines the fields of Immunology and Artificial Intelligence. In this study we present a novel approach to utilizing TCR sequence data to forecast cancer incidence by combining Graph Neural Networks (GNNs) with Attention-Based Models. We demonstrate that our model, which creates a similarity graph of TCR sequences, performs better than all previously published methods in terms of both accuracy and interpretability. Our model had high values for accuracy, precision, recall, and F1-score, indicating that our similarity-based graph construction and attention-based model were successful. Furthermore, our results indicate that graph structures and attention mechanisms may be useful tools for studying the relationship between TCR sequences and how they are related to the diagnosis of cancer. We hope that our findings may inspire new methods for creating biologically relevant datasets for TCR analysis. However, there are several limitations to our study. First, the small size of our dataset limits our ability to generalize our findings. Second, although we studied the TCR CDR3β chain, there exist numerous other chains and interactions that need to be studied in future research. Third, our model has generated considerably high scores that require an extraordinary amount of supporting evidence and data, which are currently not available to us. Consequently, we do acknowledge the limitations to this research and that more research is necessary before clinical implementation of this methodology. Although our model provides biological interpretability, the larger challenge that remains is to create machine learning models that are more transparent and understandable for medical applications.
Discussion
As humanity enters the 21st century, artificial intelligence has been a growing field of interest for many researchers. Indeed, the innovation of AI and machine learning is a great benefactor for humans and many individuals’ lives were positively influenced by such innovations. However, the capability of AI comes with limitations and these limits have become a growing concern for researchers. One of the major issues associated with more complicated machine learning is the lack of interpretability, the ability for its users to understand every step of its operation. Since there is no machine that could produce a perfectly accurate result in the present days, users of AI models often doubt the result and prediction produced by their models, which largely undermines the practicability of AI models. Moreover, even with the production of an impeccable result, AI has no means to explain the internal logic supporting its answer.
Although some models such as the one we designed have a scientific or biological background that could somewhat explain the AI model, the exact reasoning behind its calculations still remains largely inscrutable. These problems existing in almost every model have been causing an issue especially in the medical field where every decision made could determine the life of an individual. In response to this pressing concern, many researchers have started investigating and achieved considerable outcomes in attempts to make the AI model more explicable. We also hope and will strive for a future where machine learning is no longer a black box.
Onto the specific topic of cancer prediction through graph neural networks, we found that the way of constructing a graph dataset would significantly impact the condition of our model. A pertinent question regarding our model design is the choice of sequence similarity as the sole criterion for graph construction, especially given the versatility of GNNs in handling diverse graph types, such as molecular graphs. However, we considered alternative graph construction paradigms during our study. For instance, the idea of constructing graphs based on predicted 3D structures or co-occurrence networks across individuals is conceptually appealing, although these approaches were eventually deemed less suitable for our specific task. Structural modeling at repertoire scale is computationally prohibitive and would introduce significant uncertainty, while co-occurrence networks are often too sparse and conflate functional similarity with other confounding factors. In contrast, the sequence-similarity-based graph is grounded in the fundamental immunological principle that TCRs with similar sequences often share antigen specificity4’11. This approach directly encodes functional relatedness into the graph structure, allowing our GNN to learn from the collective organization of the TCR repertoire. We therefore posit that for the task of cancer prediction from bulk TCR-seq data, similarity-based graphs offer an optimal balance of biological interpretability, computational tractability, and predictive performance.
Finding new ways of constructing graphs might be a way to ameliorate current models and could possibly lead to new innovations. Although not tested in our study, we came up with another graph construction method similar to the final one in this study. In this method, we would set a value “X” and, starting from one TCR sequence, we would connect every sequence that has a similarity score to that sequence smaller than “X”. If any sequence is left disconnected from the main graph, we would enlarge “X” to see if it can connect. We believe that this method could be an appropriate representation of similarity in TCR and be a good indicator of cancer activity while preventing redundant data and clogging of the model. In our future research, we would potentially test the true effectiveness of this method. Furthermore, after seeing some success in our current model, we will also try applying it to other cancer types in future work and even other areas where similar predictions are needed.
Acknowledgement
All the work was completed by myself with help and guidance from my mentor only. This study does not entail any hazards and does not involve vertebrate animal or human subjects. The data we used were publicly available from another study with the link below:
https://www.frontiersin.org/journals/genetics/articles/10.3389/fgene.2022.860510/full
References
- R. D. Schreiber, L. J. Old, M. J. Smyth. Cancer Immunoediting: Integrating Immunity’s Roles in Cancer Suppression and Promotion. Science 331, 1565–1570 (2011). doi:10.1126/science.1203486 [↩]
- K. A. Lagattuta, A. C. Kohlgruber, et al. The T cell receptor sequence influences the likelihood of T cell memory formation. bioRxiv [Preprint] (2023). doi:10.1101/2023.07.20.549939 [↩]
- D. J. Munson, C. A. Egelston, et al. Identification of Shared TCR Sequences from T Cells in Human Breast Cancer. PNAS (2016). doi:10.1073/pnas.1606994113 [↩]
- M. Vujović, P. Marcatili, et al. Signatures of T cell immunity revealed using sequence similarity with TCRDivER algorithm. Commun Biol 6, 357 (2023). https://doi.org/10.1038/s42003-023-04702-8 [↩] [↩] [↩]
- Y. Xu, X. Qian, et al. DeepLION: Deep Multi-Instance Learning Improves the Prediction of Cancer-Associated T Cell Receptors. Front Genet 13, 860510 (2022). doi:10.3389/fgene.2022.860510 [↩] [↩] [↩]
- Yuepeng Xu, Jie Ye, et al. Deep learning-based characterization of T cell receptor sequence patterns. Brief Bioinform24(3) (2023). doi:10.1093/bib/bbad086 [↩]
- E. Goffinet, R. Mall, et al. Mate-Pred: Multimodal Attention-Based TCR-Epitope Interaction Predictor. arXiv (2022). arXiv:2401.08619 [↩]
- Z. Yu, M. Jiang, X. Lan. HeteroTCR: A heterogeneous graph neural network-based method for peptide-TCR interaction. Commun Biol 7, 684 (2024). https://doi.org/10.1038/s42003-024-06380-6 [↩]
- A. Zhang, A. Piechocka-Trocha, X. Li, B.D. Walker. A Leucine Zipper Dimerization Strategy for Soluble T Cell Receptors. Cells 11(3), 312 (2022). doi:10.3390/cells11030312 [↩]
- Giancarlo Croce, S. Bobisse, et al. Deep learning predictions of TCR-epitope interactions reveal epitope-specific chains. Nat Commun 15, 3211 (2024). https://doi.org/10.1038/s41467-024-47461-8 [↩]
- Wang Z., Ji Z. T-cell receptor sequences correlate with and predict gene expression levels. bioRxiv (2023). doi:10.1101/2023.11.27.568912 [↩] [↩] [↩]
- X. Lin, J. T. George, et al. Rapid assessment of T-cell receptor specificity. Nat Comput Sci 1, 362–373 (2021). https://doi.org/10.1038/s43588-021-00076-1 [↩]
- Hou X., Wang M., Lu C., et al. Analysis of TCR Beta Chain CDR3 in Human. Cell Physiol Biochem 39(2), 651–667 (2016). https://doi.org/10.1159/000447814 [↩]
- S. Y. Chen, T. Yue, Q. Lei, A. Y. Guo. TCRdb: A comprehensive database for T-cell receptor sequences. Nucleic Acids Res 49(D1), D468–D474 (2021). https://doi.org/10.1093/nar/gkaa796 [↩]
- E. Rosati, C. M. Dowds, et al. Overview of methodologies for T-cell receptor repertoire analysis. BMC Biotechnol17, 61 (2017). https://doi.org/10.1186/s12896-017-0379-9 [↩]
- V. I. Levenshtein. Binary codes capable of correcting deletions, insertions, and reversals. Soviet Physics-Doklady10(8), 707–710 (1966). [↩]
- R. W. Hamming. Error detecting and error correcting codes. Bell Syst Tech J 29(2), 147–160 (1950). https://doi.org/10.1002/j.1538-7305.1950.tb00463.x [↩]
- S. Kawashima, M. Kanehisa. AAindex: Amino Acid Index Database. Nucleic Acids Res 28(1), 374 (2000). https://doi.org/10.1093/nar/28.1.374 [↩]
- Nieminen A., Konev A., et al. Predicting immunogenicity of peptides with T-cell receptor binding. Bioinformatics36(14), 4020–4027 (2020). https://doi.org/10.1093/bioinformatics/btaa324 [↩]
- G. Gori, F. Scarselli, et al. A new model for learning in graph domains. Proc. IEEE Int Joint Conf Neural Networks(2005). doi:10.1109/IJCNN.2005.1555942 [↩]
- X. Lan, J. Cao, K. Ye, et al. TCR-seq Identifies Distinct Repertoires of Thyroid Tumors. Clin Endocrinol Metab105(9), 3036–3045 (2020). doi:10.1210/clinem/dga452 [↩]








