A Bidirectional LSTM (BLSTM) deep learning model that predicts whether a peptide is immune-stimulatory or non-stimulatory, reproducing the approach from "Development and optimization of an activity-trained deep learning model."
The model is trained and evaluated separately on peptide datasets from two disease contexts:
- COVID-19
- M. tuberculosis (M.tb)
- Data loading — Peptide sequences and binary activity labels (stimulatory = 1, non-stimulatory = 0) are read from an Excel file (
Data/data.xlsx), one sheet per disease. - Encoding — Each peptide is encoded as a sequence of integers over the 20 canonical amino acids, then padded to the longest sequence in the dataset.
- Architecture —
Embedding → Masking → Bidirectional LSTM → Bidirectional LSTM → Dense (ReLU) → Dense (Sigmoid), trained with binary cross-entropy loss. - Hyperparameter tuning —
GridSearchCV(viascikeras) searches over BLSTM units, dense units, dropout, learning rate, batch size, and epochs. - Class imbalance handling — Class weights are computed and applied during training to correct for imbalance between stimulatory and non-stimulatory peptides.
- Training — 60/20/20 train/validation/test split (stratified), with early stopping on validation loss.
- Evaluation & outputs — For each dataset, the script saves:
- A metrics table image (precision/recall/F1 per class, per split)
- Loss, accuracy, and ROC curve plots
- Confusion matrices for train/validation/test
- The trained Keras model (
.kerasfile)
pip install tensorflow==2.15.0
pip install keras scikit-learn pandas numpy openpyxl matplotlib seaborn scikeras- Place your peptide dataset as
Data/data.xlsx, with one sheet per disease (e.g.COVID-19,M.tb), each containingpeptideandlabelcolumns. - Run the script:
python Code/BLSTM_activity_trained_model.py
- Outputs (plots and saved models) are written to the
Data/folder.
BLSTM/
└── Code/
└── BLSTM_activity_trained_model.py # Main training & evaluation script