The pipeline takes as input a list of sequences in a CSV, which are passed into a pretrained language model to perform downstream calculations.
Create a new environment:
conda create -n plm
Activate the environment:
conda activate plm
To install necessary libraries:
pip install -r requirements.txt
or pip install -r requirements_sapiens.txt since Sapiens is not compatible with Python version 3.9 and above.
(optional) Set the cache directory in the shell: export HF_HOME="/path/to/your/cache_dir"
Run the script scripts/pipeline.py with the following arguments:
model_name class name of the model to use. Currently available: Ablang, Ablang2, ProtBert, Sapiens, ESM1b, ESMC, ESM2file_path path with the location of the input CSV file.
sequence_id_columnsequence_columnchain with either IGH/IGL/IGK for Ig heavy chain or light chain sequences respectively, only necessary when using the models Ablang and Sapienssequence_id_columnsequence_column column name of the sequence to use in the input CSVsequence_id_column column name of the sequence identifier in the input CSV (default: sequence_id)output_folder folder name to store outputcalc_list list of the downstream calculations to perform
pseudolikelihood calculates pseudolikelihood for each sequence, adds it to the input CSV, and saves this as output CSVprobability_matrix calculates the probability matrix of each amino acid per position of each sequence and save this matrix as CSVembeddings calculate the embeddings per sequence or per residue based on the parameter embeddings_methodsuggest_mutations: based on the previously calculated probability matrix values it suggests a desired number of mutationsattention_matrix calculates the attention matrix between residues in a sequencenumber_mutations number of mutations you want the model to suggest (default is 1)cache_dir path to a cache directory to download the pretrained ESM models if the standard cache should not be used.embeddings_method method to output the embeddings, one of:
average_pooling takes the average output embeddings for each sequence, adds it to the input CSV, and saves this as output CSV (default)per_token takes the embedding per residue, outputs a CSV per sequenceattention_head how to pool the attention heads per layer, one of:
average (default)sumlayer for which layer(s) to get the embedding or attention (default is last)
src/. Be careful that the name of the file is not the same as any of the packages that we are usingfit_transform which will transform the sequences using the model and create embeddings.calc_pseudo_likelihood_sequence calculates the pseudolikelihood of whole sequence (sum of log-scaled per-residue probablities, divided by sequence length)calc_probability_matrix calculates the probability matrix of each amino acid per position of a sequencecalc_attention_matrix calculates the attention matrix between residues in a sequencescripts/pipeline.py as import and at the initialization step.src/src/utils.pyscripts/pipeline.py script seperately for Ablang/Sapiens and other modelsThe pipeline takes as input a list of sequences in a CSV, which are passed into a pretrained language model to perform downstream calculations.
Create a new environment:
conda create -n plm
Activate the environment:
conda activate plm
To install necessary libraries:
pip install -r requirements.txt
or pip install -r requirements_sapiens.txt since Sapiens is not compatible with Python version 3.9 and above.
(optional) Set the cache directory in the shell: export HF_HOME="/path/to/your/cache_dir"
Run the script scripts/pipeline.py with the following arguments:
model_name class name of the model to use. Currently available: Ablang, Ablang2, ProtBert, Sapiens, ESM1b, ESMC, ESM2file_path path with the location of the input CSV file.
sequence_id_columnsequence_columnchain with either IGH/IGL/IGK for Ig heavy chain or light chain sequences respectively, only necessary when using the models Ablang and Sapienssequence_id_columnsequence_column column name of the sequence to use in the input CSVsequence_id_column column name of the sequence identifier in the input CSV (default: sequence_id)output_folder folder name to store outputcalc_list list of the downstream calculations to perform
pseudolikelihood calculates pseudolikelihood for each sequence, adds it to the input CSV, and saves this as output CSVprobability_matrix calculates the probability matrix of each amino acid per position of each sequence and save this matrix as CSVembeddings calculate the embeddings per sequence or per residue based on the parameter embeddings_methodsuggest_mutations: based on the previously calculated probability matrix values it suggests a desired number of mutationsattention_matrix calculates the attention matrix between residues in a sequencenumber_mutations number of mutations you want the model to suggest (default is 1)cache_dir path to a cache directory to download the pretrained ESM models if the standard cache should not be used.embeddings_method method to output the embeddings, one of:
average_pooling takes the average output embeddings for each sequence, adds it to the input CSV, and saves this as output CSV (default)per_token takes the embedding per residue, outputs a CSV per sequenceattention_head how to pool the attention heads per layer, one of:
average (default)sumlayer for which layer(s) to get the embedding or attention (default is last)
src/. Be careful that the name of the file is not the same as any of the packages that we are usingfit_transform which will transform the sequences using the model and create embeddings.calc_pseudo_likelihood_sequence calculates the pseudolikelihood of whole sequence (sum of log-scaled per-residue probablities, divided by sequence length)calc_probability_matrix calculates the probability matrix of each amino acid per position of a sequencecalc_attention_matrix calculates the attention matrix between residues in a sequencescripts/pipeline.py as import and at the initialization step.src/src/utils.pyscripts/pipeline.py script seperately for Ablang/Sapiens and other models