Convert normal signed fold change to log2 fold change

fold_to_log2fold(x, ...)

Arguments

x

numeric vector

Value

numeric vector representing log2 fold change values.

Details

This function takes fold change values as input, and returns log2 fold change values.

This function recognizes two forms of input:

  • ratio, which includes values between 0 and 1, but no negative values;

  • fold change, as from log2fold_to_fold() which includes no values between 0 and 1, but may include negative values.

For example, for ratio input:

  • ratio = 4 becomes log2 fold change = 2.

  • ratio = 0.25 becomes log2 fold change = -2.

For example, for fold change input:

  • fold change = 4 becomes log2 fold change = 2.

  • fold change = -4 becomes log2 fold change = -2.

Examples

x <- c(-3, -2, -1, 0, 1, 2, 3);
fc <- log2fold_to_fold(x);
fc;
#> [1] -8 -4 -2  1  2  4  8

fold_to_log2fold(fc);
#> [1] -3 -2 -1  0  1  2  3