featureChromatograms | R Documentation |
Extract ion chromatograms for features in an XcmsExperiment or
XCMSnExp object. The function returns for each feature the
extracted ion chromatograms (along with all associated chromatographic
peaks) in each sample. The chromatogram is extracted from the m/z - rt
region that includes all chromatographic peaks of a feature. By default,
this region is defined using the range of the chromatographic peaks' m/z
and retention times (with mzmin = min
, mzmax = max
, rtmin = min
and
rtmax = max
). For some features, and depending on the data, the m/z and
rt range can thus be relatively large. The boundaries of the m/z - rt
region can also be restricted by changing parameters mzmin
, mzmax
,
rtmin
and rtmax
to a different functions, such as median
.
By default only chromatographic peaks associated with a feature are
included in the returned XChromatograms object. For object
being an
XCMSnExp
object parameter include
allows also to return all
chromatographic peaks with their apex position within the selected
region (include = "apex_within"
) or any chromatographic peak overlapping
the m/z and retention time range (include = "any"
).
featureChromatograms(object, ...)
## S4 method for signature 'XcmsExperiment'
featureChromatograms(
object,
expandRt = 0,
expandMz = 0,
aggregationFun = "max",
features = character(),
return.type = "XChromatograms",
chunkSize = 2L,
mzmin = min,
mzmax = max,
rtmin = min,
rtmax = max,
...,
progressbar = TRUE,
BPPARAM = bpparam()
)
## S4 method for signature 'XCMSnExp'
featureChromatograms(
object,
expandRt = 0,
aggregationFun = "max",
features,
include = c("feature_only", "apex_within", "any", "all"),
filled = FALSE,
n = length(fileNames(object)),
value = c("maxo", "into"),
expandMz = 0,
...
)
object |
|
... |
optional arguments to be passed along to the |
expandRt |
|
expandMz |
|
aggregationFun |
|
features |
|
return.type |
|
chunkSize |
For |
mzmin |
|
mzmax |
|
rtmin |
|
rtmax |
|
progressbar |
|
BPPARAM |
For |
include |
Only for |
filled |
Only for |
n |
Only for |
value |
Only for |
XChromatograms()
object. In future, depending on parameter
return.type
, the data might be returned as a different object.
The EIC data of a feature is extracted from every sample using the same
m/z - rt area. The EIC in a sample does thus not exactly represent the
signal of the actually identified chromatographic peak in that sample.
The chromPeakChromatograms()
function would allow to extract the actual
EIC of the chromatographic peak in a specific sample. See also examples
below.
Parameters include
, filled
, n
and value
are only supported
for object
being an XCMSnExp
.
When extracting EICs from only the top n
samples it can happen that one
or more of the features specified with features
are dropped because they
have no detected peak in the top n samples. The chance for this to happen
is smaller if x
contains also filled-in peaks (with fillChromPeaks
).
Johannes Rainer
filterColumnsKeepTop()
to filter the extracted EICs keeping only
the top n columns (samples) with the highest intensity.
chromPeakChromatograms()
for a function to extract an EIC for each
chromatographic peak.
## Load a test data set with detected peaks
library(xcms)
library(MsExperiment)
faahko_sub <- loadXcmsData("faahko_sub2")
## Disable parallel processing for this example
register(SerialParam())
## Perform correspondence analysis
xdata <- groupChromPeaks(faahko_sub,
param = PeakDensityParam(minFraction = 0.8, sampleGroups = rep(1, 3)))
## Get the feature definitions
featureDefinitions(xdata)
## Extract ion chromatograms for the first 3 features. Parameter
## `features` can be either the feature IDs or feature indices.
chrs <- featureChromatograms(xdata,
features = rownames(featureDefinitions)[1:3])
## Plot the EIC for the first feature using different colors for each file.
plot(chrs[1, ], col = c("red", "green", "blue"))
## The EICs for all 3 samples use the same m/z and retention time range,
## which was defined using the `featureArea` function:
featureArea(xdata, features = rownames(featureDefinitions(xdata))[1:3],
mzmin = min, mzmax = max, rtmin = min, rtmax = max)
## To extract the actual (exact) EICs for each chromatographic peak of
## a feature in each sample, the `chromPeakChromatograms` function would
## need to be used instead. Below we extract the EICs for all
## chromatographic peaks of the first feature. We need to first get the
## IDs of all chromatographic peaks assigned to the first feature:
peak_ids <- rownames(chromPeaks(xdata))[featureDefinitions(xdata)$peakidx[[1L]]]
## We can now pass these to the `chromPeakChromatograms` function with
## parameter `peaks`:
eic_1 <- chromPeakChromatograms(xdata, peaks = peak_ids)
## To plot these into a single plot we need to use the
## `plotChromatogramsOverlay` function:
plotChromatogramsOverlay(eic_1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.