Extract the peak area (defined by the m/z and retention time range) of chromatographic peaks. The chromatographic peaks can be defined by their ID (i.e. rownames of the chromPeaks matrix) or by m/z and a retention times.

The function identifies first chromatographic peaks in x that match the input parameters mz and rt or peakId and then defines the m/z and rt range based on the "mzmin", "mzmax", "rtmin" and "rtmax" of these. If m/z and rt ranges are provided, only chromatographic peaks are considered that have their apex within the region.

As a result a matrix is returned with columns "mzmin", "mzmax", "rtmin" and "rtmax" defining the lower and upper boundaries of the region of the peaks. Each row in this matrix represent the result for one element in the input parameter specifying the peaks of interest (e.g. mz, rt or peakId).

chromPeakArea(
  x,
  mz = numeric(),
  rt = numeric(),
  diffRt = 40,
  ppm = 50,
  peakId = character()
)

Arguments

x

XCMSnExp object with identified chromatographic peaks.

mz

numeric or matrix with m/z values to identify chromatographic peaks from which regions should be extracted. If a matrix is provided it is expeted to have 2 columns with the lower and upper m/z boundary. If a numeric is provided parameter ppm is also considered.

rt

numeric or matrix with retention time values to identify chromatographic peaks from which the peak areas are supposed to be defined. If a matrix is provided it is expected to be a two column matrix with the lower and upper rt boundary in which chromatographic peaks should be found. If a numeric is provided, parameter diffRt is considered to define the rt region to search for peaks.

diffRt

numeric(1) to define the rt region in which peaks should be identified if a numeric is provided with parameter rt. The rt region is defined as rt - diffRt to rt + diffRt.

ppm

numeric(1) to define the m/z region in which peaks should be identified if mz is a numeric. The m/z region is defined as mz - ppm(mz, ppm) to mz + ppm(mz, ppm)

peakId

character with the IDs of the chromatographic peaks (i.e. rownames of chromPeaks(object)).

Value

matrix with columnd "mzmin", "mzmax", "rtmin", "rtmax" with the m/z and retention time ranges calculated on all chromatographic peaks in x matching mz and rt. Each row representing the result for each value in mz and rt.

Author

Johannes Rainer

Examples

#> Loading required package: xcms
#> Loading required package: BiocParallel
#> Loading required package: MSnbase
#> Loading required package: BiocGenerics
#> Loading required package: parallel
#> #> Attaching package: ‘BiocGenerics’
#> The following objects are masked from ‘package:parallel’: #> #> clusterApply, clusterApplyLB, clusterCall, clusterEvalQ, #> clusterExport, clusterMap, parApply, parCapply, parLapply, #> parLapplyLB, parRapply, parSapply, parSapplyLB
#> The following objects are masked from ‘package:stats’: #> #> IQR, mad, sd, var, xtabs
#> The following objects are masked from ‘package:base’: #> #> anyDuplicated, append, as.data.frame, basename, cbind, colnames, #> dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep, #> grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget, #> order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank, #> rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply, #> union, unique, unsplit, which.max, which.min
#> Loading required package: Biobase
#> Welcome to Bioconductor #> #> Vignettes contain introductory material; view with #> 'browseVignettes()'. To cite Bioconductor, see #> 'citation("Biobase")', and for packages 'citation("pkgname")'.
#> Loading required package: mzR
#> Loading required package: Rcpp
#> Loading required package: S4Vectors
#> Loading required package: stats4
#> #> Attaching package: ‘S4Vectors’
#> The following objects are masked from ‘package:base’: #> #> expand.grid, I, unname
#> Loading required package: ProtGenerics
#> #> Attaching package: ‘ProtGenerics’
#> The following object is masked from ‘package:stats’: #> #> smooth
#> #> This is MSnbase version 2.17.8 #> Visit https://lgatto.github.io/MSnbase/ to get started.
#> #> Attaching package: ‘MSnbase’
#> The following object is masked from ‘package:base’: #> #> trimws
#> #> This is xcms version 3.13.5
#> #> Attaching package: ‘xcms’
#> The following object is masked from ‘package:stats’: #> #> sigma
fls <- c(system.file('cdf/KO/ko15.CDF', package = "faahKO"), system.file('cdf/KO/ko16.CDF', package = "faahKO"), system.file('cdf/WT/wt19.CDF', package = "faahKO")) od <- readMSData(fls, mode = "onDisk")
#> Polarity can not be extracted from netCDF files, please set manually the polarity with the 'polarity' method.
xod <- findChromPeaks( od, param = CentWaveParam(noise = 10000, snthresh = 40, prefilter = c(3, 10000)))
#> Detecting mass traces at 25 ppm ...
#> OK
#> Detecting chromatographic peaks in 937 regions of interest ...
#> OK: 87 found.
#> Detecting mass traces at 25 ppm ...
#> OK
#> Detecting chromatographic peaks in 1025 regions of interest ...
#> OK: 100 found.
#> Detecting mass traces at 25 ppm ...
#> OK
#> Detecting chromatographic peaks in 623 regions of interest ...
#> OK: 71 found.
chromPeakArea(xod, rt = c(2500, 2700), diffRt = 100, mz = cbind(c(400, 300), c(500, 400)))
#> mzmin mzmax rtmin rtmax #> [1,] 453.2 476.2 2501.378 2632.834 #> [2,] 301.0 384.1 2592.145 2819.063