View source: R/assign_formulas.R
| assign_formulas | R Documentation |
Assigns molecular formulas to molecular masses using a predefined library.
Input of the peaklist (pl) is internally checked as_peaklist(),
converted to neutral masses calc_neutral_mass(), and assigned with
molecular formulas based on the mass accuracy (ma_dev) provided calc_ma_abs().
The input can be either:
A peaklist (data.table) containing m/z values or neutral masses
and additional metadata
.
A numeric vector of m/z values or neutral masses without additional metadata
(internally checked and standardized by as_peaklist()).
assign_formulas(pl, formula_library, verbose = FALSE, ...)
pl |
Either a peaklist ( |
formula_library |
Molecular 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
|
verbose |
logical; if |
... |
Arguments passed on to
|
This function calculates the neutral mass of peaks in pl and
compares it to mass values in formula_library, assigning molecular formulas
based on mass accuracy thresholds. If 13C, 15N, or 34S isotope information
is missing, additional columns are added to the output table.
A data.table where each row represents a molecular formula assigned to a
mass peak. The table contains:
All columns of the input peaklist pl (e.g. mz, i_magnitude, file_id).
All columns of the input formula_library (e.g. mf, element counts).
Calculated columns:
m — neutral mass.
m_cal — exact mass of the assigned formula.
del — absolute mass error (Da).
ppm — mass error in parts per million.
mf_id — unique ID for each (file_id, mf) combination.
Added isotope columns (13C, 15N, 34S) if missing in the library.
One peak may receive zero, one, or multiple assigned formulas depending on the mass accuracy threshold.
Boris P. Koch
# Example using demo data
assign_formulas(pl = peaklist_demo,
formula_library = ume::lib_demo,
pol = "neg",
ma_dev = 0.2,
verbose = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.