Learn R Programming

Statomica (version 1.0)

stat: Evaluates a function feature per feature.

Description

Evaluates function FUN feature per feature for input classes: matrix, xprnSet, XprnSet, xprnSetPair.

Usage

stat(x, y = numeric(0), FUN = mean, na.rm = TRUE, ...)

Arguments

x
input data of class matrix, xprnSet, XprnSet, xprnSetPair, XprnSetPair. The number of features of x is nrow(x).
y
optional input data of same class as x (not needed when x is xprnSetPair).
FUN
a function to evaluate the inputs of which must be named x, y and na.rm (see example).
na.rm
if na.rm = TRUE the NAs in the data are ignored.
...
further arguments for FUN

Value

a numeric with same length as the number of features in input x.

See Also

Classes xprnSet, XprnSet, xprnSetPair.

Functions XprnSet, xprnSet, xprnSetPair, nXprnSet, nxprnSet, nxprnSetPair.

Examples

Run this code
xm<-matrix(runif(4 * 7, min= -1, max = 1), 4, 7)
ym<-matrix(runif(4 * 8, min= -1, max = 1), 4, 8)

#input data:  XprnSet and xprnSetPair 
x1 <- XprnSet(exprs = abs(xm)) 
x2 <- xprnSetPair(x = xprnSet(exprs = xm), y = xprnSet(exprs = ym))
x3 <- nxprnSetPair(x = xm, y = ym, paired = TRUE)

#functions to apply to every feature of the input data 
FUN <- function(x, na.rm, ...){t.test(x = x, na.rm = na.rm,...)$statistic}
absFUN <- function(x, y, na.rm, ...){z<-t.test(x = x, y = y, na.rm = na.rm,...)$statistic;abs(z)}
pFUN <- function(x, y, na.rm, ...){t.test(x = x, y = y, alternative = "greater")$p.value}

z1 <- stat(x = x1, na.rm = TRUE, FUN = FUN)
z2 <- stat(x = x2, na.rm = TRUE, FUN = absFUN)
z3 <- stat(x = x3, na.rm = TRUE, FUN = pFUN)
z4 <- stat(x = xm, y = ym, na.rm = TRUE, FUN = absFUN)


Run the code above in your browser using DataLab