\Header{classifyTests}{Treat Simultaneous T-Tests as Classification Problem}
\alias{classifyTestsP}{classifyTests}
\alias{classifyTestsT}{classifyTests}
\keyword{htest}{classifyTests}
\begin{Description}\relax
Classify a series of related t-statistics as up, down or not significant.
\end{Description}
\begin{Usage}
\begin{verbatim}
classifyTests(tstat, cor.matrix=NULL, design=NULL, contrasts=NULL, df=Inf, p.value=0.01)
classifyTestsT(tstat, t1=4, t2=3)
classifyTestsP(tstat, df=Inf, p.value=0.05, method="holm")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{tstat}] numeric matrix of t-statistics or an \code{MArrayLM} object from which the t-statistics may be extracted.
\item[\code{cor.matrix}] covariance matrix of each row of t-statistics.  Defaults to the identity matrix.
\item[\code{design}] full rank numeric design matrix.  Not used if \code{cor.matrix} is specified.
\item[\code{contrasts}] numeric matrix with columns specifying contrasts of the coefficients of interest.  Not used if \code{cor.matrix} is specified.
\item[\code{df}] numeric vector giving the degrees of freedom for the t-statistics.
May have length 1 or length equal to the number of rows of \code{tstat}.
\item[\code{p.value}] numeric value between 0 and 1 giving the desired size of the test
\item[\code{t1}] first critical value for absolute t-statistics
\item[\code{t2}] second critical value for absolute t-statistics
\item[\code{method}] character string specifying p-value adjustment method.  See \code{\Link{p.adjust}} for possible values.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{classifyTests} classifies using a nested F-test approach giving particular attention to correctly classifying genes which have two or more significant t-statistics, i.e., are differential expressed under two or more conditions.
\code{classifyTestsT} and \code{classifyTestsP} implement simpler classification schemes based on threshold or critical values for the individual t-statistics in the case of \code{classifyTestsT} or p-values obtained from the t-statistics in the case of \code{classifyTestsP}.

Rows of \code{tstat} correspond to genes and columns to coefficients or contrasts.
For each row of \code{tstat}, F-statistics are constructed from the t-statistics.
If the overall F-statistic is significant, then the function makes a best choice as to which t-statistics contributed to this result.
The methodology is based on the principle that any t-statistic should be called significant if the F-test is still significant for that row when all the larger t-statistics are set to the same absolute size as the t-statistic in question.

If \code{tstat} is an \code{MArrayLM} object, then all arguments except for \code{p.value} are extracted from it.

\code{cor.matrix} is the same as the correlation matrix of the coefficients from which the t-statistics are calculated.
If \code{cor.matrix} is not specified, then it is calculated from \code{design} and \code{contrasts} if at least \code{design} is specified or else defaults to the identity matrix.
In terms of \code{design} and \code{contrasts}, \code{cor.matrix} is obtained by standardizing the matrix
\code{ t(contrasts) \%*\% solve(t(design) \%*\% design) \%*\% contrasts }
to a correlation matrix.\end{Details}
\begin{Value}
A list with components
\begin{ldescription}
\item[\code{classification}] numeric matrix with elements \code{-1}, \code{0} or \code{1} depending on whether each t-statistic is classified as significantly negative, not significant or significantly positive respectively
\item[\code{Fstat}] numeric vector containing moderated F-statistics for testing the contrasts simultaneously zero
\end{ldescription}
\end{Value}
\begin{Author}\relax
Gordon Smyth
\end{Author}
\begin{SeeAlso}\relax
An overview of linear model functions in limma is given by \link{5.LinearModels}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
tstat <- matrix(c(0,5,0, 0,2.5,0, -2,-2,2, 1,1,1), 4, 3, byrow=TRUE)
classifyTests(tstat)

# See also the examples for contrasts.fit and vennDiagram
\end{ExampleCode}
\end{Examples}

