Several utility functions to work with adducts.
Usage
GenFormAdducts()
MetFragAdducts()
as.adduct(
x,
format = "generic",
isPositive = NULL,
charge = NULL,
adductInfo = NULL,
err = TRUE
)
calculateIonFormula(formula, adduct)
calculateNeutralFormula(formula, adduct)Arguments
- x
The object that should be converted. Should be a
characterstring, anumericMetFragadduct identifier (adduct_modecolumn obtained withMetFragAdducts) or anadductobject (in which case no conversion occurs).- format
A
characterthat specifies the source format."generic"is an internally used generic format that supports full textual conversion. Examples:"[M+H]+","[2M+H]+","[M+3H]3+"."sirius"Is the format used bySIRIUS. It is similar togenericbut does not allow multiple charges/molecules. See the SIRIUS manual for more details."genform"and"metfrag"support fixed types of adducts which can be obtained with theGenFormAdductsandMetFragAdductsfunctions, respectively."openms"is the format used by theMetaboliteAdductDechargertool."cliquems"is the format used by cliqueMS."nontarget"is the format used by nontarget/enviPat and requiresadductInfoto be set.- isPositive
A logical that specifies whether the adduct should be positive. Should only be set when
format="metfrag"andxis anumericidentifier.- charge
The final charge. Only needs to be set when
format="openms".- adductInfo
A
data.framewith adduct info from e.g. enviPat::adducts. Only needs to be set whenformat="nontarget".- err
If
TRUEthen an error will be thrown if conversion fails, otherwise returns without data.- formula
A
charactervector with formulae to convert.- adduct
An
adductobject (or something that can be converted to it withas.adduct). Examples:"[M-H]-","[M+Na]+".
Details
GenFormAdducts returns a table with information on adducts
supported by GenForm.
MetFragAdducts returns a table with information on adducts
supported by MetFrag.
as.adduct Converts an object in to an adduct
object.
calculateIonFormula Converts one or more neutral formulae to
adduct ions.
calculateNeutralFormula Converts one or more adduct ions to
neutral formulae.
Examples
as.adduct("[M+H]+")
as.adduct("[M+H2]2+")
as.adduct("[2M+H]+")
as.adduct("[M-H]-")
as.adduct("+H", format = "genform")
as.adduct(1, isPositive = TRUE, format = "metfrag") # MetFrag adduct ID 1 --> returns [M+H]+
calculateIonFormula("C2H4O", "[M+H]+") # C2H5O
calculateNeutralFormula("C2H5O", "[M+H]+") # C2H4O