orderFeatures: Order features, based on their ability to discriminate

orderFeaturesR Documentation

Order features, based on their ability to discriminate

Description

For each row of data, an F or (potentially) other statistic is calculated, using the function FUN, that measures the extent to which this variable separates the data into groups. This statistic is then used to order the rows.

Usage

 orderFeatures(x, cl, subset = NULL, FUN = aovFbyrow, values =
FALSE) 

Arguments

x

Matrix; rows are features, and columns are observations ('samples')

cl

Factor that classifies columns into groups

subset

allows specification of a subset of the columns of data

FUN

specifies the function used to measure separation between groups

values

if TRUE, F-values as well as the ordering are returned

Value

Either (values=FALSE) a vector that orders the rows, or (values=TRUE)

ord

a vector that orders the rows

stat

ordered values of the statistic

Author(s)

John Maindonald

Examples

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]))
  }

hddplot documentation built on Sept. 14, 2023, 5:07 p.m.