% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions-XCMSnExp.R
\name{featureChromatograms}
\alias{featureChromatograms}
\title{Extract ion chromatograms for each feature}
\usage{
featureChromatograms(x, expandRt = 0, aggregationFun = "max", features,
  include = c("feature_only", "all"), filled = FALSE, ...)
}
\arguments{
\item{x}{\code{XCMSnExp} object with grouped chromatographic peaks.}

\item{expandRt}{\code{numeric(1)} to expand the retention time range for each
chromatographic peak by a constant value on each side.}

\item{aggregationFun}{\code{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 \code{"sum"} returns a base peak
chromatogram.}

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

\item{include}{\code{character(1)} defining which chromatographic peaks and
feature definitions should be included in the returned
\code{\link[=XChromatograms]{XChromatograms()}}. See description above for details.}

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

\item{...}{optional arguments to be passed along to the \code{\link[=chromatogram]{chromatogram()}}
function.}
}
\value{
\code{\link[=XChromatograms]{XChromatograms()}} object.
}
\description{
Extract ion chromatograms for features in an \linkS4class{XCMSnExp} object. The
function returns for each feature its extracted ion chromatogram and all
associated peaks with it.

By default only chromatographic peaks associated with a feature are included
for an extracted ion chromatogram. Setting \code{include = "all"} (instead of
the default \code{include = "feature_only"}) will return all chromatographic peaks
identified in the m/z - rt data slice of a feature (and eventually also other
features within that region).
}
\examples{

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"))

## 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))
od <- adjustRtime(od, param = ObiwarpParam(binSize = 0.6))
od <- groupChromPeaks(od,
    param = PeakDensityParam(minFraction = 0.8, sampleGroups = rep(1, 3)))

## Extract ion chromatograms for each feature
chrs <- featureChromatograms(od)

## 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", "blue"))
}
\author{
Johannes Rainer
}
