Skip to content

Simple MS/MS spectrum preprocessing and visualization in Python

License

Notifications You must be signed in to change notification settings

justinjjvanderhooft/spectrum_utils

 
 

Repository files navigation

spectrum_utils

Build status Python 3.6 Python 3.7

Simple MS/MS spectrum preprocessing and visualization in Python.

Features

  • 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

Example

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

Installation

spectrum_utils can be installed easily via pip:

pip install spectrum_utils

Or via conda:

conda install -c bioconda spectrum_utils

Dependencies

spectrum_utils has the following dependencies:

Missing dependencies will be automatically installed when you install spectrum_utils.

API documentation

You can find the API documentation here.

Contact

For more information you can visit the official code website or send an email to [email protected].

About

Simple MS/MS spectrum preprocessing and visualization in Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 80.4%
  • Python 19.5%
  • Shell 0.1%