This library combines brainpy and ms_peak_picker to build a toolkit for MS and MS/MS data. The goal of these libraries is to provide pieces of the puzzle for evaluating MS data modularly. The goal of this library is to combine the modules to streamline processing raw data.
ms_deisotope
uses PEP 517 and 518 build system definition and isolation to ensure all of its
compile-time dependencies are installed prior to building. Normal installation should work with pip,
and pre-built wheels are available for Windows.
ms_deisotope
and several of its dependencies use C extensions to make iterative operations much
faster. If you plan to use this library on a large amount of data, I highly recommend you ensure they
are installed:
>>> import ms_deisotope
>>> ms_deisotope.DeconvolutedPeak
<type 'ms_deisotope._c.peak_set.DeconvolutedPeak'>
Building C extensions from source requires a version of Cython >= 0.27.0
Compiling C extensions requires that numpy
, brain-isotopic-distribution
, and ms_peak_picker
be compiled and installed prior to building ms_deisotope
:
pip install numpy
pip install -v brain-isotopic-distribution ms_peak_picker
pip install -v ms_deisotope
If these libraries are not installed, ms_deisotope
will fall back to using pure Python implementations,
which are much slower.
ms_deisotope
can read from mzML, mzXML and MGF files directly, using the pyteomics
library.
On Windows, it can also use comtypes
to access Thermo's MSFileReader.dll to read RAW files and
Agilent's MassSpecDataReader.dll to read .d directories. Whenever possible, the library provides a
common interface to all supported formats. With Thermo's pure .NET library, it can use pythonnet
to read Thermo RAW files on Windows and Linux (and presumably Mac, too).
from ms_deisotope import MSFileLoader
from ms_deisotope.data_source import mzxml
# open a file, selecting the appropriate reader automatically
reader = MSFileLoader("path/to/data.mzML")
# or specify the reader type directly
reader = mzxml.MzXMLLoader("path/to/data.mzXML")
All supported readers provide fast random access for uncompressed files, and support the Iterator interface.
# jump the iterator to the MS1 scan nearest to 30 minutes into the run
reader.start_from_scan(rt=30)
# read out the next MS1 scans and all associated MSn scans
scan_bunch = next(reader)
print(scan_bunch.precursor, len(scan_bunch.products))
Gzip compressed mzML, mzXML, and MGF files are transparently decompressed with unaffected sequential access time but can be very slow for random access. ms_deisotope supports idzip-flavor gzip compressed files which provide the same degree of data compression as gzip (and backwards-compatible with programs expecting gzip) but offers near-uncompressed random access speed.
An "Averagine" model is used to describe the composition of an "average amino acid", which can then be used to approximate the composition and isotopic abundance of a combination of specific amino acids. Given that often the only solution available is to guess at the composition of a particular m/z because there are too many possible elemental compositions, this is the only tractable solution.
This library supports arbitrary Averagine formulae, but the Senko Averagine is provided by default: {"C": 4.9384, "H": 7.7583, "N": 1.3577, "O": 1.4773, "S": 0.0417}
from ms_deisotope import Averagine
from ms_deisotope import plot
peptide_averagine = Averagine({"C": 4.9384, "H": 7.7583, "N": 1.3577, "O": 1.4773, "S": 0.0417})
plot.draw_peaklist(peptide_averagine.isotopic_cluster(1266.321, charge=1))
- ms_deisotope includes several pre-defined averagines (or "averagoses" as may be more appropriate):
- Senko's peptide - ms_deisotope.peptide
- Native N- and O-glycan - ms_deisotope.glycan
- Permethylated glycan - ms_deisotope.permethylated_glycan
- Glycopeptide - ms_deisotope.glycopeptide
- Sulfated Glycosaminoglycan - ms_deisotope.heparan_sulfate
- Unsulfated Glycosaminoglycan - ms_deisotope.heparin
The general-purpose averagine-based deconvolution procedure can be called by using the high level API function deconvolute_peaks, which takes a sequence of peaks, an averagine model, and a isotopic goodness-of-fit scorer:
import ms_deisotope
deconvoluted_peaks, _ = ms_deisotope.deconvolute_peaks(peaks, averagine=ms_deisotope.peptide,
scorer=ms_deisotope.MSDeconVFitter(10.))
The result is a deisotoped and charge state deconvoluted peak list where each peak's neutral mass is known and the fitted charge state is recorded along with the isotopic peaks that gave rise to the fit.
Refer to the documentation for a deeper description of isotopic pattern fitting.