Write adduct hypotheses as CAMERA-style text
Source:R/AllGenerics.R, R/methods-numeric.R, R/methods-XcmsExperiment.R
formatAdducts.RdformatAdducts() writes the nBest most plausible hypotheses of each
feature as text, best first, in CAMERA's format
("[M+H]+ 169.037 [M+Na]+ 146.048").
Usage
formatAdducts(object, ...)
# S4 method for class 'data.frame'
formatAdducts(object, nBest = 3, nFeatures = max(object$feature, 0L), ...)
# S4 method for class 'XcmsExperiment'
formatAdducts(object, nBest = 3, ...)Arguments
- object
A
data.frameof hypotheses as returned by thenumericmethod ofannotateAdducts(), or an annotated xcms::XcmsExperiment.- ...
ignored.
- nBest
numeric(1)number of hypotheses per feature;Inffor all.- nFeatures
integer(1), for thedata.framemethod only: the total number of features (length of the result).
Value
For the data.frame method a character vector with one entry
per feature ("" without hypotheses). For the XcmsExperiment method
the object with a rewritten adduct column; nothing is recomputed.
Examples
mz <- c(124.0392, 152.0342, 170.0445, 192.0275, 377.0300)
hints <- annotateAdducts(mz, AdductVoteParam(),
intensity = c(81, 50, 100, 11, 2),
groups = rep("FG.1", 5))
formatAdducts(hints, nBest = 1, nFeatures = 5)
#> [1] "[M+H-HCOOH]+ 169.037" "[M+H-H2O]+ 169.037" "[M+H]+ 169.037"
#> [4] "[M+Na]+ 169.037" "[2M+K]+ 169.037"