\HeaderA{orderFeatures}{Order features, based on their ability to discriminate}{orderFeatures}
\keyword{htest}{orderFeatures}
\begin{Description}\relax
For each row of \code{data}, an F or (potentially) other
statistic is calculated, using the function \code{FUN}, that measures
the extent to which this variable separates the data into groups. This
statistic is then used to order the rows.
\end{Description}
\begin{Usage}
\begin{verbatim} orderFeatures(x, cl, subset = NULL, FUN = aovFbyrow, values =
FALSE) \end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] Matrix; rows are features, and columns are observations 
('samples')
\item[\code{cl}] Factor that classifies columns into groups
\item[\code{subset}] allows specification of a subset of the columns of \code{data}
\item[\code{FUN}] specifies the function used to measure separation between groups
\item[\code{values}] if \code{TRUE}, F-values as well as the ordering are returned
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\end{Details}
\begin{Value}
Either (\code{values=FALSE}) a vector that orders the rows,
or (\code{values=TRUE})
\begin{ldescription}
\item[\code{ord}] a vector that orders the rows
\item[\code{stat}] ordered values of the statistic
\end{ldescription}
\end{Value}
\begin{Note}\relax
\end{Note}
\begin{Author}\relax
John Maindonald
\end{Author}
\begin{References}\relax
\end{References}
\begin{SeeAlso}\relax
~~objects to See Also as \code{\LinkA{help}{help}}, ~~~
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
mat <- matrix(rnorm(1000), ncol=20)
cl <- factor(rep(1:3, c(7,9,4)))
ord <- orderFeatures(mat, cl)

## The function is currently defined as
function(x, cl, subset=NULL, FUN=aovFbyrow, values=FALSE){
    if(dim(x)[2]!=length(cl))stop(paste("Dimension 2 of x is",
                  dim(x)[2], "differs from the length of cl (=",
                  length(cl)))
    ## Ensure that cl is a factor & has no redundant levels
    if(is.null(subset))
      cl <- factor(cl)
    else
      cl <- factor(cl[subset])
    if(is.null(subset))
      stat <- FUN(x, cl)
    else
      stat <- FUN(x[, subset], cl)
    ord <- order(-abs(stat))
    if(!values)ord else(list(ord=ord, stat=stat[ord]))
  }
\end{ExampleCode}
\end{Examples}

