Formula annotations class
Source:R/formulas.R, R/formulas-set.R, R/formulas-sirius.R
formulas-class.RdContains data of generated chemical formulae for given feature groups.
Usage
# S4 method for class 'formulas'
annotations(obj, features = FALSE)
# S4 method for class 'formulas'
analyses(obj)
# S4 method for class 'formulas'
defaultExclNormScores(obj)
# S4 method for class 'formulas'
show(object)
# S4 method for class 'formulas,ANY,ANY'
x[[i, j]]
# S4 method for class 'formulas'
delete(obj, i = NULL, j = NULL, ...)
# S4 method for class 'formulas'
as.data.table(
x,
fGroups = NULL,
fragments = FALSE,
countElements = NULL,
countFragElements = NULL,
OM = FALSE,
normalizeScores = "none",
excludeNormScores = defaultExclNormScores(x),
average = FALSE
)
# S4 method for class 'formulas'
annotatedPeakList(
obj,
index,
groupName,
analysis = NULL,
MSPeakLists,
onlyAnnotated = FALSE
)
# S4 method for class 'formulas'
plotSpectrum(
obj,
index,
groupName,
analysis = NULL,
MSPeakLists,
title = NULL,
normalized = "multiple",
specSimParams = getDefSpecSimParams(),
mincex = 0.9,
xlim = NULL,
ylim = NULL,
showLegend = TRUE,
...
)
# S4 method for class 'formulas'
plotScores(
obj,
index,
groupName,
analysis = NULL,
normalizeScores = "max",
excludeNormScores = defaultExclNormScores(obj)
)
# S4 method for class 'formulas'
consensus(
obj,
...,
MSPeakLists,
specSimParams = getDefSpecSimParams(removePrecursor = TRUE),
absMinAbundance = NULL,
relMinAbundance = NULL,
uniqueFrom = NULL,
uniqueOuter = FALSE,
rankWeights = 1,
labels = NULL
)
# S4 method for class 'formulasSet'
show(object)
# S4 method for class 'formulasSet'
delete(obj, i, j, ...)
# S4 method for class 'formulasSet,ANY,missing,missing'
x[i, j, ..., sets = NULL, updateConsensus = FALSE, drop = TRUE]
# S4 method for class 'formulasSet'
filter(obj, ..., sets = NULL, updateConsensus = FALSE, negate = FALSE)
# S4 method for class 'formulasSet'
plotSpectrum(
obj,
index,
groupName,
analysis = NULL,
MSPeakLists,
title = NULL,
normalized = "multiple",
specSimParams = getDefSpecSimParams(),
mincex = 0.9,
xlim = NULL,
ylim = NULL,
showLegend = TRUE,
perSet = TRUE,
mirror = TRUE,
...
)
# S4 method for class 'formulasSet'
annotatedPeakList(obj, index, groupName, analysis = NULL, MSPeakLists, ...)
# S4 method for class 'formulasSet'
consensus(
obj,
...,
MSPeakLists,
specSimParams = getDefSpecSimParams(removePrecursor = TRUE),
absMinAbundance = NULL,
relMinAbundance = NULL,
uniqueFrom = NULL,
uniqueOuter = FALSE,
rankWeights = 1,
labels = NULL,
filterSets = FALSE,
setThreshold = 0,
setThresholdAnn = 0,
setAvgSpecificScores = FALSE
)
# S4 method for class 'formulasSet'
unset(obj, set)
# S4 method for class 'formulasConsensusSet'
unset(obj, set)
# S4 method for class 'formulasSIRIUS'
delete(obj, i = NULL, j = NULL, ...)Arguments
- obj, x, object
The
formulasobject.- features
If
TRUEreturns formula data for features, otherwise for feature groups.- i, j
For
[[: If bothiandjare specified thenispecifies the analysis andjthe feature group of the feature for which annotations should be returned. Otherwiseispecifies the feature group for which group annotations should be returned.i/jcan be specified asintegerindex or as acharactername.Otherwise passed to the
featureAnnotationsmethod.- ...
For
plotSpectrum: Further arguments passed toplot.For
delete: passed to the function specified asj.For
consensus: Any further (and unique)formulasobjects.For sets workflow methods: further arguments passed to the base
formulasmethod.- fGroups, fragments, countElements, countFragElements, OM
Passed to the
featureAnnotationsmethod.- normalizeScores
A
characterthat specifies how normalization of annotation scorings occurs. Either"none"(no normalization),"max"(normalize to max value) or"minmax"(perform min-max normalization). Note that normalization of negative scores (e.g. output bySIRIUS) is always performed as min-max. Furthermore, currently normalization forcompoundstakes the original min/max scoring values into account when candidates were generated. Thus, forcompoundsscoring, normalization is not affected when candidate results were removed after they were generated (e.g. by use offilter).- excludeNormScores
A
charactervector specifying any compound scoring names that should not be normalized. Set toNULLto normalize all scorings. Note that whether any normalization occurs is set by theexcludeNormScoresargument.For
compounds: By defaultscoreandindividualMoNAScoreare set to mimic the behavior of theMetFragweb interface.- average
If set to
TRUEan 'average formula' is generated for each feature group by combining all elements from all candidates and averaging their amounts. This obviously leads to non-existing formulae, however, this data may be useful to deal with multiple candidate formulae per feature group when performing elemental characterization. Setting this toTRUEdisables reporting of most other data.- index
The candidate index (row). For
plotSpectrumtwo indices can be specified to compare spectra. In this casegroupNameandanalysis(if notNULL) should specify values for the spectra to compare.- groupName
The name of the feature group for which a plot should be made. To compare spectra, two group names can be specified.
- analysis
The name of the analysis for which a plot should be made. If
NULLthen data from the feature group averaged peak list is used. When comparing spectra, eitherNULLor the analyses for both spectra should be specified.- MSPeakLists
The
MSPeakListsobject with relevant spectral data.- onlyAnnotated
Set to
TRUEto filter out any peaks that could not be annotated.- title
The title of the plot. If
NULLa title will be automatically made.- normalized
Controls intensity normalization. Should be
FALSE(don't normalize),TRUE(normalize) or"multiple"(only normalizes if multiple spectra are plotted).- specSimParams
A named
listwith parameters that influence the calculation of MS spectra similarities. See the spectral similarity parameters documentation for more details.- mincex
The formula annotation labels are automatically scaled. The
mincexargument forces a minimumcexvalue for readability.- xlim, ylim
Sets the plot size limits used by
plot. Set toNULLfor automatic plot sizing.- showLegend
Set to
TRUEto show a legend.- absMinAbundance, relMinAbundance
Minimum absolute or relative (0-1) abundance across objects for a result to be kept. For instance,
relMinAbundance=0.5means that a result should be present in at least half of the number of compared objects. Set to NULL to ignore and keep all results. Limits cannot be set whenuniqueFromis notNULL.- uniqueFrom
Set this argument to only retain formulas that are unique within one or more of the objects for which the consensus is made. Selection is done by setting the value of
uniqueFromto alogical(values are recycled),numeric(select by index) or acharacter(as obtained withalgorithm(obj)). Forlogicalandnumericvalues the order corresponds to the order of the objects given for the consensus. Set toNULLto ignore.- uniqueOuter
If
uniqueFromis notNULLand ifuniqueOuter=TRUE: only retain data that are also unique between objects specified inuniqueFrom.- rankWeights
A numeric vector with weights of to calculate the mean ranking score for each candidate. The value will be re-cycled if necessary, hence, the default value of 1 means equal weights for all considered objects.
- labels
A
characterwith names to use for labelling. IfNULLlabels are automatically generated.- sets
(sets workflow) A
characterwith name(s) of the sets to keep (or remove ifnegate=TRUE). Note: ifupdateConsensus=FALSEthen thesetCoveragecolumn of the annotation results is not updated.- updateConsensus
(sets workflow) If
TRUEthen the annonation consensus among set results is updated. See theSets workflowssection for more details.- drop
Passed to the
featureAnnotationsmethod.- negate
Passed to the
featureAnnotationsmethod.- perSet, mirror
(sets workflow) If
perSet=TRUEthen the set specific mass peaks are annotated separately. Furthermore, ifmirror=TRUE(and there are two sets in the object) then a mirror plot is generated.- filterSets
(sets workflow) Controls how algorithms concensus abundance filters are applied. See the
Sets workflowssection below.- setThreshold, setThresholdAnn
(sets workflow) Thresholds used to create the annotation set consensus. See
generateFormulas.- setAvgSpecificScores
(sets workflow) If
TRUEthen set specific annotation scores (e.g. MS/MS and isotopic pattern match scores) are averaged for the set consensus. SeegenerateFormulas.- set
(sets workflow) The name of the set.
Value
annotations returns a list containing for each feature
group (or feature if features=TRUE) a data.table
with an overview of all generated formulae and other data such as candidate
scoring and MS/MS fragments.
consensus returns a formulas object that is produced by
merging results from multiple formulas objects.
Details
formulas objects are obtained with generateFormulas. This class is derived from the
featureAnnotations class, please see its documentation for more methods and other details.
Methods (by generic)
annotations(formulas): Accessor method to obtain generated formulae.analyses(formulas): returns acharactervector with the names of the analyses for which data is present in this object.defaultExclNormScores(formulas): Returns default scorings that are excluded from normalization.show(formulas): Show summary information for this object.x[[i: Extracts a formula table, either for a feature group or for features in an analysis.as.data.table(formulas): Generates a table with all candidate formulae for each feature group and other information such as element counts.annotatedPeakList(formulas): Returns an MS/MS peak list annotated with data from a given candidate formula.plotSpectrum(formulas): Plots an annotated spectrum for a given candidate formula of a feature or feature group. Two spectra can be compared by specifying a two-sized vector for theindex,groupNameand (if desired)analysisarguments.plotScores(formulas): Plots a barplot with scoring of a candidate formula.consensus(formulas): Generates a consensus of results from multiple objects. In order to rank the consensus candidates, first each of the candidates are scored based on their original ranking (the scores are normalized and the highest ranked candidate gets value 1). The (weighted) mean is then calculated for all scorings of each candidate to derive the final ranking (if an object lacks the candidate its score will be 0). The original rankings for each object is stored in therankcolumns.
Slots
featureFormulasA
listwith all generated formulae for each analysis/feature group. Use theannotationsmethod for access.setThreshold,setThresholdAnn,setAvgSpecificScores(sets workflow) A copy of the equally named arguments that were passed when this object was created by
generateFormulas.origFGNames(sets workflow) The original (order of) names of the
featureGroupsobject that was used to create this object.MS2QuantMeta(sets workflow) A named
listwith for each set the metadata from MS2Quant filled in bypredictRespFactors.
Source
Subscripting of formulae for plots generated by
plotSpectrum is based on the chemistry2expression function
from the ReSOLUTION package.
Sets workflows
The formulasSet class is applicable for sets workflows. This class is derived from formulas and therefore largely follows the same user interface.
The following methods are specifically defined for sets workflows:
unsetConverts the object data for a specified set into a 'non-set' object (formulasUnset), which allows it to be used in 'regular' workflows. Only the annotation results that are present in the specified set are kept (based on the set consensus, see below for implications).
The following methods are changed or with new functionality:
filterand the subset operator ([) Can be used to select data that is only present for selected sets. Depending on theupdateConsenus, both either operate on set consensus or original data (see below for implications).annotatedPeakListReturns a combined annotation table with all sets.plotSpectrumIs able to highlight set specific mass peaks (perSetandmirrorarguments).consensusCreates the algorithm consensus based on the original annotation data (see below for implications). Then, like the sets workflow method forgenerateFormulas, a consensus is made for all sets, which can be controlled with thesetThresholdandsetThresholdAnnarguments. The candidate coverage among the different algorithms is calculated for each set (e.g.coverage-positivecolumn) and for all sets (coveragecolumn), which is based on the presence of a candidate in all the algorithms from all sets data. Theconsensusmethod for sets workflow data supports thefilterSetsargument. This controls how the algorithm consensus abundance filters (absMinAbundance/relMinAbundance) are applied: iffilterSets=TRUEthen the minimum of allcoverageset specific columns is used to obtain the algorithm abundance. Otherwise the overallcoveragecolumn is used. For instance, consider a consensus object to be generated from two objects generated by different algorithms (e.g.SIRIUSandGenForm), which both have a positive and negative set. Then, if a candidate occurs with both algorithms for the positive mode set, but only with the first algorithm in the negative mode set,relMinAbundance=1will remove the candidate iffilterSets=TRUE(because the minimum relative algorithm abundance is 0.5), whilefilterSets=FALSEwill not remove the candidate (because based on all sets data the candidate occurs in both algorithms).
Two types of annotation data are stored in a formulasSet object:
Annotations that are produced from a consensus between set results (see
generateFormulas).The 'original' annotation data per set, prior to when the set consensus was made. This includes candidates that were filtered out because of the thresholds set by
setThresholdandsetThresholdAnn. However, whenfilteror subsetting ([) operations are performed, the original data is also updated.
In most cases the first data is used. However, in a few cases the original annotation data is used (as indicated
above), for instance, to re-create the set consensus. It is important to realize that the original annotation data
may have additional candidates, and a newly created set consensus may therefore have 'new' candidates. For
instance, when the object consists of the sets "positive" and "negative" and setThreshold=1
was used to create it, then formulas[, sets = "positive", updateConsensus = TRUE] may now have additional
candidates, i.e. those that were not present in the "negative" set and were previously removed due to
the consensus threshold filter.
See also
The featureAnnotations base class for more relevant methods and
generateFormulas.