highlightChromPeaks: Add definition of chromatographic peaks to an extracted...

View source: R/functions-XCMSnExp.R

highlightChromPeaksR Documentation

Add definition of chromatographic peaks to an extracted chromatogram plot

Description

The highlightChromPeaks function adds chromatographic peak definitions to an existing plot, such as one created by the plot method on a Chromatogram or Chromatograms object.

Usage

highlightChromPeaks(x, rt, mz, peakIds = character(),
  border = rep("00000040", length(fileNames(x))), lwd = 1, col = NA,
  type = c("rect", "point", "polygon"), whichPeaks = c("any", "within",
  "apex_within"), ...)

Arguments

x

For highlightChromPeaks: XCMSnExp object with the detected peaks.

rt

For highlightChromPeaks: numeric(2) with the retention time range from which peaks should be extracted and plotted.

mz

numeric(2) with the mz range from which the peaks should be extracted and plotted.

peakIds

character defining the IDs (i.e. rownames of the peak in the chromPeaks table) of the chromatographic peaks to be highlighted in a plot.

border

colors to be used to color the border of the rectangles/peaks. Has to be equal to the number of samples in x.

lwd

numeric(1) defining the width of the line/border.

col

For highlightChromPeaks: color to be used to fill the rectangle (if type = "rect") or the peak (for type = "polygon").

type

the plotting type. See plot in base grapics for more details. For highlightChromPeaks: character(1) defining how the peak should be highlighted: type = "rect" draws a rectangle representing the peak definition, type = "point" indicates a chromatographic peak with a single point at the position of the peak's "rt" and "maxo" and type = "polygon" will highlight the peak shape. For type = "polygon" the color of the border and area can be defined with parameters "border" and "col", respectively.

whichPeaks

character(1) specifying how peaks are called to be located within the region defined by mz and rt. Can be one of "any", "within", and "apex_within" for all peaks that are even partially overlapping the region, peaks that are completely within the region, and peaks for which the apex is within the region. This parameter is passed to the type argument of the chromPeaks function. See related documentation for more information and examples.

...

additional parameters to the matplot or plot function.

Author(s)

Johannes Rainer

Examples


## Read some files from the faahKO package.
library(xcms)
library(faahKO)
faahko_3_files <- c(system.file('cdf/KO/ko16.CDF', package = "faahKO"),
                    system.file('cdf/KO/ko18.CDF', package = "faahKO"))

od <- readMSData(faahko_3_files, mode = "onDisk")

## Peak detection using the 'matchedFilter' method. Note that we are using a
## larger binSize to reduce the runtime of the example.
xod <- findChromPeaks(od, param = MatchedFilterParam(binSize = 0.3, snthresh = 20))

## Extract the ion chromatogram for one chromatographic peak in the data.
chrs <- chromatogram(xod, rt = c(2700, 2900), mz = 335)

plot(chrs)

## Extract chromatographic peaks for the mz/rt range (if any).
chromPeaks(xod, rt = c(2700, 2900), mz = 335)

## Highlight the chromatographic peaks in the area
## Show the peak definition with a rectangle
highlightChromPeaks(xod, rt = c(2700, 2900), mz = 335)

## Color the actual peak
highlightChromPeaks(xod, rt = c(2700, 2900), mz = 335,
    col = c("#ff000020", "#00ff0020"), type = "polygon")

xiaodfeng/DynamicXCMS documentation built on Aug. 6, 2023, 3:02 p.m.