colmean: Give means of rows of matrix based on column grouping...

View source: R/utils.R

colmeanR Documentation

Give means of rows of matrix based on column grouping variable

Description

Inspired by edgeR::sumTechReps and base::rowsum(), this function takes the average of the values in each group given by the group argument for each row of the data matrix.

Usage

colmean(x, group, na.rm = FALSE)

Arguments

x

variable (gene) by sample numeric matrix

group

Factor specifying the grouping level to by averaged

na.rm

Logical (TRUE or FALSE). Should NA (including NaN) values be discarded?

Value

variable x nLevels(group) matrix

Examples

# Specify the Group levels
Group <- gl(n = 2, k = 3, labels = c("DMSO", "THZ1"))

# Take the average of every gene by treatment group
by_group <- colmean(GSE161650_lc, group = Group)
by_group[1:5, ]


jcalendo/coriell documentation built on March 5, 2025, 5:42 a.m.