This function performs an automated mass recalibration for peak lists using predefined or user-specified calibrant lists.
Calibration can be based on existing calibrant tables included in ume::known_mf
(via the calibr_list argument) or on a user-provided set of molecular formulas
(custom_calibr_list).
The function assigns calibrant peaks to each spectrum and evaluates their mass accuracy. Three independent outlier tests are applied to the assigned calibrants, and only those that pass all tests are used to calculate the recalibration model.
Recalibration is performed using a linear model (m ~ m_cal), and spectra with
insufficient calibrant matches can be either excluded or corrected using
extrapolated calibration parameters.
calc_recalibrate_ms(
pl,
col_spectrum_id = "file_id",
calibr_list = c("cal_fa_neg", "cal_marine_dom_neg", "calibration", "marine_dom",
"cal_marine_dom_pos", "cal_marine_pw_neg", "cal_SRFA_neg", "cal_SRFA_OL_neg",
"E_coli_metabolome", "Post-column standard"),
custom_calibr_list = NULL,
min_no_calibrants = 1,
outlier_removal = TRUE,
insufficient_calibrants = c("extrapolate", "remove_spectrum"),
verbose = FALSE,
pol = c("neg", "pos", "neutral"),
ma_dev,
...
)A list containing:
plRecalibrated peaklist.
checkSummary of the number of calibrants per spectrum.
cal_peaksAssigned calibrant peaks and recalibration results.
cal_statsCalibration statistics (slopes, intercepts, accuracy metrics).
fig_*Interactive plotly figures comparing mass accuracy before and after recalibration.
data.table containing peak data. Mandatory columns include neutral
molecular mass (mass), peak magnitude (i_magnitude), and a peak
identifier (peak_id).
Character. Name of the column that identifies individual
spectra or samples (default: "file_id"). The peaklist must also contain a
column named "mass".
Character string. Name of a predefined calibrant list stored in
ume::known_mf (column category). Ignored if custom_calibr_list is provided.
Character vector. Custom list of molecular formulas to be used as calibrants instead of a predefined list.
Integer. Minimum number of calibrant peaks required per
spectrum to perform recalibration (default: 3). If fewer calibrants are found,
recalibration is skipped or handled according to insufficient_calibrants.
Logical. If TRUE (default), mass-accuracy-based outlier
detection is applied to the calibrants within each spectrum before recalibration.
Character. Defines how spectra with too few calibrants are handled:
"extrapolate"Apply the median calibration slope and intercept from spectra with at least two calibrants (default).
"remove_spectrum"Remove spectra for which no calibrant peaks were identified.
logical; if TRUE, show progress messages.
Arguments passed on to assign_formulas, calc_neutral_mass, calc_ma_abs
formula_libraryMolecular formula library: a predefined data.table used for
assigning molecular formulas to a peak list and for mass calibration. The library
requires a fixed format, including mass values for matching. Predefined libraries
are available in the R package ume.formulas and further described in
Leefmann et al. (2019). A standard library for marine dissolved organic matter is
ume.formulas::lib_02. New libraries can be built using
ume::create_ume_formula_library().
mzNumeric vector of m/z values (> 0).
polCharacter: "neg", "pos", or "neutral".
mMeasured mass
ma_devMass accuracy in +/- parts per million (ppm)
Boris P. Koch
Recalibration is based on a linear fit (lm(m ~ m_cal)), with slopes and intercepts
computed individually for each spectrum. Optionally, spectra without sufficient
calibrants can be corrected using median calibration parameters derived from
other spectra.
Other calculations:
calc_data_summary(),
calc_dbe(),
calc_eval_params(),
calc_exact_mass(),
calc_ideg(),
calc_ma(),
calc_neutral_mass(),
calc_nm(),
calc_norm_int(),
calc_number_assignment(),
calc_number_occurrence()