Skip to main content

Python Toolkit for Mass Spectrometry

Project description

Build Status Documentation Status PyPI PyPI - Python Version Coverage

A Python toolkit for processing of chromatography–mass spectrometry data

PyMassSpec is a Python package for processing gas chromatography-mass spectrometry data. PyMassSpec provides a framework and a set of components for rapid development and testing of methods for processing of chromatography–mass spectrometry data. PyMassSpec can be used interactively through the Python shell, or the functions can be collected into scripts when it is preferable to perform data processing in the batch mode.


Originally by Andrew Isaac, Sean O’Callaghan and Vladimir Likić

The original publication can be found here: https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-13-115

Forked from the original PyMS Repository: https://github.com/ma-bio21/pyms.

The original project seems to have been abandoned as there has been no activity in 18 months.

The PyMassSpec project

The directory structure of PyMassSpec is as follows:

/
├── pyms:      The PyMassSpec code
│
├── pyms-data: Example GC-MS data files
│
├── pyms-demo: Examples of how to use PyMassSpec
│
├── tests: pytest tests
│
└── UserGuide: Sphinx source for documentation

Features

Installation

PyMassSpec can be installed with the following command:

$ pip --user install PyMassSpec

This will also install the following dependencies:

numpy >= 1.16.2
scipy >= 1.2.1
pymzml >= 2.2.1
matplotlib >= 3.0.2
openpyxl >= 2.6.2
netCDF4 >= 1.5.0
biopython >= 1.74
deprecation >= 2.0.6

PyMassSpec also requires ‘mp4py’, installation instructions for which can be found at: https://mpi4py.readthedocs.io/en/stable/

Usage

A tutorial illustrating various PyMassSpec features in detail is provided in subsequent chapters of this User Guide. The commands executed interactively are grouped together by example, and can be found here.

The data used in the PyMassSpec documentation and examples is available here.

In the “Demos and Examples” section there is a page corresponding to each example, coded with the chapter number (ie. “pyms-demo/20a/” corresponds to the Example 20a, from Chapter 2).

Each example has a script named ‘proc.py’ which contains the commands given in the example. These scripts can be run with the following command:

$ python3 proc.py

Example processing GC-MS data

Download the file gc01_0812_066.jdx and save it in the folder data. This file contains GC-MS data in the the JCAMP-DX format.

First the raw data is loaded:

>>> from pyms.GCMS.IO.JCAMP import JCAMP_reader
>>> jcamp_file = "data/gc01_0812_066.jdx"
>>> data = JCAMP_reader(jcamp_file)
-> Reading JCAMP file 'Data/gc01_0812_066.jdx'
>>> data
<pyms.GCMS.Class.GCMS_data at 0x7f3ec77da0b8>

The intensity matrix object is then built by binning the data:

>>> from pyms.IntensityMatrix import build_intensity_matrix_i
>>> im = build_intensity_matrix_i(data)

In this example, we show how to obtain the dimensions of the newly created intensity matrix, then loop over all ion chromatograms, and for each ion chromatogram apply Savitzky-Golay noise filter and tophat baseline correction:

>>> n_scan, n_mz = im.size
>>> from pyms.Noise.SavitzkyGolay import savitzky_golay
>>> from pyms.TopHat import tophat
>>> for ii in range(n_mz):
...     print("working on IC", ii)
...     ic = im.get_ic_at_index(ii)
...     ic1 = savitzky_golay(ic)
...     ic_smooth = savitzky_golay(ic1)
...     ic_base = tophat(ic_smooth, struct="1.5m")
...     im.set_ic_at_index(ii, ic_base)

The resulting noise and baseline corrected ion chromatogram is saved back into the intensity matrix.

Further examples can be found in the documentation

Contributing

Contributions are very welcome. Tests can be run with pytest. Please ensure the coverage is at least .. image:: https://coveralls.io/repos/github/domdfcoding/pymassspec/badge.svg?branch=master before you submit a pull request.

For further information see the section Contributing to PyMassSpec

License

PyMassSpec is Free and Open Source software released under the GNU General Public License version 2.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyMassSpec-2.2.3.tar.gz (90.1 kB view details)

Uploaded Source

Built Distribution

PyMassSpec-2.2.3-py3-none-any.whl (147.8 kB view details)

Uploaded Python 3

File details

Details for the file PyMassSpec-2.2.3.tar.gz.

File metadata

  • Download URL: PyMassSpec-2.2.3.tar.gz
  • Upload date:
  • Size: 90.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for PyMassSpec-2.2.3.tar.gz
Algorithm Hash digest
SHA256 b137c3d0373139bbd7e499c9bd9f3731358a081ddb4134d38d3b1989ae44e080
MD5 4b4ad8fde31ae66fe0cbb1c9aa3bfb01
BLAKE2b-256 f9cd3bd6b5304a5f0293b6c1cdbc9bb5913b274c394d7d7640c1ee5d3b1b2a57

See more details on using hashes here.

File details

Details for the file PyMassSpec-2.2.3-py3-none-any.whl.

File metadata

  • Download URL: PyMassSpec-2.2.3-py3-none-any.whl
  • Upload date:
  • Size: 147.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for PyMassSpec-2.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 210f093f22d491bf70764778f05135d11ce6c9a9d1607c0c0c33f67af428230c
MD5 1e1f5e94d91786b85d7f2eee98805aa1
BLAKE2b-256 5c27915d27940bcbb4096581b7d7e8eee0efb1d8e7f6731d7ff88ed9675ba3ff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page