applyByCategory: Apply a function to a vector of statistics, by category

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/catcode.R

Description

For each category, apply the function FUN to the set of values of stats belonging to that category.

Usage

1
applyByCategory(stats, Amat, FUN = mean, ...)

Arguments

stats

Numeric vector with test statistics of interest.

Amat

A logical or numeric matrix: the adjacency matrix of the bipartite genes - category graph. Its rows correspond to the categories, columns to the genes, and TRUE or a numeric value different from 0 indicates membership. The columns are assumed to be aligned with the elements of stats.

FUN

A function to apply to the subsets stats by categories.

...

Extra parameters passed to FUN.

Details

For GO categories, the function cateGOry might be useful for the construction of Amat.

Value

The return value is a list or vector of length equal to the number of categories. Each element corresponds to the values obtained by applying FUN to the subset of values in stats according to the category defined for that row.

Author(s)

R. Gentleman, contributions from W. Huber

See Also

apply

Examples

1
2
3
4
5
6
7
8
 set.seed(0xabcd)
 st = rnorm(20)
 names(st) = paste("gene", 1:20)

 a = matrix(sample(c(FALSE, TRUE), 60, replace=TRUE), nrow=3,
        dimnames = list(paste("category", LETTERS[1:3]), names(st)))

 applyByCategory(st, a, median)

Category documentation built on Nov. 8, 2020, 10:58 p.m.