\name{adduct.search}
\alias{adduct.search}
\title{Method for identifying adduct patterns}
\description{Identification of features corresponding to different adducts of the same molecular compound.}
\usage{adduct.search(ftlist, mz.tol = 3e-3, adducts = 0, mode = "+", onlyIsotopes = TRUE, fplot = TRUE)}
\arguments{
  \item{ftlist }{ feature list as returned by \code{\link{isotope.search}}.}
  \item{mz.tol }{ tolerance for M/Z values.}
  \item{adducts }{ adduct list (see details).}
  \item{onlyIsotopes }{If onlyIsotopes=1, the adduct search will only take into account features that have been previously 
associated to an isotope pattern.}
  \item{fplot }{ logical, if \code{'TRUE'} summary figures are plotted.}
}
\details{
If \code{adducts} is equal to 0 a default table of adducts will be used using the ionization mode specified by \code{mode}. If the user wants to provide its own 
adduct list it must be added through the \code{adducts} argument. \code{adducts} must be a list() object with two vectors named \code{labels} 
(i.e. \code{c("[M+H]", "[M+2H]", "[M+3H]", "[M+NH4]")}) and \code{masses}(i.e. \code{c(1.00728, 2.0145, 3.0218, 18.0338)}). [M+H] and [M-H] are respectively mandatory for positive 
and negative ionization modes.
}
\value{
A matrix containing the final results. Each row corresponds to a compound and the indexes of all the features 
related to this compound (isotopes, adducts, fragments...) are provided.
}
\author{A.Alonso, et al. Grup de Recerca de Reumatologia 2010, bioinformatics@urr.cat.}
\seealso{\code{\link{data.norm}}, \code{\link{isotope.search}}, \code{\link{printresults}}, \code{\link{plotcompound}}.}
\examples{
## Load example data
data(astream.data,package="AStream")

## Normalize intensities, search for outliers and feature pairs selection
feat <- data.norm(input)

## Identify Carbon isotopes
feat <- isotope.search(feat)

## Search for adducts
results <- adduct.search(feat)
## Show some results
results[1:min(30,dim(results)[1]),]

## Adduct table provided by the user as a 'data.frame'
table <- list(masses=c(1.007276, 18.033823,22.989218,38.963158,68.99472),
                          labels = c("[M+H]","[M+NH4]","[M+Na]","[M+K]","[M+NaHCOOH]"))
results <- adduct.search(feat, adducts = table)
}