chromatogram,XCMSnExp-method {xcms} | R Documentation |
chromatogram
: the method allows to extract
chromatograms from OnDiskMSnExp
and
XCMSnExp
objects. See also the
chromatogram
implementation for
OnDiskMSnExp
in the MSnbase
package.
## S4 method for signature 'XCMSnExp' chromatogram(object, rt, mz, aggregationFun = "sum", missing = NA_real_, msLevel = 1L, BPPARAM = bpparam(), adjustedRtime = hasAdjustedRtime(object))
object |
Either a |
rt |
|
mz |
|
aggregationFun |
|
missing |
|
msLevel |
|
BPPARAM |
Parallelisation backend to be used, which will
depend on the architecture. Default is
|
adjustedRtime |
For |
Arguments rt
and mz
allow to specify the MS
data slice from which the chromatogram should be extracted.
The parameter aggregationSum
allows to specify the function to be
used to aggregate the intensities across the mz range for the same
retention time. Setting aggregationFun = "sum"
would e.g. allow
to calculate the total ion chromatogram (TIC),
aggregationFun = "max"
the base peak chromatogram (BPC).
The length of the extracted Chromatogram
object,
i.e. the number of available data points, corresponds to the number of
scans/spectra measured in the specified retention time range. If in a
specific scan (for a give retention time) no signal was measured in the
specified mz range, a NA_real_
is reported as intensity for the
retention time (see Notes for more information). This can be changed
using the missing
parameter.
chromatogram
returns a Chromatograms
object with
the number of columns corresponding to the number of files in
object
and number of rows the number of specified ranges (i.e.
number of rows of matrices provided with arguments mz
and/or
rt
).
Chromatogram
objects extracted with
chromatogram
contain NA_real_
values if, for a given retention time, no
signal was measured in the specified mz range. If no spectrum/scan is
present in the defined retention time window a Chromatogram
object
of length 0 is returned.
For XCMSnExp
objects, if adjusted retention times are
available, the chromatogram
method will by default report
and use these (for the subsetting based on the provided parameter
rt
). This can be overwritten with the parameter
adjustedRtime
.
Johannes Rainer
XCMSnExp
for the data object.
Chromatogram
for the object representing
chromatographic data.
Chromatograms
for the object allowing to arrange
multiple Chromatogram
objects.
plot
to plot a Chromatogram
or
Chromatograms
objects.
as
(as(x, "data.frame")
) in MSnbase
for a method to extract the MS data as data.frame
.
## Read some files from the faahKO package. library(xcms) library(faahKO) faahko_3_files <- c(system.file('cdf/KO/ko15.CDF', package = "faahKO"), system.file('cdf/KO/ko16.CDF', package = "faahKO"), system.file('cdf/KO/ko18.CDF', package = "faahKO")) od <- readMSData(faahko_3_files, mode = "onDisk") ## Extract the ion chromatogram for one chromatographic peak in the data. chrs <- chromatogram(od, rt = c(2700, 2900), mz = 335) chrs ## Plot the chromatogram plot(rtime(chrs[1, 2]), intensity(chrs[1, 2]), type = "l", xlab = "rtime", ylab = "intensity", col = "000080") for(i in c(1, 3)) { points(rtime(chrs[1, i]), intensity(chrs[1, i]), type = "l", col = "00000080") } ## Plot the chromatogram using the dedicated plot method. plot(chrs) ## Extract chromatograms for multiple ranges. mzr <- matrix(c(335, 335, 344, 344), ncol = 2, byrow = TRUE) rtr <- matrix(c(2700, 2900, 2600, 2750), ncol = 2, byrow = TRUE) chrs <- chromatogram(od, mz = mzr, rt = rtr) chrs ## Plot the extracted chromatograms plot(chrs) ## Get access to all chromatograms for the second mz/rt range chrs[1, ] ## Plot just that one plot(chrs[1, , drop = FALSE])