numpy==1.22.4
pandas==1.4.3
scikit_learn==1.2.2
scipy==1.7.3
torch==1.12.1
tqdm==4.64.1
transformers==4.24.0
Clone this Github repo and set up a new conda environment. It normally takes about 10 minutes to install on a normal desktop computer.
# create a new conda environment
$ conda create --name TCRBinder python=3.9
$ conda activate TCRBinder
# install requried python dependencies
$ pip install -r requirements.txt
# clone the source code of TCRBinder
$ git clone https://github.com/dongweihe/TCRBinder.git
$ cd TCRBinder
The raw interaction data were compiled from publicly accessible resources, including VDJdb (https://vdjdb.cdr3.net/), IEDB (https://www.iedb.org/), McPAS-TCR (http://friedmanlab.weizmann.ac.il/McPAS-TCR/), OTS (https://opig.stats.ox.ac.uk/webapps/ots), and the 10x Genomics datasets (https://www.10xgenomics.com/datasets).
We separately pre-train two RoFormer models on TCR α chain and β chain sequences. Then, utilize pHLA-TCR (PHT) binding data to fine-tune these models, finally forming the TCRBinder model.
You need to download the files “ProcessedData/Alpha.csv” and “ProcessedData/Beta.csv” from Zenodo(https://doi.org/10.5281/zenodo.20808756), and place them into the “/ProcessedData” folder. The commands for pre-training two RoFormer models on TCR α chain and β chain sequences are:
python pretrain_main.py --config ./config/common/pretrain_alpha.json
python pretrain_main.py --config ./config/common/pretrain_beta.json
After training completes, the pre-trained Roformer models will be saved in ../Result_alpha/checkpoints/Pretrain/XXXX_XXXXXX and ../Result_beta/checkpoints/Pretrain/XXXX_XXXXXX folders, where XXXX_XXXXXX is the training timestamp.
We provide a standalone script encode_tcr.py for encoding new TCR sequences without running the full TCRBinder pipeline. You need to place encode_tcr.py in the project directory, and then set INPUT_CSV, ALPHA_DIR, BETA_DIR, and OUT_PREFIX in encode_tcr.py according to your local paths.
The command for encoding new TCR sequences is:
python encode_tcr.py
The outputs will be saved under ./Standalone_TCR_Embeddings/tcr_embeddings.
Since we use ESM2 model parameters as the antigen model, you need to download the ESM2 model parameters from Hugging Face (https://huggingface.co/facebook/esm2_t30_150M_UR50D/tree/main) and place them into the /Code/esm2/esm2_150m directory.
You can use our provided simple example dataset (“Sample.csv”) to run our model. The training command for TCRBinder is:
python finetuning_main.py --config ./config/common/finetuning.json
Before running the task, please timely replace the file paths for "tcr_tokenizer_dir", "beta_dir", and "alpha_dir" in the finetuning.json configuration file.
After fine-tuning, you can evaluate external datasets. Before evaluation, please copy the absolute path of model_best.pth from the ../Result_PHT/checkpoints/ directory to the "discriminator_resume" field in the generalization.json file. Then, replace beta_dir with ../Result_beta/checkpoints/Pretrain/XXXX_XXXXXX/, replace "alpha_dir" with ../Result_alpha/checkpoints/Pretrain/XXXX_XXXXXX/, and update the corresponding "tcr_tokenizer_dir", "alpha_dir", and "beta_dir".
The generalization command for TCRBinder is:
python generalization.py --config ./config/common/generalization.json
If you have any questions, please contact us via email:
numpy==1.22.4
pandas==1.4.3
scikit_learn==1.2.2
scipy==1.7.3
torch==1.12.1
tqdm==4.64.1
transformers==4.24.0
Clone this Github repo and set up a new conda environment. It normally takes about 10 minutes to install on a normal desktop computer.
# create a new conda environment
$ conda create --name TCRBinder python=3.9
$ conda activate TCRBinder
# install requried python dependencies
$ pip install -r requirements.txt
# clone the source code of TCRBinder
$ git clone https://github.com/dongweihe/TCRBinder.git
$ cd TCRBinder
The raw interaction data were compiled from publicly accessible resources, including VDJdb (https://vdjdb.cdr3.net/), IEDB (https://www.iedb.org/), McPAS-TCR (http://friedmanlab.weizmann.ac.il/McPAS-TCR/), OTS (https://opig.stats.ox.ac.uk/webapps/ots), and the 10x Genomics datasets (https://www.10xgenomics.com/datasets).
We separately pre-train two RoFormer models on TCR α chain and β chain sequences. Then, utilize pHLA-TCR (PHT) binding data to fine-tune these models, finally forming the TCRBinder model.
You need to download the files “ProcessedData/Alpha.csv” and “ProcessedData/Beta.csv” from Zenodo(https://doi.org/10.5281/zenodo.20808756), and place them into the “/ProcessedData” folder. The commands for pre-training two RoFormer models on TCR α chain and β chain sequences are:
python pretrain_main.py --config ./config/common/pretrain_alpha.json
python pretrain_main.py --config ./config/common/pretrain_beta.json
After training completes, the pre-trained Roformer models will be saved in ../Result_alpha/checkpoints/Pretrain/XXXX_XXXXXX and ../Result_beta/checkpoints/Pretrain/XXXX_XXXXXX folders, where XXXX_XXXXXX is the training timestamp.
We provide a standalone script encode_tcr.py for encoding new TCR sequences without running the full TCRBinder pipeline. You need to place encode_tcr.py in the project directory, and then set INPUT_CSV, ALPHA_DIR, BETA_DIR, and OUT_PREFIX in encode_tcr.py according to your local paths.
The command for encoding new TCR sequences is:
python encode_tcr.py
The outputs will be saved under ./Standalone_TCR_Embeddings/tcr_embeddings.
Since we use ESM2 model parameters as the antigen model, you need to download the ESM2 model parameters from Hugging Face (https://huggingface.co/facebook/esm2_t30_150M_UR50D/tree/main) and place them into the /Code/esm2/esm2_150m directory.
You can use our provided simple example dataset (“Sample.csv”) to run our model. The training command for TCRBinder is:
python finetuning_main.py --config ./config/common/finetuning.json
Before running the task, please timely replace the file paths for "tcr_tokenizer_dir", "beta_dir", and "alpha_dir" in the finetuning.json configuration file.
After fine-tuning, you can evaluate external datasets. Before evaluation, please copy the absolute path of model_best.pth from the ../Result_PHT/checkpoints/ directory to the "discriminator_resume" field in the generalization.json file. Then, replace beta_dir with ../Result_beta/checkpoints/Pretrain/XXXX_XXXXXX/, replace "alpha_dir" with ../Result_alpha/checkpoints/Pretrain/XXXX_XXXXXX/, and update the corresponding "tcr_tokenizer_dir", "alpha_dir", and "beta_dir".
The generalization command for TCRBinder is:
python generalization.py --config ./config/common/generalization.json
If you have any questions, please contact us via email: