Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Integrating AIR and transcriptomics

🧠 Key takeaways
⚙️ Environment setup
Steps
yml
  1. Install conda:

    • Before creating the environment, ensure that conda is installed on your system.

  2. Save the yml content:

    • Copy the content from the yml tab into a file named environment.yml.

  3. Create the environment:

    • Open a terminal or command prompt.

    • Run the following command:

      conda env create -f environment.yml
  4. Activate the environment:

    • After the environment is created, activate it using:

      conda activate <environment_name>
    • Replace <environment_name> with the name specified in the environment.yml file. In the yml file it will look like this:

      name: <environment_name>
  5. Verify the installation:

    • Check that the environment was created successfully by running:

      conda env list
🗄️ Get data and notebooks

This book uses lamindb to store, share, and load datasets and notebooks using the theislab/sc-best-practices instance. We acknowledge free hosting from Lamin Labs.

  1. Install lamindb

    • Install the lamindb Python package:

    pip install lamindb
  2. Optionally create a lamin account

  3. Verify your setup

    • Run the lamin connect command:

    import lamindb as ln
    
    ln.Artifact.connect("theislab/sc-best-practices").df()

    You should now see up to 100 of the stored datasets.

  4. Accessing datasets (Artifacts)

    • Search for the datasets on the Artifacts page

    • Load an Artifact and the corresponding object:

    import lamindb as ln
    
    af = ln.Artifact.connect("theislab/sc-best-practices").get(
        key="key_of_dataset", is_latest=True
    )
    obj = af.load()

    The object is now accessible in memory and is ready for analysis. Adapt the lamindb.Artifact.connect("theislab/sc-best-practices").get("SOMEIDXXXX") suffix to get respective versions.

  5. Accessing notebooks (Transforms)

    lamin load <notebook url>

    which will download the notebook to the current working directory. Analogously to Artifacts, you can adapt the suffix ID to get older versions.

Motivation

Paired receptor and gene expression measurements link the clonal history and specificity of a cell to its state. Cells of one clonotype share their antigen and often their fate, which is partly determined by the receptor itself Lagattuta et al., 2022. In the previous chapters, we used the transcriptomic cell types to interpret clonotypes, and here we use the clonotypes to interpret the gene expression.

Output
→ connected lamindb: theislab/sc-best-practices
! It looks like you are running jupyter lab but don't have jupyter-server module installed. Please install it via pip install jupyter-server
→ loaded Transform('xCJYwnWzps2W0000', key='multimodal_integration.ipynb'), started new Run('xZKKNgqU8dvNwNa9') at 2026-09-29 18:14:11 UTC
→ notebook imports: anndata==0.13.2 lamindb-core==2.10.0 scanpy==1.12.4 scirpy==0.25.1

We load the T cells annotated in the specificity chapter.

Clonotypes in the gene expression space

We normalize the gene expression and build a neighborhood graph on the principal components that the authors corrected for batch effects between the sequencing runs.

To color the embedding by clonal expansion, we copy it from the airr modality to the gene expression.

<Figure size 1664x480 with 2 Axes>

Expanded clonotypes are concentrated in one region of the CD8+ T cells, whereas CD4+ T cells are rarely expanded. Cells that lack one of the two chains have no clonotype (nan).

Clonotype modularity

Clonotype modularity tests whether the cells of a clonotype are more connected in the neighborhood graph of the gene expression than expected by chance, following the idea of CoNGA Schattgen et al., 2022. Clonotypes with a high modularity share a transcriptional state, whereas clonotypes whose cells are spread across states have differentiated into several fates.

Output
Loading...
Loading...
<Figure size 850x400 with 3 Axes>
gex:cell_type CD8.TE 148 CD4.CM 84 CD8.EM 83 NKT 38 MAIT 25 Name: airr:clone_id, dtype: int64

Most clonotypes with a significant modularity consist of terminal effector or effector memory CD8+ T cells, whose expanded clones share an effector state.

Gene expression of expanded T cells

Groups defined by the receptors can be compared like any other groups of cells. We compare expanded and non-expanded CD8+ T cells.

<Figure size 640x480 with 1 Axes>

Expanded CD8+ T cells express cytotoxic genes such as NKG7, GZMH, GNLY and PRF1, consistent with their effector state. This comparison treats cells as independent samples, which suffices to characterize groups of cells. Comparisons between conditions, such as severity groups, should instead aggregate the cells of each donor into pseudobulk samples, as described in the differential gene expression chapter Squair et al., 2021.

Joint embeddings

Several methods learn a joint representation of receptor sequences and gene expression. CoNGA relates the neighborhood graphs of TCR and gene expression similarity Schattgen et al., 2022, TESSA and its BCR counterpart Benisse let receptor similarity constrain the expression of clonotypes Zhang et al., 2021Zhang et al., 2022, and mvTCR embeds TCRs and gene expression with a multimodal variational autoencoder Drost et al., 2024. Their authors showed that joint representations capture specificity better than either modality alone, but no independent benchmark of these methods exists yet. We therefore recommend starting with the transparent analyses shown above and using joint embeddings to generate hypotheses, for example about groups of clonotypes that may share an antigen.

Quiz

Loading...

Contributors

We gratefully acknowledge the contributions of:

Authors

  • Felix Drost

Reviewers

  • Lukas Heumos

References
  1. Lagattuta, K. A., Kang, J. B., Nathan, A., Pauken, K. E., Jonsson, A. H., Rao, D. A., Sharpe, A. H., Ishigaki, K., & Raychaudhuri, S. (2022). Repertoire analyses reveal T cell antigen receptor sequence features that influence T cell fate. Nature Immunology, 23(3), 446–457. 10.1038/s41590-022-01129-x
  2. Schattgen, S. A., Guion, K., Crawford, J. C., Souquette, A., Barrio, A. M., Stubbington, M. J., Thomas, P. G., & Bradley, P. (2022). Integrating T cell receptor sequences and transcriptional profiles by clonotype neighbor graph analysis (CoNGA). Nature Biotechnology, 40(1), 54–63.
  3. Squair, J. W., Gautier, M., Kathe, C., Anderson, M. A., James, N. D., Hutson, T. H., Hudelle, R., Qaiser, T., Matson, K. J. E., Barraud, Q., Levine, A. J., La Manno, G., Skinnider, M. A., & Courtine, G. (2021). Confronting false discoveries in single-cell differential expression. Nature Communications, 12(1), 5692. 10.1038/s41467-021-25960-2
  4. Zhang, Z., Xiong, D., Wang, X., Liu, H., & Wang, T. (2021). Mapping the functional landscape of T cell receptor repertoires by single-T cell transcriptomics. Nature Methods, 18(1), 92–99.
  5. Zhang, Z., Chang, W. Y., Wang, K., Yang, Y., Wang, X., Yao, C., Wu, T., Wang, L., & Wang, T. (2022). Interpreting the B-cell receptor repertoire with single-cell gene expression using Benisse. Nature Machine Intelligence, 1–9.
  6. Drost, F., An, Y., Bonafonte-Pardàs, I., Dratva, L. M., Lindeboom, R. G. H., Haniffa, M., Teichmann, S. A., Theis, F., Lotfollahi, M., & Schubert, B. (2024). Multi-modal generative modeling for joint analysis of single-cell T cell receptor and gene expression data. Nature Communications, 15(1), 5577. 10.1038/s41467-024-49806-9