R/foldchange.R
foldchange.Rdfoldchange computes the fold change for two sets of values.
logratio2foldchange converts values from log-ratios to fold changes.
foldchange2logratio does the reverse.
foldchange(num, denom)
logratio2foldchange(logratio, base = 2)
foldchange2logratio(foldchange, base = 2)A vector or matrix of the same dimensions as the input containing the converted values.
Fold changes are commonly used in the biological sciences as a mechanism for comparing the relative size of two measurements. They are computed as: \(\frac{num}{denom}\) if \(num>denom\), and as \(\frac{-denom}{num}\) otherwise.
Fold-changes have the advantage of ease of interpretation and symmetry about \(num=denom\), but suffer from a discontinuity between -1 and 1, which can cause significant problems when performing data analysis. Consequently statisticians prefer to use log-ratios.
foldchange(): Compute fold-change.
logratio2foldchange(): Compute foldchange from log-ratio values.
foldchange2logratio(): Compute log-ratio from fold-change values.
a <- 1:21
b <- 21:1
f <- foldchange(a, b)
cbind(a, b, f)
#> a b f
#> [1,] 1 21 -21.000000
#> [2,] 2 20 -10.000000
#> [3,] 3 19 -6.333333
#> [4,] 4 18 -4.500000
#> [5,] 5 17 -3.400000
#> [6,] 6 16 -2.666667
#> [7,] 7 15 -2.142857
#> [8,] 8 14 -1.750000
#> [9,] 9 13 -1.444444
#> [10,] 10 12 -1.200000
#> [11,] 11 11 1.000000
#> [12,] 12 10 1.200000
#> [13,] 13 9 1.444444
#> [14,] 14 8 1.750000
#> [15,] 15 7 2.142857
#> [16,] 16 6 2.666667
#> [17,] 17 5 3.400000
#> [18,] 18 4 4.500000
#> [19,] 19 3 6.333333
#> [20,] 20 2 10.000000
#> [21,] 21 1 21.000000