Skip to main content

A Python-based gloss of the RaMS package in R

Project description

pylgrams

A Python language gloss of the RaMS package for rapid and intuitive access to mass-spectrometry data. This package parses the open source mass-spectrometry mzML and mzXML file types in Python and returns the retention time, m/z ratio, and intensity values to the user as a Pandas data frame. This allows for easy chromatogram extraction and visualization.

The package currently lacks much of the expanded functionality of RaMS and is currently comparable to RaMS v1.0. I don't have plans to expand this much further - for additional functionality, consider using the rpy2 package to port the R code directly.

Installation

pip install pylgrams

Demo

import matplotlib.pyplot as plt
import seaborn as sns
import os
import pylgrams

msdata = pylgrams.grabMSdata("src/pylgrams/example_data/S30657.mzML.gz")
bet_chrom = msdata["MS1"][(msdata["MS1"]["mz"]>118.085) & (msdata["MS1"]["mz"]<118.087)]
bet_chrom = bet_chrom[(bet_chrom["rt"]>7) & (bet_chrom["rt"]<9)]
sns.relplot(bet_chrom, kind="line", x="rt", y="int")
plt.show()

bet_frags = msdata["MS2"][(msdata["MS2"]["premz"]>118.0865) & (msdata["MS2"]["premz"]<118.0867)]
plt.stem(bet_frags["fragmz"], bet_frags["int"], linefmt='-k', markerfmt='ko', basefmt=" ")
plt.show()

dir_path = "src/pylgrams/example_data/"
only_mzML_files_os = [os.path.join(dir_path, f) for f in os.listdir(dir_path) if f.endswith('.mzML.gz')]
msdata = pylgrams.grabMSdata(only_mzML_files_os)
bet_chrom = msdata["MS1"][(msdata["MS1"]["mz"]>118.085) & (msdata["MS1"]["mz"]<118.087)]
sns.relplot(bet_chrom, kind="line", x="rt", y="int", hue="filename")
plt.show()

Project details


Download files

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

Source Distribution

pylgrams-1.0.1.tar.gz (1.7 MB view hashes)

Uploaded Source

Built Distribution

pylgrams-1.0.1-py3-none-any.whl (1.7 MB view hashes)

Uploaded Python 3

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