% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions-XCMSnExp.R
\name{reconstructChromPeakSpectra}
\alias{reconstructChromPeakSpectra}
\title{Data independent acquisition (DIA): reconstruct MS2 spectra}
\usage{
reconstructChromPeakSpectra(object, expandRt = 1, diffRt = 2,
  minCor = 0.8, intensity = "maxo",
  peakId = rownames(chromPeaks(object, msLevel = 1L)),
  BPPARAM = bpparam())
}
\arguments{
\item{object}{\code{XCMSnExp} with identified chromatographic peaks.}

\item{expandRt}{\code{numeric(1)} allowing to expand the retention time range
for extracted ion chromatograms by a constant value (for the peak
shape correlation).}

\item{diffRt}{\code{numeric(1)} defining the maximal allowed difference between
the retention time of the chromatographic peak (apex) and the retention
times of MS2 chromatographic peaks (apex) to consider them as
representing candidate fragments of the original ion.}

\item{minCor}{\code{numeric(1)} defining the minimal required correlation
coefficient for MS2 chromatographic peaks to be considered for MS2
spectrum reconstruction.}

\item{intensity}{\code{character(1)} defining the column in the \code{chromPeaks}
matrix that should be used for the intensities of the reconstructed
spectra's peaks.}

\item{peakId}{optional \code{character} vector with peak IDs (i.e. rownames of
\code{chromPeaks}) of MS1 peaks for which MS2 spectra should be reconstructed.
By default they are reconstructed for all MS1 chromatographic peaks.}

\item{BPPARAM}{parallel processing setup. See \code{\link[=bpparam]{bpparam()}} for more
information.}
}
\value{
\code{\link[=Spectra]{Spectra()}} with the reconstructed MS2 spectra for all MS1 peaks
in \code{object}. Contains empty \linkS4class{Spectrum2} objects for MS1 peaks for
which reconstruction was not possible (either no MS2 signal was recorded
or the correlation of the MS2 chromatographic peaks with the MS1
chromatographic peak was below threshold \code{minCor}. \code{Spectra} metadata
columns \code{"ms2_peak_id"} and \code{"ms2_peak_cor"} (of type \code{\link[=CharacterList]{CharacterList()}}
and \code{\link[=NumericList]{NumericList()}} with length equal to the number of peaks per
reconstructed MS2 spectrum) providing the IDs and the correlation of the
MS2 chromatographic peaks from which the MS2 spectrum was reconstructed.
}
\description{
Reconstructs MS2 spectra for each MS1 chromatographic peak (if possible) for
data independent acquisition (DIA) data (such as SWATH). See the
\emph{LC-MS/MS analysis} vignette for more details and examples.
}
\details{
In detail, the function performs for each MS1 chromatographic peak:
\itemize{
\item Identify all MS2 chromatographic peaks from the isolation window
containing the m/z of the ion (i.e. the MS1 chromatographic peak) with
approximately the same retention time than the MS1 peak (accepted rt shift
can be specified with the \code{diffRt} parameter).
\item Correlate the peak shapes of the candidate MS2 chromatographic peaks with
the peak shape of the MS1 peak retaining only MS2 chromatographic peaks
for which the correlation is \code{> minCor}.
\item Reconstruct the MS2 spectrum using the m/z of all above selected MS2
chromatographic peaks and their intensity (either \code{"maxo"} or \code{"into"}).
Each MS2 chromatographic peak selected for an MS1 peak will thus represent
one \strong{mass peak} in the reconstructed spectrum.
}

The resulting \code{Spectra} object provides also the peak IDs of the MS2
chromatographic peaks for each spectrum as well as their correlation value.
}
\seealso{
\code{\link[=findChromPeaksIsolationWindow]{findChromPeaksIsolationWindow()}} for the function to perform MS2
peak detection in DIA isolation windows and for examples.
}
\author{
Johannes Rainer, Micheal Witting
}
