AverageBy: Average a numeric matrix or data.frame by columns

Description Usage Arguments Author(s) Examples

View source: R/src_AverageBy.R

Description

Function takes a named list with column numbers to be averaged. Unpaired columns are simply returned as-is.

Usage

1
AverageBy(cts, by)

Arguments

cts

a numeric matrix or data.frame

by

a named list with column numbers to be averaged, colname will be the respective list name

Author(s)

Alexander Toenges

Examples

1
2
3
4
5
cts <- lapply(seq(1,5), function(x) rnorm(10)) %>% do.call(cbind, .)
colnames(cts) <- c("A_rep1", "B_rep1", "A_rep2", "C_rep1", "B_rep2")
rownames(cts) <- paste0("Gene", seq(1,nrow(cts)))
by <- sapply(unique(gsub("_rep.*", "", colnames(cts))), function(x) grep(paste0("^", x, "_rep"), colnames(cts)))
AverageBy(cts,by)

ATpoint/diffanalyseR documentation built on Oct. 8, 2021, 10:11 p.m.