Commit 56b69ec7 by Andrea Mancini

Update README.md

parent f9ed6dd2
......@@ -6,7 +6,7 @@ We implemented SPIN, a Transformer model inspired by ESM-2, for functionally cla
We experimented with two Protein families: Thioredoxin (TRX) and SH3. We identify functional classes and subclasses with ProfileView (https://doi.org/10.1101/717249), handling thousands of sequences at a time to create comprehensive groups.
Our goal is to achieve large-scale classification of millions of proteins from extensive databases and ongoing high-throughput sequencing efforts. Moreover, it identifies conserved residues that are crucial for subfamilies, providing insights into the functional nuances of protein subclasses.
[Click here](https://zenodo.org/records/17351600) to visit public Zenodo record.
[Click here](https://zenodo.org/records/18394307) to visit public Zenodo record.
- **Architecture**:
<p align="center">
......@@ -30,6 +30,7 @@ Datasets split: Train 80%, Val 10 %, Test 10%
| PLMs Classifier | PLM Parameters | Val Acc | Val F1 | Test Acc | Test F1 | Start (± 3) | End (± 3) | Training (s/iter) w/ batch = 16 | Test (s/iter) w/ batch = 16 |
|:---------------------------:|:--------------:|:-------:|:------:|:--------:|:-------:|:-----------:|:---------:|:-------------------------------:|:---------------------------:|
| ESM2-35M | 35M (Freezed) | 0.797 | 0.796 | 0.798 | 0.796 | 0.505 | 0.571 | 0.53 | 0.52 |
| ESM2-650M | 650M (Frozen) | 0.858 | 0.842 | 0.857 | 0.856 | 0.557 | 0.638 | 4.52 | 4.51 |
| ProtT5-XL-UR50-Half Encoder | 1.2B (Freezed) | 0.826 | 0.826 | 0.822 | 0.821 | 0.512 | 0.583 | 4.43 | 4.16 |
| Ankh-base Encoder | 450M (Freezed) | 0.815 | 0.813 | 0.822 | 0.820 | 0.476 | 0.556 | 3.90 | 3.82 |
......@@ -54,18 +55,19 @@ Get started with just a few steps:
**Protein Families:**
| Model | # Classes | # tokens | # Epoch | #Val F1 score | # Checkpoint |
|:---:|:---:|:---:|:---:|:---:|:---:|
| TRX model | 8 | 1024 | 7 | 0.92 | [🔗 Download](https://zenodo.org/records/17466839/files/trx_8class_model.tar?download=1) |
| SH3 model | 7 | 1024 | 10 | 0.91 | [🔗 Download](https://zenodo.org/records/17466839/files/sh3_7class_model.tar?download=1) |
| CPF model | 8 | 1024 | 10 | 0.99 | [🔗 Download](https://zenodo.org/records/17466839/files/cpf_8class_model.tar?download=1) |
| Model | # Classes | # tokens | # Epoch | #Val F1 score | # Checkpoint | # Calibrated Temp.Scaler (Joblib)
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| TRX model | 8 | 1024 | 7 | 0.92 | [🔗 Download](https://zenodo.org/records/18394307/files/trx_8class_model.tar?download=1) | [🔗 Download](https://zenodo.org/records/18394307/files/trx_temperature_scaler.joblib?download=1)
| SH3 model | 7 | 1024 | 10 | 0.91 | [🔗 Download](https://zenodo.org/records/18394307/files/sh3_7class_model.tar?download=1) | [🔗 Download](https://zenodo.org/records/18394307/files/sh3_temperature_scaler.joblib?download=1)
| CPF model | 8 | 1024 | 10 | 0.99 | [🔗 Download](https://zenodo.org/records/18394307/files/cpf_8class_model.tar?download=1) | [🔗 Download](https://zenodo.org/records/18394307/files/cpf_temperature_scaler.joblib?download=1)
**PLMs Comparison on TRX family:**
| Model | # Epoch | # Checkpoint |
|:---:|:---:|:---:|
| Ankh-base | 10 |[🔗 Download](https://zenodo.org/records/17466839/files/ankh_freezed_trx8.tar?download=1) |
| ESM2-35M | 7 |[🔗 Download](https://zenodo.org/records/17466839/files/esm_trx_freezed.tar?download=1) |
| Ankh-base | 10 |[🔗 Download](https://zenodo.org/records/18394307/files/ankh_freezed_trx8.tar?download=1) |
| ESM2-35M | 7 |[🔗 Download](https://zenodo.org/records/18394307/files/esm_trx_freezed.tar?download=1) |
| ProtT5-XL | 5 |[🔗 Download](https://drive.google.com/file/d/1FNeI46XlfoTNDS-nst25-nWYFB2KxklU/view?usp=sharing) |
......@@ -80,24 +82,47 @@ Example of dataset.csv:
```bash
create_dataset.py -f path_to_fasta -t path_to_nhx --depth val (optional) --nodes "Internal Node IDs list of subtrees" --class "Class IDs (only if passing a node list)"
```
### 5️⃣ Train the model
```bash
training.py -f path_to_csv --epochs 10 --batchsize 8 -v 2
```
```bash
training.py -f path_to_csv --epochs 10 --batchsize 8 -v 2
```
#### Change backbone model:
Open config.py > edit 'version' instance attribute in Model_args class with:
- Ankh-base - 🤗 Model card: [ElnaggarLab/ankh-base](https://huggingface.co/ElnaggarLab/ankh-base)
- ProtT5-XL - 🤗 Model card: [Rostlab/prot_t5_xl_half_uniref50-enc](https://huggingface.co/Rostlab/prot_t5_xl_half_uniref50-enc)
*Change backbone model:*
Open config.py > edit 'version' instance attribute in Model_args class with:
- Ankh-base - 🤗 Model card: [ElnaggarLab/ankh-base](https://huggingface.co/ElnaggarLab/ankh-base)
- ProtT5-XL - 🤗 Model card: [Rostlab/prot_t5_xl_half_uniref50-enc](https://huggingface.co/Rostlab/prot_t5_xl_half_uniref50-enc)
### 7️⃣ Predict
```bash
predict.py -f path_to_csv --ckptpath checkpoint.tar
```
### 8️⃣ Compute Calibrated Probabilities
```code
import joblib
import torch
from utils.evaluation_utils import EvalMetrics, evaluate
from utils.torch_utils import load_model
... # load data
model = load_model(model_path)
criterion = torch.nn.functional.cross_entropy
metric = EvalMetrics(len(model.config.labels))
tot_loss, tot_loss_span, start_acc, end_acc, start_pred, end_pred, start_prob, end_prob = evaluate(
model, criterion, sh3_metric, sh3_loader, verbose=1, device=device, return_span=True
)
scaler = joblib.load(scaler_path)
scaled_probs = scaler.predict(metric.y_prob)
```
<!---### Example Jupyter nb
Open demo.ipynb for an example of inference with TRX--->
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment