\HeaderA{calculate.GSEA}{Calculate 2-sided statistics based on the GSEA algorithm}{calculate.GSEA}
\keyword{array}{calculate.GSEA}
\keyword{htest}{calculate.GSEA}
\begin{Description}\relax
Calculates the 2-sided statistics based on the GSEA algorithm.
\end{Description}
\begin{Usage}
\begin{verbatim}
calculate.GSEA(tab, phenotype, gsList, nsim = 1000,
               verbose = FALSE, alwaysUseRandomPerm = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{tab}] a numeric matrix of expression values, with the rows and
columns representing probe sets and sample arrays, respectively
\item[\code{phenotype}] a numeric or character vector indicating the phenotype
\item[\code{gsList}] a list containing three vectors from the output of
the \code{selectGeneSets} function
\item[\code{nsim}] an integer indicating the number of permutations to use
\item[\code{verbose}] a boolean to indicate whether to print debugging messages
to the R console
\item[\code{alwaysUseRandomPerm}] a boolean to indicate whether the algorithm
can use complete permutations for cases where \code{nsim} is greater
than the total number of unique permutations possible with the
\code{phenotype} vector
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This function assumes 2 distinct types of phenotypes in the data.
It calculates a variant of the GSEA statistics (Mootha et
al.) with the following modifications:
(a) GSEA was changed from a 1-sided to a 2-sided approach.
(b) The 2-group t-statistics is used as the difference metric.

The function also normalizes the GSEA statistic and calculates the
corresponding q-values for each gene set as described in Tian
et al. (2005)  The function's output can be used for further analysis
in other functions such as \code{rankPathways.NGSk} or
\code{getPathwayStatistics.NGSk}.
\end{Details}
\begin{Value}
A list containing
\begin{ldescription}
\item[\code{ngs}] number of gene sets
\item[\code{nsim}] number of permutations performed
\item[\code{t.set}] a numeric vector of Tk statistics
\item[\code{t.set.new}] a numeric vector of NTk statistics
\item[\code{p.null}] the proportion of nulls
\item[\code{p.value}] a numeric vector of p-values
\item[\code{q.value}] a numeric vector of q-values
\end{ldescription}
\end{Value}
\begin{Author}\relax
Lu Tian, Peter Park, and Weil Lai
\end{Author}
\begin{References}\relax
Mootha V.K., Lindgren C.M., Eriksson K.F., Subramanian A., Sihag S.,
Lehar J., Puigserver P., Carlsson E., Ridderstrale M., Laurila E.,
Houstis N., Daily M.J., Patterson N., Mesirov J.P., Golud T.R., Tamayo
P., Spiegelman B., Lander E.S., Hirshhorn J.N., Altshuler D., Groop
L.C.  (2003)  PGC-1alpha-responsive genes involved in oxidative
phosphorylation are coordinately downregulated in human diabetes.
\emph{Nature Genetics}, \bold{34}, 267-73.

Tian L., Greenberg S.A., Kong S.W., Altschuler J., Kohane I.S., Park
P.J. (2005)  Discovering statistically significant pathways in
expression profiling studies.  \emph{Proceedings of the National
Academy of Sciences of the USA}, \bold{102}, 13544-9.

\url{http://www.pnas.org/cgi/doi/10.1073/pnas.0506577102}
\end{References}

