\name{tablesDE}
\alias{tablesDE}

\title{
  Save HTML or CSV tables of differentially expressed genes
}

\description{
  This function takes an object of class \code{\link{maigesDE}} or
  \code{\link{maigesDEcluster}} generated by functions
  \code{\link{deGenes2by2Ttest}}, \code{\link{deGenes2by2Wilcox}},
  \code{\link{deGenes2by2BootT}} and \code{\link{deGenesANOVA}} and save HTML
  or CSV tables differentially expressed genes.
}

\usage{
tablesDE(deComp=NULL, dir="./", filenames=NULL, dataID="Someone's",
         type=c("HTML","CSV")[1], geneID="GeneName", hsID="ClusterId",
         gbID="GeneId", annotID="Annot", genes=NULL, logFold=TRUE,
         adjP="none", sort="p.value", nDEgenes=NULL)
}

\arguments{
  \item{deComp}{object of class \code{\link{maigesDE}}.}
  \item{dir}{character specifying the directory to save the files.}
  \item{filenames}{character vector with file names to be saved, if NULL
    default names are given.}
  \item{dataID}{character giving an identifier for the dataset. If NULL
    the \code{notes} slot from \code{DE.comp} are used.}
  \item{type}{type of file to be saved. May be 'HTML' (default) or 'CSV'.}
  \item{geneID}{character giving the ID of label  for gene symbol in the dataset.}
  \item{hsID}{character giving the ID of label for unigene code in the dataset.}
  \item{gbID}{character giving the ID of label for Genbank entry in the dataset.}
  \item{annotID}{character giving the ID of label for gene annotation in
    the dataset.}
  \item{genes}{character vector specifying the genes to be saved, mapped
    according to \code{geneID} label.}
  \item{logFold}{logical specifying if the fold change must be saved in
    log2 scale.}
  \item{adjP}{character string giving the type of p-value
    adjustment. May be 'Bonferroni', 'Holm', 'Hochberg', 'SidakSS',
    'SidakSD', 'BH', 'BY' or 'none'. Defaults to 'none'.}
  \item{sort}{character specifying the field to be sorted, may be
    'p.value' (default), 'fold' or 'statistic'. }
  \item{nDEgenes}{number of differentially genes to be saved in the
    file. Defaults to NULL to save all genes. If an integer value the
    function saves the \code{nDEgenes} with smaller p-values (most
    significantly DE genes). If a number in (0,1) \code{nDEgenes} is
    used as a cutoff for the p-values.}
}

\details{
  We use the function \code{\link[multtest]{mt.rawp2adjp}} from package
  \emph{multtest} to adjust p-values, any information the methods
  implemented must be searched in their help pages. The arguments
  \code{hsID}, \code{gbID} and \code{annotID} are used only to improve
  the tables generate including links for the respective databases, but
  if these information are absent in the dataset they must be specified
  as NULL. The argument \code{geneID} must be necessarily specified,
  because the genes must be at least one identification.
}

\value{
  This function don't return any object.
}

\seealso{
  \code{\link{deGenes2by2Ttest}}, \code{\link{deGenes2by2Wilcox}},
  \code{\link{deGenes2by2BootT}}, \code{\link{deGenesANOVA}},
  \code{\link{maigesDE}}, \code{\link{maigesDEcluster}}.
}

\examples{
## Loading the dataset
data(gastro)

## Doing bootstrap from t statistic test fot 'Type' sample label, k=1000
## specifies one thousand bootstraps
gastro.ttest = deGenes2by2Ttest(gastro.summ, sLabelID="Type")

tablesDE(gastro.ttest) ## Save HTML tables

## To save only tables with p-value < 0.05
tablesDE(gastro.ttest, nDEgenes=0.05)

## To save only tables with 30 most significantly genes
tablesDE(gastro.ttest, nDEgenes=30)
}

\author{
  Gustavo H. Esteves <\email{gesteves@vision.ime.usp.br}>
}

\keyword{methods}