Designing meaningful continuous representations of T cell receptor sequences with deep generative models

Allen Leary, Darius Scott, Namita T. Gupta, Janelle Waite, Dimitris Skokos, Gurinder S. Atwal, Peter G. HawkinsNature Communications 2024

Abstract

T Cell Receptor (TCR) antigen binding underlies a key mechanism of the adaptive immune response yet the vast diversity of TCRs and the complexity of protein interactions limits our ability to build useful low dimensional representations of TCRs. To address the current limitations in TCR analysis we develop a capacity-controlled disentangling variational autoencoder trained using a dataset of approximately 100 million TCR sequences, that we name TCR-VALID. We design TCR-VALID such that the model representations are low-dimensional, continuous, disentangled, and sufficiently informative to provide high-quality TCR sequence de novo generation. We thoroughly quantify these properties of the representations, providing a framework for future protein representation learning in low dimensions. The continuity of TCR-VALID representations allows fast and accurate TCR clustering and is benchmarked against other state-of-the-art TCR clustering tools and pre-trained language models.

TL;DR

Researchers have developed TCR-VALID, a deep generative model that maps the astronomical diversity of T cell receptor (TCR) sequences into a smooth, 16-dimensional latent space. By balancing information capacity with biological interpretability, the model enables state-of-the-art TCR clustering, de novo sequence generation, and robust detection of "unknown" sequences.

Introduction

T cell receptors (TCRs) are the primary "sensors" of our adaptive immune system, recognizing fragments of pathogens or tumors. However, the potential diversity of human TCRs is staggering—estimated between $10^{15}$ and $10^{61}$ possible sequences.

The challenge is functional: how do we group TCRs that bind the same target when we have millions of sequences but very few labels? Existing computational tools often struggle with this "needle in a haystack" problem. Some are too slow for large datasets, while others (like large language models) produce high-dimensional representations that are difficult to interpret or use for designing new receptors. The authors sought a "Goldilocks" representation: low-dimensional enough for optimization, continuous enough for smooth transitions, and biologically meaningful.

Methods: The TCR-VALID Architecture

The core of the paper is TCR-VALID (T Cell Receptor - Variational Autoencoder Landscape for Interpretable Disentangling). Key technical innovations include:

  • Physicochemical Encoding: Instead of treating amino acids as arbitrary letters (one-hot encoding), the model represents them using seven physical properties (e.g., hydrophobicity, size, charge). This grounds the model in the actual chemistry of protein interactions.
  • Capacity-Controlled $\beta$-VAE: The authors used a specialized Variational Autoencoder (VAE) where they strictly controlled the "information capacity" ($C$) of the latent space. By limiting how many "bits" of information the model can store, they forced it to learn a smooth, continuous landscape rather than just memorizing sequences.
  • Disentanglement: The model was designed to separate different biological factors—like the "V gene" (the structural backbone) and the "CDR3 region" (the specific binding loop)—into different latent dimensions.
The TCR-VALID architecture uses physicochemical featurization and a capacity-controlled VAE to learn a 16D latent space.

Datasets

The authors utilized a massive scale of data to train and validate the model:

  • Training: Approximately 100 million unique TCR sequences (unlabeled) sourced from the iReceptor Gateway and VDJServer.
  • Evaluation: A comprehensive labeled dataset of TCR-antigen pairs (from VDJdb and other sources) was used to benchmark clustering and classification performance.
  • Robustness: They used a CD4 TCR reference set to "spike in" irrelevant sequences, testing how well the model maintains performance in noisy, real-world scenarios.

Key Insights: Continuity and Disentanglement

  • The Continuity-Accuracy Tradeoff: There is a fundamental tension between how accurately a model reconstructs a sequence and how "smooth" its internal map is. By tuning the information capacity ($C$), the authors found a sweet spot ($C=2$ nats per dimension) that allows for meaningful "walking" through the latent space without falling off the manifold of biologically feasible proteins.
  • Disentanglement as Interpretability: By using Random Forests to probe the latent space, the authors proved that specific dimensions independently encode the V gene, J gene, and insert properties. This means the model isn't a "black box"; we can see which "knobs" it's turning to change a TCR's properties.
  • Uncertainty Awareness: By training with an auxiliary loss on unlabeled data, the model can perform "Out-of-Distribution" (OOD) detection. It can effectively say, "I've never seen a TCR like this before," which is crucial for clinical applications where identifying novel or rare immune responses is the goal.
Latent transversals demonstrate how TCR-VALID navigates the continuous latent space to generate biologically realistic sequence variations.

Key Results

  • Clustering Performance: TCR-VALID matched or exceeded the performance of specialized tools like tcrdist and iSMART in grouping TCRs by antigen specificity.
  • Scalability: The model scales significantly better than traditional distance-based methods. While some tools take hours to process large repertoires, TCR-VALID’s embedding and clustering are fast enough for million-sequence datasets.
  • Generative Design: The authors demonstrated de novo generation of TCR sequences by averaging the latent representations of known binders and decoding them back into sequences, producing motifs that match experimentally validated receptors.
  • Classification: In antigen classification tasks, TCR-VALID achieved high accuracy (median AUROC ~0.94) while providing superior OOD detection compared to existing deep learning models like DeepTCR.

Limitations and Future Work

While TCR-VALID is a major step forward, the authors note several areas for growth:

  • Zero-Shot Challenges: Predicting binding for an entirely new antigen (one not seen during training) remains an "incredibly large state space" problem that no current model has fully solved.
  • Paired Chains: Most of the training was done on independent $\alpha$ or $\beta$ chains due to data availability. Future work could better integrate paired-chain data as single-cell sequencing becomes more common.
  • Structural Integration: While physicochemical properties are a proxy for structure, incorporating 3D structural data directly could further improve the model's physical realism.

Summary updated

BibTeX
@inproceedings{leary2024designing,
  author = {Allen Leary and Darius Scott and Namita T. Gupta and Janelle Waite and Dimitris Skokos and Gurinder S. Atwal and Peter G. Hawkins},
  title = {{Designing meaningful continuous representations of T cell receptor sequences with deep generative models}},
  booktitle = {Nature Communications},
  year = {2024},
  doi = {10.1038/s41467-024-48198-0},
}
Figure