bittremieux / spectrum_utils

Python package for efficient mass spectrometry data processing and visualization
https://spectrum-utils.readthedocs.io/
Apache License 2.0
140 stars 20 forks source link

Annotate neutral loss fragments in peptide spectra #17

Closed bittremieux closed 3 years ago

bittremieux commented 3 years ago

Fixes #16.

Neutral losses are specified by their molecular formula. Neutral losses are specified by their delta mass.

Also slight changes to the FragmentAnnotation interface to follow the PSI peak interpretation specification in development for the PSI spectral library format. This also changes the designation of the peak charges in the plot a bit.

I'm still thinking a bit about the interface and underlying code.

TODO:

Example:

import matplotlib.pyplot as plt
import pandas as pd
import spectrum_utils.plot as sup
import spectrum_utils.spectrum as sus

peaks = pd.read_csv('https://metabolomics-usi.ucsd.edu/csv/'
                    '?usi=mzspec%3AMassIVE%3ATASK-f4b86b150a164ee4a440b661e97a7193-spectra'
                    '%3Ascan%3A471429%3ATSMGGTQQQFVEGVR%2F2')
spectrum = sus.MsmsSpectrum(
    'mzspec:MassIVE:TASK-f4b86b150a164ee4a440b661e97a7193-spectra:scan:471429',
    812.8890, 2, peaks['mz'].values, peaks['intensity'].values,
    peptide='TSMGGTQQQFVEGVR')

spectrum.annotate_peptide_fragments(0.05, 'Da', ion_types='aby',
                                    neutral_losses={'NH3': -17.026549,
                                                    'H2O': -18.010565})

fig, ax = plt.subplots(figsize=(12, 6))
sup.spectrum(spectrum, ax=ax)
plt.savefig('neutral_loss.png', dpi=300, bbox_inches='tight')
plt.close()

Plot: neutral_loss