featureChromatograms: Extract ion chromatograms for each feature

Description Usage Arguments Value Author(s) Examples

View source: R/functions-XCMSnExp.R

Description

Extract ion chromatograms for features in an XCMSnExp object. The function returns for each feature its extracted ion chromatogram and all associated peaks with it. The chromatogram is extracted from the m/z - rt region including all chromatographic peaks of that features (i.e. based on the ranges of "mzmin", "mzmax", "rtmin", "rtmax" of all chromatographic peaks of the feature).

By default only chromatographic peaks associated with a feature are included for an extracted ion chromatogram (parameter include = "feature_only"). By setting include = "apex_within" all chromatographic peaks (and eventually the feature which they are part of - if feature definitions are present) that have their apex position within the m/z - rt range from which the chromatogram is extracted are returned too. With include = "any" or include = "all" all chromatographic peaks (and eventually the feature in which they are present) overlapping the m/z and rt range will be returned.

Usage

1
2
3
4
5
6
7
8
9
featureChromatograms(
  x,
  expandRt = 0,
  aggregationFun = "max",
  features,
  include = c("feature_only", "apex_within", "any", "all"),
  filled = FALSE,
  ...
)

Arguments

x

XCMSnExp object with grouped chromatographic peaks.

expandRt

numeric(1) to expand the retention time range for each chromatographic peak by a constant value on each side.

aggregationFun

character(1) specifying the name that should be used to aggregate intensity values across the m/z value range for the same retention time. The default "sum" returns a base peak chromatogram.

features

integer, character or logical defining a subset of features for which chromatograms should be returned. Can be the index of the features in featureDefinitions, feature IDs (row names of featureDefinitions) or a logical vector.

include

character(1) defining which chromatographic peaks (and related feature definitions) should be included in the returned XChromatograms(). Defaults to "feature_only"; See description above for options and details.

filled

logical(1) whether filled-in peaks should be included in the result object. The default is filled = FALSE, i.e. only detected peaks are reported.

...

optional arguments to be passed along to the chromatogram() function.

Value

XChromatograms() object.

Author(s)

Johannes Rainer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(xcms)
library(faahKO)
faahko_3_files <- c(system.file('cdf/KO/ko15.CDF', package = "faahKO"),
                    system.file('cdf/KO/ko18.CDF', package = "faahKO"))

## Do a simple and fast preprocessing on a subset of the test data
od <- filterRt(readMSData(faahko_3_files, mode = "onDisk"), c(250, 3000))
od <- findChromPeaks(od, param = CentWaveParam(peakwidth = c(30, 80),
    noise = 1000, prefilter = c(3, 10000)))
od <- adjustRtime(od, param = ObiwarpParam(binSize = 0.6))
od <- groupChromPeaks(od,
    param = PeakDensityParam(minFraction = 0.8, sampleGroups = rep(1, 2)))

## Get the feature definitions
featureDefinitions(od)

## Extract ion chromatograms for the first 3 features. Parameter
## `features` can be either the feature IDs or feature indices.
chrs <- featureChromatograms(od, features = 1:3)

## Plot the XIC for the first feature using different colors for each file
par(mfrow = c(1, 2))
plot(chrs[1, ], col = c("red", "green"))

yclement/xcms documentation built on April 10, 2020, 12:08 a.m.