\HeaderA{comp.stat}{Computing Test Statistics for Differential Expression}{comp.stat}
\keyword{univar}{comp.stat}
\begin{Description}\relax
This function computes test statistics, e.g., t-statitics, F-statistics, 
SAM, fold changes, moderated t or F statistics, B statistics, 
for each row of a microarray data matrix.
\end{Description}
\begin{Usage}
\begin{verbatim}
comp.stat(X, L, test = c("t", "fc", "sam", "f", "modt", "modf", "B"), extra = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{X}] A  matrix, with \eqn{m}{} rows corresponding to variables
(hypotheses) and \eqn{n}{} columns to observations. In the case of gene 
expression data, rows correspond to genes and columns to mRNA
samples. The data can be read using \code{\LinkA{read.table}{read.table}}.
\item[\code{L}] A vector of integers corresponding to observation (column)
class labels. For \eqn{k}{} classes, the labels must be integers
between 0 and \eqn{k-1}{}.
\item[\code{test}] A character string specifying the statistic to be
used to test the null hypothesis of no association between the
variables and the class labels.\\
\Tabular{ll}{
\code{test="t"}: & t-statistics; \\
\code{test="f"}: & F-statistics;\\
\code{test="fc"}:& fold changes;\\
\code{test="sam"}: & SAM-statistics; \\
\code{test="modt"}: & moderated t-statistics;\\
\code{test="modf"}: & moderated F-statistics; \\
\code{test="B"}: & B-statistics.}
\item[\code{extra}] Extra parameter needed for the test specified; see
\code{\LinkA{deds.genExtra}{deds.genExtra}}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The function \code{comp.stat} interfaces to a C function and
computes various statistics for differential expression in the C
environment and therefore faster than functions in R. However,
functions in R that are implemented in the DEDS packages may have
more flexibility in terms of specifications of arguments. Below is a
table the details \code{comp.stat} and its equivalent R functions
in the DEDS package. Note that all the R functions listed in the 2nd
column of the table below return a function with bindings for a series
of arguments which accept the microarray data matrix as its single
argument and compute accordingly statistics. \\

\Tabular{lll}{
Interface to C & R functions & Statistics \\
deds.stat(X, L, test="t") & tTest(L=NULL, mu=0, var.equal=FALSE)
& t statistics \\
deds.stat(X, L, test="fc") & FC(L=NULL, is.log=TRUE, FUN=mean)
& fold change \\
deds.stat(X, L, test="sam") & Sam(L=NULL, prob=0.5, B=200,
stat.only=TRUE, verbose=FALSE, deltas, s.step=0.01, alpha.step=0.01,
plot.it=FALSE) & SAM statistics \\
deds.stat(X, L, test="f") & fTest(L=NULL) & F statistics \\
deds.stat(X, L, test="modt") & tmodTest(L=NULL) & moderated t
statistics \\
deds.stat(X, L, test="modf") & fmodTest(L=NULL) & moderated F
statistics \\
deds.stat(X, L, test="B") & BTest(L=NULL, proportion=0.01) & B
statistics }
\end{Details}
\begin{Value}
A vector of test statistics for each row of the matrix.
\end{Value}
\begin{Author}\relax
Yuanyuan Xiao, \email{yxiao@itsa.ucsf.edu}, \\
Jean Yee Hwa Yang, \email{jean@biostat.ucsf.edu}.
\end{Author}
\begin{References}\relax
For references on B-statistics and moderated t and F statistics:

Lönnstedt, I. and Speed, T. P. (2002). Replicated microarray
data. \emph{Statistica Sinica} \bold{12}, 31-46.

Smyth, G. K. (2003). Linear models and empirical Bayes methods for
assessing differential expression in microarray
experiments. http://www.statsci.org/smyth/pubs/ebayes.pdf
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{deds.genExtra}{deds.genExtra}},
for B statistics: \code{\LinkA{lm.series}{lm.series}} and
\code{\LinkA{ebayes}{ebayes}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
X <- matrix(rnorm(1000,0,0.5), nc=10)
L <- rep(0:1,c(5,5))

# genes 1-10 are differentially expressed
X[1:10,6:10]<-X[1:10,6:10]+1

# t statistics
tstat <- comp.stat(X, L, test="t")

# SAM, fudge factor set as the median of pooled genewise standard deviations
samstat <- comp.stat(X, L, test="sam")
# SAM, fudge factor set as the 90% of pooled genewise standard deviations
samstat <- comp.stat(X, L, test="sam", extra=c(0.9))

# moderated t
modtstat <- comp.stat(X, L, test="modt")

# B, proportion of differentially expressed genes is set at default, 1%
Bstat <- comp.stat(X, L, test="B")
# B, proportion of differentially expressed genes is set at  10%
Bstat <- comp.stat(X, L, test="B", extra=c(0.1))
\end{ExampleCode}
\end{Examples}

