normalize_to_count: normalize_to_count

View source: R/function_normToCount.R

normalize_to_countR Documentation

normalize_to_count

Description

'normalize_to_count' takes a numeric matrix 'expr.data' with only non-negative entries and normalizes each column (=> sample) to a total number of counts.
For every sample i, each feature j gets scaled to

expr.data[j, i] = (count * expr.data[j, i]) / sum(expr.data[, i])

Usage

normalize_to_count(expr.data, count = NA)

Arguments

expr.data

numeric matrix, with features as rows and samples as columns. Notice, 'normalize_to_count' normalizes the columns of this matrix.

count

float, 0 < 'count', to which every sample of expr.data is scaled. If 'is.na(count)' count is set to nrow(expr.data)

Value

'ret', matrix with same dimension as 'expr.data'

Examples

library(DTD)
some.matrix <- matrix(abs(rnorm(1000 * 5)), ncol = 5, nrow = 1000)
# each sample (=column) has different number of total counts:
apply(some.matrix, 2, sum)

normalized.matrix <- normalize_to_count(some.matrix)

# check:
apply(normalized.matrix, 2, sum)

MarianSchoen/DTD documentation built on April 29, 2022, 1:59 p.m.