AMPGen: A de novo Generation Pipeline Leveraging Evolutionary Information for Broad-Spectrum Antimicrobial Peptide Design
Overview
AMPGen is a pipeline for generating and evaluating novel antimicrobial peptide (AMP) sequences. Using EvoDiff, a novel diffusion framework in protein design, AMPGen generates new AMP sequences and employs machine learning models to classify and predict their antimicrobial efficacy. The pipeline has demonstrated exceptional success efficiency, with 29 out of 34 peptides (85.3%) exhibiting antimicrobial activity (MIC value less than 200 µg/ml against at least one bacterium).
Methods
Datasets Preparation
We compiled AMP and non-AMP datasets from various public databases for use in our classification and MIC prediction models. The AMP dataset includes sequences from APD, DADP, DBAASP, DRAMP, YADAMP, and dbAMP, resulting in a final set of 10,249 unique sequences with antibacterial targets. The non-AMP dataset, sourced from UniProt, consists of 11,989 sequences filtered to exclude those associated with specific antimicrobial keywords.
De Novo AMP Generation
AMP sequences are generated using two pre-trained order-agnostic autoregressive diffusion models (OADM) from the EvoDiff framework (paper).
-
Sequence-Based Generation:
- The sequence-based model, Evodiff-OA_DM_640M, is pre-trained on the Uniref50 dataset, containing 42 million protein sequences. This model unconditionally generates peptide sequences of length 15-35 aa.
-
MSA-Based Generation:
- The MSA-based model, Evodiff-MSA_OA_DM_MAXSUB, is trained on the OpenFold dataset and generates sequences in two ways:
- Unconditional generation of peptide sequences of length 15-35 aa.
- Conditional generation using MSAs with known AMP sequences as representative sequences.
- The MSA-based model, Evodiff-MSA_OA_DM_MAXSUB, is trained on the OpenFold dataset and generates sequences in two ways:
Classification and Efficacy Prediction
-
XGBoost-based AMP Classifier:
- Dataset Preparation: Sequences in the AMP dataset were filtered based on length, retaining those within the range of 5 to 65 aa, resulting in a total of 9,964 AMP-labeled peptide sequences as the positive dataset.
- Feature Extraction: Features were primarily derived from the PseKRAAC encoding method and QSOrder encoding parameters, resulting in 14 categories of 1,311 features.
- Model Training: The data was used to train an XGBoost model, with AMP sequences labeled as 1 and nonAMP sequences labeled as 0. Model tuning was conducted based on the F1 score and AUC index using 10-fold cross-validation (k-fold 10) to prevent overfitting.
-
LSTM Regression-based MIC Predictor:
- Dataset Preparation: All entries in the AMP dataset with MIC values were included. The AMP sequences targeting Escherichia coli totaled 7,100, while those targeting Staphylococcus aureus totaled 6,482. Sequences with multiple MIC values targeting the same bacteria were averaged and converted to a uniform unit of μM. These values were then log-transformed (log₁₀). Additionally, 7,193 sequences from the nonAMP dataset were labeled with a logMIC value of 4.
- Model Training: Separate regression training was conducted on the Escherichia coli and Staphylococcus aureus datasets using Long Short-Term Memory (LSTM) models. The datasets were split into training, validation, and test sets in the ratio of 72:18:10. Each model comprised two LSTM layers, a dropout layer with a dropout rate of 0.7, and a linear layer. The models were compiled using standard L2 loss and optimized with the Adam optimizer.
Installation Guide
Welcome to the AMPGen project! This guide will walk you through the steps required to install and set up the necessary environment and dependencies to run AMPGen. Before getting started, please ensure that you have Anaconda installed on your system.
Prerequisites
To use the AMPGen system, you need Python 3.11 and a few essential libraries. We'll guide you through setting up a clean conda environment, installing EvoDiff, and then the necessary dependencies. Required Python libraries: numpy, pandas, tqdm, scikit-learn, xgboost.
Setting Up the Environment
-
Create a Conda Environment
Next, create a new conda environment with Python 3.8.5, which is the recommended version for this project:conda create --name AMPGen python=3.11 conda activate AMPGen
-
Install Environment
With the new environment activated, install all packages:pip install -r requirements.txt pip install ampgen
Usage Guide
1. Generate New AMP Sequences
Conditional Generation of AMP Sequences with MSA
You can generate antimicrobial peptide (AMP) sequences using EvoDiff's conditional generation model with MSA.First, you’ll need your template sequence and to run an MSA tool (e.g. HHblits or MMseqs2) to generate an a3m file. We’ve provided an example a3m in the “example” folder.
## Use a ModelScope model to accelerate downloads.
from modelscope.hub.file_download import model_file_download
import os
import shutil
from ampgen.util.generation import generate_conditional_msa_sequences
import torch
files_to_download = ['msa-oaar-maxsub.tar','oaar-38M.tar']
target_dir = os.path.expanduser("~/.cache/torch/hub/checkpoints")
os.makedirs(target_dir, exist_ok=True)
downloaded_files = []
for filename in files_to_download:
file_path = model_file_download(
model_id='wolfberry/AMPGen',
file_path=filename,
revision='master'
)
target_path = os.path.join(target_dir, filename)
shutil.move(file_path, target_path)
print(f"Download: {target_path}")
downloaded_files.append(target_path)
print(f"\nDownload complete!")
total_sequences = 2 # Set the number of sequences you want to generate
directory_path = '/mnt/workspace/example'
to_device = 'cuda' if torch.cuda.is_available() else 'cpu'
out= generate_conditional_msa_sequences(directory_path=directory_path, total_sequences=total_sequences, to_device=to_device)
# print(seq) # Print the generated sequence from the first entry
sequences = [row[4] for row in out]
print(sequences)
Unconditional Generation of AMP Sequences with MSA
You can generate antimicrobial peptide (AMP) sequences' MSA using EvoDiff's unconditional generation model.We take the first entry in the MSA file as the model’s final output; in an MSA, the first query sequence is typically the template sequence we want. By default, MSA files have a depth of 16.
from ampgen.util.generation import generate_unconditional_msa_sequences
import torch
total_sequences = 1 # Set the number of sequences you want to generate
to_device = 'cuda' if torch.cuda.is_available() else 'cpu'
seq = generate_unconditional_msa_sequences(total_sequences=total_sequences,to_device=to_device)
print(seq)
Unconditional Generation of AMP Sequences
You can generate antimicrobial peptide (AMP) sequences using EvoDiff's unconditional generation model.Here we use the smaller model (OA_DM_38M) as an example; you can also switch to the larger OA_DM_640M model.
from ampgen.util.generation import generate_unconditional_sequences
import torch
total_sequences = 1 # Set the number of sequences you want to generate
to_device = 'cuda' if torch.cuda.is_available() else 'cpu'
model_name = "OA_DM_38M" #OA_DM_640M,OA_DM_38M
seq = generate_unconditional_sequences(total_sequences=total_sequences, to_device=to_device, model_name=model_name)
print(seq)
2. Calculate Properties of Generated Sequences
Calculate Properties of Generated AMP Sequences
You can calculate the physical and chemical properties of the generated AMP sequences, including molecular weight, net charge, and hydrophobicity.We recommend designating as candidates those sequences with net charges greater than 0 and a proportion of hydrophobic amino acids between 0.3 and 0.7.
from ampgen.util.CalProperties import calculate_properties
# set the display options for pandas
import pandas as pd
pd.set_option("display.expand_frame_repr", False)
pd.set_option("display.max_columns", None)
pd.set_option("display.width", 1000)
seq = ['KIGERIERIGQRIKDFFQNLAPRLEE', 'AGEEIGRTVEGIGRTIKDFFTNLAP'] #Sequences may only contain the 20 standard amino acids.
out = calculate_properties(seq)
print(out) # Print the DataFrame containing the calculated properties
3. Identify AMP Candidates
AMP Discriminator
To classify sequences as antimicrobial peptides (AMPs) using the AMP Discriminator.
import os
import argparse
import pandas as pd
import xgboost
from ampgen.model.features import get_pre_features
from ampgen.model.Discriminator import classify_sequences
from modelscope.hub.file_download import model_file_download
# set the display options for pandas
import pandas as pd
pd.set_option("display.expand_frame_repr", False)
pd.set_option("display.max_columns", None)
pd.set_option("display.width", 1000)
# Download AMPGen_discriminator from modelscope
print("Downloading AMPGen_discriminator... ")
file_path = model_file_download(
model_id='wolfberry/AMPGen',
file_path='AMPGen_discriminator.bin',
revision='master'
)
print("Predicting…... ")
seq = ['KIGERIERIGQRIKDFFQNLAPRLEE', 'AGEEIGRTVEGIGRTIKDFFTNLAP']
model_path = file_path
out = classify_sequences(model_path,seq)
print(out.to_string(index=False)) # Print the DataFrame containing the classification results
4. Run the MIC Scorer
This section provides a step-by-step guide to using the MIC scorer. The scorer predicts the MIC (Minimum Inhibitory Concentration) values using a pre-trained LSTM model based on protein embeddings generated by an ESM model.Note that you need to run the ESM-3b model here, it requires a certain amount of GPU resources.
from ampgen.model.MICscorer import get_predicted_mic
from modelscope.hub.file_download import model_file_download
import torch
# set the display options for pandas
import pandas as pd
pd.set_option("display.expand_frame_repr", False)
pd.set_option("display.max_columns", None)
pd.set_option("display.width", 1000)
# Download MIC_scorer from modelscope
def download_and_get_paths():
scaler_path = model_file_download(
model_id='wolfberry/AMPGen',
file_path='ecoliscaler.pkl', # stpascaler.pkl
revision='master'
)
lstm_model_path = model_file_download(
model_id='wolfberry/AMPGen',
file_path='AMPGen_Gneg_scorer.pth', # AMPGen_Gpos_scorer.pth
revision='master'
)
model_location = model_file_download(
model_id='wolfberry/AMPGen',
file_path='esm2_t36_3B_UR50D.pt',
revision='master'
)
model_plus = model_file_download(
model_id='wolfberry/AMPGen',
file_path='esm2_t36_3B_UR50D-contact-regression.pt',
revision='master'
)
return scaler_path, lstm_model_path, model_location
print("Downloading MIC Scorer... ")
scaler_path, lstm_model_path, model_location = download_and_get_paths()
print("Predicting…... ")
to_device = 'cuda' if torch.cuda.is_available() else 'cpu'
df = get_predicted_mic(
sequences=['KIGERIERIGQRIKDFFQNLAPRLEE', 'AGEEIGRTVEGIGRTIKDFFTNLAP'],
model_location=model_location,
scaler_path=scaler_path,
lstm_model_path=lstm_model_path,
device=to_device,
)
print(df)