Peak Picking Methods¶
This page highlights the most often used API functionalities and is not complete.
It covers peak picking and chromatogram extraction helpers in emzed.peak_picking.
For complete coverage, see the API Reference.
Core Functions¶
Wrapper around OpenMS FeatureFinderMetabo for MS1 and MS2 workflows.
For MS2, emzed can split by precursors and merge subgroup results.
Precursor splitting groups MSn spectra by their precursor m/z values,
including multiplexed spectra with several precursors per scan. It uses
tolerance binning by default; pass
split_by_precursors_method="clustering" to use complete-linkage clustering.
run_feature_finder_metabo(peak_map, ms_level=None, verbose=True, run_feature_grouper=True, split_by_precursors_mz_tol=0.0, split_by_precursors_method='binning', **parameters)
¶
Run OpenMS FeatureFinderMetabo through the emzed wrapper.
Supports MS1 and MS2-oriented workflows. For MS2, emzed can split by precursor tuples, run per subgroup, and merge results into one table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peak_map
|
input |
required | |
ms_level
|
optional MS level selection (for example |
None
|
|
verbose
|
set to |
True
|
|
run_feature_grouper
|
set to |
True
|
|
split_by_precursors_mz_tol
|
precursor m/z tolerance for MS2
subgrouping. Set to |
0.0
|
|
split_by_precursors_method
|
precursor grouping method,
|
'binning'
|
|
parameters
|
additional OpenMS parameters using the emzed prefixes
|
{}
|
Returns:
| Type | Description |
|---|---|
|
OpenMS parameter references:
|
Run feature finding for all matching files in a folder and save one
*_peaks.table per input file.
run_feature_finder_metabo_on_folder(in_folder, file_patterns=None, out_folder=None, ms_level=None, n_cores=1, verbose=False, run_feature_grouper=True, split_by_precursor_mz_tol=0.0, overwrite=False, split_by_precursor_method='binning', **parameters)
¶
Run run_feature_finder_metabo for matching input files in a folder.
Saves one *_peaks.table result per input file.
MS2-related settings are forwarded unchanged (for example ms_level,
split_by_precursor_mz_tol, and split_by_precursor_method), as well
as all additional **parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_folder
|
input folder, must exist. |
required | |
file_patterns
|
list of file patterns. Defaults to
|
None
|
|
out_folder
|
output folder, created on demand. Default:
|
None
|
|
ms_level
|
optional MS level to use for feature finding. |
None
|
|
n_cores
|
run feature finding on |
1
|
|
verbose
|
set to |
False
|
|
run_feature_grouper
|
also run OpenMS feature grouping. |
True
|
|
split_by_precursor_mz_tol
|
precursor m/z tolerance used to split MS2 spectra before feature finding. |
0.0
|
|
overwrite
|
overwrite existing |
False
|
|
split_by_precursor_method
|
precursor grouping method,
|
'binning'
|
|
parameters
|
additional parameters forwarded to
|
{}
|
Returns:
| Type | Description |
|---|---|
|
|
Extract chromatograms for peak windows from a peak table.
Input rows must provide (with optional postfixes):
mzmin, mzmax, rtmin, rtmax, and peakmap.
extract_chromatograms(peak_table, ms_level=None, post_fixes=None, path=None, overwrite=False)
¶
Extract chromatograms from table with peak map and peak limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peak_table
|
Table with columns |
required | |
ms_level
|
optional MS level to consider. |
None
|
|
post_fixes
|
optional post_fixes to consider. |
None
|
|
path
|
optional path for out-of-memory table. |
None
|
|
overwrite
|
allow overwriting existing out-of-memory table. |
False
|
Returns:
| Type | Description |
|---|---|
|
new table with chromatograms and chromatogram boundaries. |
Extract all MS chromatograms already stored in a PeakMap into a table.
Each output row represents one chromatogram and includes:
peakmap, rtmin_chromatogram, rtmax_chromatogram,
precursor_mz_chromatogram, mz_chromatogram, type, and chromatogram.
Use this when you want table-based processing/filtering of instrument-provided chromatograms (for example SRM/MRM traces) rather than extracting new XICs from spectra windows.
extract_ms_chromatograms(peakmap, path=None)
¶
Export all chromatograms stored in a PeakMap to a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peakmap
|
input |
required | |
path
|
optional output path for out-of-memory table storage. |
None
|
Returns:
| Type | Description |
|---|---|
|
|
Optional XCMS Wrapper¶
The package also exposes an optional XCMS-based wrapper (R backend):
run_feature_finder_centwave(peakmap, ppm=25, peakwidth=(20, 50), prefilter=(3, 100), snthresh=10, integrate=1, mzdiff=-0.001, noise=0, mzCenterFun='wMean', fitgauss=False, msLevel=None, verboseColumns=False, roiList=[], firstBaselineCheck=False, roiScales=[], extendLengthMSW=False, verboseBetaColumns=False)
¶
Run XCMS centWave peak picking through the emzed R connector.
This is an optional wrapper that requires the XCMS R package setup. If XCMS 4 is missing, it is installed automatically on first use. This requires network access, a compiler toolchain and libcurl/OpenSSL/zlib development headers; missing prerequisites are reported together with the matching system install command. Parameters are forwarded to centWave. XCMS project page: https://bioconductor.org/packages/release/bioc/html/xcms.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peakmap
|
input |
required | |
ppm
|
tolerated m/z deviation in ppm. |
25
|
|
peakwidth
|
expected chromatographic peak width range in seconds. |
(20, 50)
|
|
prefilter
|
prefilter tuple used by centWave. |
(3, 100)
|
|
snthresh
|
signal-to-noise threshold. |
10
|
|
integrate
|
integration method setting passed to centWave. |
1
|
|
mzdiff
|
minimum m/z difference for overlapping peaks. |
-0.001
|
|
noise
|
intensity threshold for noise filtering. |
0
|
|
mzCenterFun
|
function name used for m/z center calculation. |
'wMean'
|
|
fitgauss
|
enable Gaussian fitting of chromatographic peaks. |
False
|
|
msLevel
|
optional MS level filter passed to centWave. |
None
|
|
verboseColumns
|
include additional verbose result columns. |
False
|
|
roiList
|
optional predefined ROI list. |
[]
|
|
firstBaselineCheck
|
perform baseline check before ROI extension. |
False
|
|
roiScales
|
optional ROI scales. |
[]
|
|
extendLengthMSW
|
extend wavelet scales for long peaks. |
False
|
|
verboseBetaColumns
|
include additional beta-shape diagnostic columns. |
False
|
Returns:
| Type | Description |
|---|---|
|
|
install_xcms()
¶
Install required R dependencies for XCMS centWave support.
run_feature_finder_centwave calls this automatically when XCMS 4 is
missing, so calling it manually is only needed for pre-provisioning an
environment (e.g. offline setup or CI). It checks for the required build
dependencies first and reports missing system packages with an install
command.
Requires a pre-existing R installation; R itself is not bundled with emzed.