| Title: | Centroid Profile Mass Spectrometry Data |
|---|---|
| Description: | CentroidR provides the infrastructure to centroid profile mass spectrometry spectra (mzML) with independent MS1 and MS2 tolerances, 1D Morse-Smale topological prominence valley splitting, weighted log-quadratic Gaussian and power-weighted m/z centroiding, overlapping multiplet deconvolution, and analyzer-specific m/z domain scaling. |
| Authors: | Adriano Rutz [aut, cre] (ORCID: <https://orcid.org/0000-0003-0443-9902>), Johannes Rainer [aut] (ORCID: <https://orcid.org/0000-0002-6977-7147>) |
| Maintainer: | Adriano Rutz <[email protected]> |
| License: | AGPL (>= 3) |
| Version: | 0.0.0.9005 |
| Built: | 2026-11-20 22:55:24 UTC |
| Source: | https://github.com/adafede/CentroidR |
Processes an mzML file containing profile-mode mass spectra and writes centroided MS1 and MS2 spectra to a new mzML file.
centroid_one_file( file, pattern, replacement, min_datapoints_ms1 = 5L, min_datapoints_ms2 = 1L, mz_tol_da_ms1 = 0.0025, mz_tol_da_ms2 = 0.0025, mz_tol_ppm_ms1 = 5, mz_tol_ppm_ms2 = 5, mz_fun_ms1 = base::mean, mz_fun_ms2 = base::mean, int_fun_ms1 = base::max, int_fun_ms2 = base::max, mz_weighted = TRUE, time_domain = TRUE, intensity_exponent = 3, centroid_method = c("weighted", "gaussian", "func"), intensity_method = c("func", "gaussian_apex", "gaussian_area", "trapezoid"), deconvolve = FALSE, valley_ratio = 0.2, valley_hws = 2L, baseline_subtract = FALSE, domain_scaling = c("legacy", "linear", "tof", "orbitrap", "fticr"), mz_ref = 100 )centroid_one_file( file, pattern, replacement, min_datapoints_ms1 = 5L, min_datapoints_ms2 = 1L, mz_tol_da_ms1 = 0.0025, mz_tol_da_ms2 = 0.0025, mz_tol_ppm_ms1 = 5, mz_tol_ppm_ms2 = 5, mz_fun_ms1 = base::mean, mz_fun_ms2 = base::mean, int_fun_ms1 = base::max, int_fun_ms2 = base::max, mz_weighted = TRUE, time_domain = TRUE, intensity_exponent = 3, centroid_method = c("weighted", "gaussian", "func"), intensity_method = c("func", "gaussian_apex", "gaussian_area", "trapezoid"), deconvolve = FALSE, valley_ratio = 0.2, valley_hws = 2L, baseline_subtract = FALSE, domain_scaling = c("legacy", "linear", "tof", "orbitrap", "fticr"), mz_ref = 100 )
file |
character(1). Path to the input mzML file ( |
pattern |
character(1). Regular expression pattern to match in the input file path, used for modifying the output file path. |
replacement |
character(1). Replacement string for altering the output
file path based on the |
min_datapoints_ms1 |
integer(1). Minimum datapoints to be considered for MS1 data. Must be at least 1. Default: 5L. |
min_datapoints_ms2 |
integer(1). Minimum datapoints to be considered for MS2 data. Must be at least 1. Default: 1L. |
mz_tol_da_ms1 |
numeric(1). m/z tolerance in Daltons for MS1 data. Default: 0.0025. |
mz_tol_da_ms2 |
numeric(1). m/z tolerance in Daltons for MS2 data. Default: 0.0025. |
mz_tol_ppm_ms1 |
numeric(1). m/z tolerance in parts per million (ppm) for MS1. Default: 5. |
mz_tol_ppm_ms2 |
numeric(1). m/z tolerance in parts per million (ppm) for MS2. Default: 5. |
mz_fun_ms1 |
function. Function to aggregate m/z values within each
peak group (MS1). Ignored if |
mz_fun_ms2 |
function. Function to aggregate m/z values within each
peak group (MS2). Ignored if |
int_fun_ms1 |
function. Function to aggregate peak intensities within each peak group (MS1). Default: base::max. |
int_fun_ms2 |
function. Function to aggregate peak intensities within each peak group (MS2). Default: base::max. |
mz_weighted |
logical(1). If |
time_domain |
logical(1). If |
intensity_exponent |
numeric(1). If |
centroid_method |
character(1). Mathematical estimator for peak m/z
when |
intensity_method |
character(1). Mathematical estimator for peak
abundance: |
deconvolve |
logical(1). If |
valley_ratio |
numeric(1). Maximum ratio of valley intensity to the
topological basin barrier height (1D Morse-Smale persistence) at which a
group is split into separate peaks. Must be in |
valley_hws |
integer(1). Half-window size for local maxima detection during valley splitting. Must be at least 1. Default: 2L. |
baseline_subtract |
logical(1). If |
domain_scaling |
character(1). Mass analyzer spacing scaling model used
when grouping adjacent profile points: |
mz_ref |
numeric(1). Reference m/z (in Daltons) at which |
MS1 and MS2 spectra are processed separately with their own tolerances so
the two levels can be tuned independently. Spectra of any other msLevel
(such as MS3+) are preserved unmodified with their original centroided
flag, and all spectra retain their original chronological scan acquisition
order in the exported mzML.
Within a spectrum, profile points are first grouped by m/z tolerance using
either the legacy sqrt(mz) transformation (domain_scaling = "legacy") or
an exact local Jacobian analyzer spacing law (domain_scaling in "linear",
"tof", "orbitrap", or "fticr"). Each group is then recursively split at
deep valleys evaluated via 1D Morse-Smale topological basin prominence
(valley_ratio, valley_hws, and optional baseline_subtract) so that
closely spaced peaks are not merged even when small noise ripples sit inside
a valley.
Peak centroids are estimated via power-weighted mean (centroid_method = "weighted"), apex-centered weighted log-quadratic Guo-Caruana Gaussian
fitting (centroid_method = "gaussian"), or custom aggregation ("func"),
while peak abundances can be reported via int_fun_ms* (intensity_method = "func"), interpolated Gaussian apex ("gaussian_apex"), analytical Gaussian
area ("gaussian_area"), or numerical trapezoidal integration
("trapezoid"). Setting deconvolve = TRUE performs 2-pass Gauss-Seidel
Gaussian tail subtraction across split sub-peaks prior to centroid and
intensity estimation.
A group is only reduced when it holds at least min_datapoints_ms* points of
non-zero intensity; below that it is reported as zero intensity and filtered
out. Spectra left without any peak by this step are restored from the input,
so no spectrum is lost.
File path modifications are supported via pattern and replacement.
pattern is a regular expression, as in sub().
logical(1). TRUE if the file was centroided, or TRUE if it was
skipped because the output file already existed; FALSE if the input was
missing, if pattern/replacement resolved to the input file itself
(preventing in-place overwrite), or if centroiding failed. Invalid argument
types raise an error instead of returning FALSE.
Topics: http://edamontology.org/topic_3172 (Metabolomics),
http://edamontology.org/topic_0153 (Lipids),
http://edamontology.org/topic_0154 (Small molecules),
http://edamontology.org/topic_3370 (Analytical chemistry)
Operations: http://edamontology.org/operation_3215 (Peak detection /
Peak picking / Centroiding), http://edamontology.org/operation_3214
(Spectral analysis), http://edamontology.org/operation_3695
(Data filtering)
Input/Output Data: http://edamontology.org/data_0943 (Mass spectrum),
http://edamontology.org/data_2536 (Mass spectrometry data)
Input/Output Format: http://edamontology.org/format_3244 (mzML)
Johannes Rainer, Adriano Rutz
## Not run: # Example usage (requires an mzML file): # centroid_one_file( # file = "raw_data.mzML", # pattern = "\.mzML$", # replacement = "_centroided.mzML", # min_datapoints_ms1 = 5L, # min_datapoints_ms2 = 1L # ) ## End(Not run)## Not run: # Example usage (requires an mzML file): # centroid_one_file( # file = "raw_data.mzML", # pattern = "\.mzML$", # replacement = "_centroided.mzML", # min_datapoints_ms1 = 5L, # min_datapoints_ms2 = 1L # ) ## End(Not run)