log2_fold_change calculates the log2 fold change of a matrix with features in the rows and samples in the columns.

log2_fold_change(
  mat,
  condition_vector,
  condB = NULL,
  log = FALSE,
  pseudocount = 0
)

Arguments

mat

A matrix. Features in rows and samples in columns.

condition_vector

A character vector or factor with the names of the conditions. The conditions must correspond to the samples, i.e. the exact same order. Two and only two conditions (levels) are needed.

condB

Condition used as reference. E.g. control condition.

log

If log is TRUE, it's assumed that the matrix is already log transformed.

pseudocount

Numeric value indicating pseudocount to be added.

Value

A named vector of log2 fold changes per feature.