Transformer-diffusion de novo peptide sequencing for data-independent acquisition mass spectrometry
Project description
DiffNovo_DIA
Transformer-Diffusion de novo peptide sequencing for data-independent acquisition mass spectrometry.
DiffNovo_DIA is an extension of the Transformer_DIA model that integrates a transformer architecture with a diffusion model to improve de novo peptide sequencing from data-independent acquisition (DIA) mass spectrometry.
Installation
To manage dependencies efficiently, we recommend using conda. Start by creating a dedicated conda environment:
conda create --name diffnovo-dia python=3.10
Activate the environment:
conda activate diffnovo-dia
Install DiffNovo_DIA and its dependencies via pip:
pip install diffnovo-dia
To verify a successful installation, check the command-line interface:
diffnovo-dia --help
Data Preprocessing
Feature Extraction
To use DiffNovo_DIA, you must first generate a feature file that serves as structured input to the model. We provide a script which takes your spectrum and feature files as input and produces a pickle file containing the formatted features. The generated features include:
- Keys: Peptide sequences
- Values: List containing the following attributes:
precursor_mzprecursor_chargescan_list_middlems1mz_listint_listneighbor_right_countneighbor_size_half
To run the script, use the provided script feature_extractor.py to generate feature file required by Transformer_DIA and DiffNovo_DIA models. The script takes the following inputs:
- A feature CSV file
- An MGF spectrum file It will generate a pickled feature file compatible with both diffnovo_dia and transformer_dia models.
python feature_extractor.py --feature_file your_feature.csv --spectrum_file your_spectra.mgf --output_file output_features.pkl
MGF Annotation
Use this script to annotate .mgf files with peptide sequences for models like PepNet, DiffNovo, Transformer-DIA and DiffNovo_DIA. The annotation process links each precursor ion in feature file to spectra in the MGF file.
For Transformer-DIA and DiffNovo_DIA, the recommended selection mode is five_rt, which automatically selects the top five spectra whose retention times are closest to the mean retention time of the corresponding precursor ion. The selection spectra for annotation should be aligned with spectra selection in feature extraction — for example, we used five_rt for both.
You can run the script using:
For annotating with PepNet, set the model_name to pepnet. For other models, leave the model_name empty.
python annotate_mgf.py --model_name pepnet --spectrum_file input.mgf --feature_file features.csv --selection five_rt
If you're not using PepNet, simply leave model_name empty:
python annotate_mgf.py --model_name "" --spectrum_file input.mgf --feature_file features.csv --selection five_rt
Both feature_extractor.py and annotate_mgf.py are located in the data_utils/ directory.
Usage
Predict Peptide Sequences
DiffNovo_DIA predicts peptide sequences from MS/MS spectra stored in MGF files. Predictions are saved as a CSV file:
diffnovo-dia --mode=denovo --model=pretrained_checkpoint.ckpt --peak_path=path/to/spectra.mgf --peak_feature=path/to/precursor_feature.pkl
Evaluate de novo Sequencing Performance
To assess the performance of de novo sequencing against known annotations:
diffnovo-dia --mode=eval --model=pretrained_checkpoint.ckpt --peak_path=path/to/spectra.mgf --peak_feature=path/to/precursor_feature.pkl
Annotations in the MGF file must include peptide sequences in the SEQ field.
Train a New Model
To train a new Transformer model from scratch, provide labeled training and validation datasets in MGF format:
diffnovo-dia --mode=train --peak_path=path/to/train/annotated_spectra.mgf \
--peak_feature=path/to/train/precursor_feature.pkl \
--peak_path_val=path/to/validation/annotated_spectra.mgf \
--peak_feature_val==path/to/validation/precursor_feature.pkl
MGF files must include peptide sequences in the SEQ field.
Fine-Tune an Existing Model
To fine-tune a pretrained Transformer-DIA model, set the --train_from_scratch parameter to false:
diffnovo-dia --mode=train --model=pretrained_checkpoint.ckpt \
--peak_feature=path/to/train/precursor_feature.pkl \
--peak_path_val=path/to/validation/annotated_spectra.mgf \
--peak_feature_val==path/to/validation/precursor_feature.pkl
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file diffnovo_dia-0.1.1.tar.gz.
File metadata
- Download URL: diffnovo_dia-0.1.1.tar.gz
- Upload date:
- Size: 66.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b915b76e97bbd221c27948eba6df3a72cb6d56af2f2805dc4e5c104059f4ebc9
|
|
| MD5 |
cc5efe425c75bb260254a1698b135177
|
|
| BLAKE2b-256 |
f6fa490e3cd9bba366c5596e614858ef0c6ebbf9432c429aea4795190f79f788
|
File details
Details for the file diffnovo_dia-0.1.1-py3-none-any.whl.
File metadata
- Download URL: diffnovo_dia-0.1.1-py3-none-any.whl
- Upload date:
- Size: 76.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a53fdbe9c2f9afda2e84889655b2bea836e01dd96ebb6e5758dde3d1e4b2ffe
|
|
| MD5 |
8884b2c7d5b150501721bc3567fe072c
|
|
| BLAKE2b-256 |
3e1b8fcebcbcb536f0c8014894260f96802433128d540b1248c53683c2cf0927
|