Creates a character vector of molecular formulas and adds it as a column to the input data.table.
The molecular formula string follows the Hill system order for element arrangement.
If keep_element_sums == TRUE, a data.table is returned that also provides
the sum of atoms of each element in the molecular formula.
convert_data_table_to_molecular_formulas(
mfd,
isotope_formulas = FALSE,
keep_element_sums = FALSE,
verbose = FALSE,
...
)The original table mfd as data.table having additional columns:
Standardized molecular formula following the Hill order.
If isotope_formulas = TRUE:
Standardized molecular formula considering all isotopes of an element.
If keep_element_sums = TRUE:
The total count of all atoms that are carbon isotopes (similar for all other elements.
data.table with molecular formula data as derived from
ume::assign_formulas. Column names of elements/isotopes must match names in
the isotope column of ume::masses; values are integers representing
counts per formula.
Logical. If TRUE the output table will have an additional
molecular formula string that includes isotope information (e.g. "[12C5][13C1][1H12][16O6]")
description. If TRUE the output table will have
additional columns containing the total count of atoms of an element (e.g. S_tot).
logical; if TRUE, show progress messages.
Additional arguments passed to methods.
The function correctly handles isotopic notations such as [13C] and [18O2].
The output follows the Hill order, meaning C, H first, followed by other elements in alphabetical order.
Single-element counts (e.g., C1H4 → CH4) are formatted without explicit 1.
This function extracts element or isotope counts from a table with columns for each element of a molecular formula,
including those with isotopic notation.
It ensures that only valid elements are included based on a reference table (masses).
The function internally uses the ume::masses table that contains element and isotopic symbols.
Other molecular formula functions:
convert_molecular_formula_to_data_table()
convert_data_table_to_molecular_formulas(mf_data_demo[, .(`12C`, `1H`, `14N`, `16O`, `31P`, `32S`)])
Run the code above in your browser using DataLab