I found this documentation on pyOpenMS mass spec library. I want to try different peak picking algorithms. Unfortunately, the docs are not very detailed and don't show how to use the other peak picking algorithms and the codebase itself is also quite cryptic for me.

Any idea how to use, for example, the FeatureFindingMetabo algorithm insead of the centroided one?

from urllib.request import urlretrieve
# from urllib import urlretrieve  # use this code for Python 2.x
gh = "https://raw.githubusercontent.com/OpenMS/OpenMS/develop"
urlretrieve (gh +"/src/tests/topp/FeatureFinderCentroided_1_input.mzML", "feature_test.mzML")

from pyopenms import *

# Prepare data loading (save memory by only
# loading MS1 spectra into memory)
options = PeakFileOptions()
fh = MzMLFile()

# Load data
input_map = MSExperiment()
fh.load("feature_test.mzML", input_map)

ff = FeatureFinder()

# Run the feature finder
name = "centroided"
features = FeatureMap()
seeds = FeatureMap()
params = FeatureFinder().getParameters(name)
ff.run(name, input_map, features, params, seeds)

fh = FeatureXMLFile()
fh.store("output.featureXML", features)
print("Found", features.size(), "features")
  • $\begingroup$ Hi Sören, We build a Python pipeline with FeatureFinderMetabo, it was like a year ago so I can not recall the details right now, but you can see the entire thing here: github.com/saezlab/lipyd/blob/master/src/lipyd/msproc.py If you will be still having issues, maybe in the weekend I can check it again. $\endgroup$
    – deeenes
    Jul 16, 2020 at 21:59

2 Answers 2


This is a draft answer, if the OP still need needs I will extend it later.

Me too I found the documentation and examples of pyopenms very scarce. At the same time OpenMS is huge, sometimes you find key information not in various other sources instead of the official documentation. This is especially true if it comes to metabolomics.

We built a Python OpenMS lipidomics LC MS/MS preprocessing pipeline, contained in this file: https://github.com/saezlab/lipyd/blob/master/src/lipyd/msproc.py

The top class is the one called MSPreprocess, it implements the workflow, the other classes implement its steps.

Briefly, you start from profile mode mzML files, then

  1. Peak picking with PeakPickerHiRes results centroided data
  2. FeatureFindingMetabo assembles the traces in a metabolomics compatible way
  3. A MapAlignment algorithm alignes the traces across scans
  4. A FeatureGrouping algorithm alignes the features across multiple experiments

Our software mentioned above (lipyd) outputs data frames from the m/z, RT and intensity.

About OpenMS I can recommend to read the C++ code and docs. The Python classes and methods are automatically built minimal wrappers, everything works the same way as in C++.

  • $\begingroup$ Hi, thank you for sharing the link. I will have a look at it. Do you mind sharing what version of pyopenms was used here? $\endgroup$
    – Soren
    Jul 29, 2020 at 3:02
  • $\begingroup$ I only know both openms and pyopenms on my computer are 2.5.0, and I think I haven't updated them since last summer $\endgroup$
    – deeenes
    Jul 29, 2020 at 18:06
  • $\begingroup$ It's hard to understand what is going on and when FeatureFinderMetabo is called and with which arguments. As it is so encapsulated in the method_key wrapper. $\endgroup$
    – Soren
    Aug 31, 2020 at 19:55
  • $\begingroup$ Anyway, it was super helpful. I composed my own answer out of your code, which is more concise. You could comment on that in case I made a mistake or forgot something. $\endgroup$
    – Soren
    Aug 31, 2020 at 22:46

My minimal procedure based on the code that @deeenes shared for a single file. Comments to improve this solution are highly appreciated:

files = list_of_filenames

feature_map = oms.FeatureMap()
mass_traces = []
mass_traces_split = []
mass_traces_filtered  = []

exp = oms.MSExperiment()

options = oms.PeakFileOptions()

fh = oms.MzXMLFile()

# Peak map
peak_map = oms.PeakMap()

file = files[0]

print('# Filename:', basename(file))
fh.load(file, exp)

print('# Spectra:', len( exp.getSpectra() ))
print('# Chromatograms:', len( exp.getChromatograms() ) )

for chrom in exp.getChromatograms():
for spec in exp.getSpectra():

mass_trace_detect = oms.MassTraceDetection()
mass_trace_detect.run(peak_map, mass_traces, 100000)

print('# Mass traces:', len(mass_traces) )

elution_peak_detection = oms.ElutionPeakDetection()
elution_peak_detection.detectPeaks(mass_traces, mass_traces_split)
print('# Mass traces split:', len(mass_traces_split) )

feature_finding_metabo = oms.FeatureFindingMetabo()

print('# Mass traces filtered:', len(mass_traces_filtered) )
print('# Features:', feature_map.size() )

oms.FeatureXMLFile().store('FeatureFindingMetabo.featureXML', feature_map)

# Filename: CA_1.mzXML
# Spectra: 989
# Chromatograms: 0
# Mass traces: 18476
# Mass traces split: 25194
# Mass traces filtered: 0
# Features: 23549

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.