Checks whether the input data is already log-transformed; if not, applies a log2 transformation. This helps ensure comparability of expression values across datasets.
Usage
log_trans(data, pseudo = 1, ...)
# S3 method for class 'matrix'
log_trans(data, pseudo = 1, ...)
# S3 method for class 'ExpressionSet'
log_trans(data, pseudo = 1, ...)Value
A matrix or an ExpressionSet with
log2-transformed expression values.
Details
The function heuristically determines whether data has been
log-transformed, following the methodology used in
GEO2R. If not, it
applies log2() with the specified pseudo offset.
References
NCBI GEO2R: https://www.ncbi.nlm.nih.gov/geo/geo2r/?acc=GSE1122
Examples
sample_means <- 2^runif(2, 2, 10)
sample_disp <- 100 / sample_means + 0.5
data <- matrix(
rnbinom(4, mu = sample_means, size = 1 / sample_disp),
nrow = 2
)
log_trans(data)
#> Applying log2 transformation with a pseudo count of 1 to the data.
#> [,1] [,2]
#> [1,] 0.000000 3.169925
#> [2,] 7.924813 6.149747
log_trans(log2(data))
#> The data is already log-transformed. No transformation applied.
#> [,1] [,2]
#> [1,] -Inf 3.000000
#> [2,] 7.918863 6.129283