\Header{ebayes}{Empirical Bayes Statistics for Differential Expression}
\alias{eBayes}{ebayes}
\keyword{htest}{ebayes}
\begin{Description}\relax
Given a series of related parameter estimates and standard errors, compute moderated t-statistics and log-odds of differential expression by empirical Bayes shrinkage of the standard errors towards a common value.
\end{Description}
\begin{Usage}
\begin{verbatim}
ebayes(fit,proportion=0.01,std.coef=NULL)
eBayes(fit,proportion=0.01,std.coef=NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{fit}] a list object produced by \code{lm.series}, \code{gls.series}, \code{rlm.series} or \code{lmFit} containing components \code{coefficients}, \code{stdev.unscaled}, \code{sigma} and \code{df.residual}
\item[\code{proportion}] assumed proportion of genes which are differentially expressed
\item[\code{std.coef}] assumed standard deviation of log2 fold changes for differentially expressed genes. Normally this parameter is estimated from the data.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function is used to rank genes in order of evidence for differential expression.
The function accepts as input output from the functions \code{lm.series}, \code{rlm.series} or \code{gls.series}.
The estimates \code{s2.prior} and \code{df.prior} are computed by \code{fdist.fit}.
\code{s2.post} is the weighted average of \code{s2.prior} and \code{sigma\textasciicircum{}2} with weights proportional to \code{df.prior} and \code{df.residual} respectively.

The \code{lods} is sometimes known as the B-statistic.\end{Details}
\begin{Value}
\code{ebayes} produces an ordinary list with the following components.
\code{eBayes} adds the following components to \code{fit} to produce an augmented object, usually of class \code{MArrayLM}.
\begin{ldescription}
\item[\code{t}] numeric vector or matrix of penalized t-statistics
\item[\code{p.value}] numeric vector of p-values corresponding to the t-statistics
\item[\code{s2.prior}] estimated prior value for \code{sigma\textasciicircum{}2}
\item[\code{df.prior}] degrees of freedom associated with \code{s2.prior}
\item[\code{s2.post}] vector giving the posterior values for \code{sigma\textasciicircum{}2}
\item[\code{lods}] numeric vector or matrix giving the log-odds of differential expression
\item[\code{var.prior}] estimated prior value for the variance of the log2-fold-change for differentially expressed gene
\end{ldescription}
\end{Value}
\begin{Author}\relax
Gordon Smyth
\end{Author}
\begin{References}\relax
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{\Link{fitFDist}}, \code{\Link{tmixture.matrix}}.

An overview of linear model functions in limma is given by \link{5.LinearModels}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
#  Simulate gene expression data,
#  6 microarrays and 100 genes with one gene differentially expressed
M <- matrix(rnorm(100*6,sd=0.3),100,6)
M[1,] <- M[1,] + 1.6
fit <- lm.series(M)
eb <- ebayes(fit)
qqt(eb$t,df=eb$df+fit$df)
abline(0,1)
#  Points off the line may be differentially expressed
\end{ExampleCode}
\end{Examples}

