A multimodal foundation model for T cell receptor and transcriptome analysis
Project description
TCRfoundation
A multimodal foundation model for single-cell immune profiling
Overview
TCRfoundation integrates gene expression and TCR sequences (α and β chains) from paired single-cell measurements through self-supervised pretraining with masked reconstruction and cross-modal contrastive learning.
Input and Pretraining Architecture
Gene expression profiles are encoded through feed-forward layers with multi-head attention, while TCR sequences are tokenized and processed through transformer blocks. The fused representations are learned via three objectives: masked gene expression reconstruction, masked TCR sequence reconstruction, and cross-modal alignment.
Fine-tuning Tasks
The pretrained model supports three downstream applications:
- T-cell state classification: Predict tissue origin, disease state, and cellular phenotype
- Binding specificity detection: Identify TCR-antigen interactions and quantify binding avidity
- Cross-modal prediction: Infer gene expression from TCR sequences
Installation
From PyPI (Recommended)
pip install tcrfoundation
From Source
git clone https://github.com/Liao-Xu/TCRfoundation.git
cd TCRfoundation
pip install -e .
Requirements: Python 3.8+, PyTorch 1.10.0+
Quick Start
import tcrfoundation as tcrf
import scanpy as sc
# Load your data
adata = sc.read("your_data.h5ad")
# Pretrain the foundation model
model, history = tcrf.pretrain.train(
adata,
epochs=500,
batch_size=2048,
save_dir='models/'
)
# Fine-tune for classification
results, adata_new = tcrf.finetune.classification.train_classifier(
adata,
label_column="cell_type",
checkpoint_path="models/foundation_model_best.pt",
num_epochs=50
)
Documentation
- Full Documentation: https://tcrfoundation.readthedocs.io
Tutorials
Complete Jupyter notebook tutorials are available:
- Pretraining - Train the foundation model
- Classification - T cell state classification
- Specificity - Antigen specificity prediction
- Avidity - Binding avidity regression
- Cross-modal - TCR-to-gene prediction
Contact
- Author: Xu Liao
- Email: xl3514@cumc.columbia.edu
- GitHub: https://github.com/Liao-Xu/TCRfoundation
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tcrfoundation-0.1.3.tar.gz.
File metadata
- Download URL: tcrfoundation-0.1.3.tar.gz
- Upload date:
- Size: 46.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f32d28de7027fb46882f5d3e9ecf2213ee1f4eaf0714728d24ea91fce0dd3f07
|
|
| MD5 |
0d6e31c53b2d5d1b378ea6a5bedcbff2
|
|
| BLAKE2b-256 |
527c068a81df5b301730f3566a89dd6a8ceee32091482ef4e3a6f3dbbe834900
|
File details
Details for the file tcrfoundation-0.1.3-py3-none-any.whl.
File metadata
- Download URL: tcrfoundation-0.1.3-py3-none-any.whl
- Upload date:
- Size: 56.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcfaeb5e8dfbc7fde8ab487960b48fc1e3c0037f5e2033aee5e2c0c85594baa5
|
|
| MD5 |
a84d6e3604b7fbdd23d2725bb668000c
|
|
| BLAKE2b-256 |
1e2fec3fe51f246505995955f31b3a53c65905b8aa351a49e37346d578db94ff
|