Simple MS/MS spectrum preprocessing and visualization in Python.
- Spectrum (pre)processing
- Precursor & noise peak removal
- Intensity filtering
- Intensity scaling
- Modification-aware fragment ion annotating (powered by Pyteomics)
- Spectrum plotting
- Single spectrum with annotated ions
- Mirror plot of matching spectra
- Interactive spectrum plots
import matplotlib.pyplot as plt
from spectrum_utils import plot
from spectrum_utils import spectrum
# Initialize spectrum information first...
spec = spectrum.MsmsSpectrum(identifier, precursor_mz, precursor_charge,
mz, intensity, retention_time=retention_time,
peptide=peptide)
# Preprocess the MS/MS spectrum.
fragment_tol_mass = 10
fragment_tol_mode = 'ppm'
spec = (spec.set_mz_range(min_mz=100, max_mz=1400)
.remove_precursor_peak(fragment_tol_mass, fragment_tol_mode)
.filter_intensity(min_intensity=0.05, max_num_peaks=150)
.scale_intensity(scaling='root')
.annotate_peaks(fragment_tol_mass, fragment_tol_mode,
ion_types='aby'))
# Plot the MS/MS spectrum.
plot.spectrum(spec)
plt.show()
plt.close()
(Condensed example. See here for the full code to generate the figure below.)
spectrum_utils
can be installed easily via pip:
pip install spectrum_utils
Or via conda:
conda install -c bioconda spectrum_utils
spectrum_utils
has the following dependencies:
Missing dependencies will be automatically installed when you install spectrum_utils
.
You can find the API documentation here.
For more information you can visit the official code website or send an email to [email protected].