Convert normal signed fold change to log2 fold change
Source:R/jam-log2fold-to-fold.R
fold_to_log2fold.RdConvert normal signed fold change to log2 fold change
Details
This function takes fold change values as input, and returns log2 fold change values.
This function recognizes two forms of input:
ratios: with values between 0 and 1, and no negative values
fold changes: as from
log2fold_to_fold()with no values between 0 and 1, and may include negative values.
For any value between 0 and 1, it applies log2()
directly, which produces negative output. In return,
conversion back to fold change using log2fold_to_fold()
will not be reciprocal, instead that step will produce
negative fold change.
For example:
input = 4becomeslog2 fold change = 2.input = 0.25becomeslog2 fold change = -2.input = -4becomeslog2 fold change = -2.
See also
Other jam numeric functions:
deg2rad(),
log2fold_to_fold(),
noiseFloor(),
normScale(),
rad2deg(),
rowGroupMeans(),
rowRmMadOutliers(),
warpAroundZero()
Examples
x <- c(-3, -2, -1, 0, 1, 2, 3, NA);
fc <- log2fold_to_fold(x);
fc;
#> [1] -8 -4 -2 1 2 4 8 NA
xfc <- c(-4, 0.5, 1, 2, 4)
fold_to_log2fold(xfc);
#> [1] -2 -1 0 1 2