Skip to contents

Transforms log2-transformed expression data back to linear scale by calculating 2^x for each value in the input matrix.

Usage

unlog2_data(data)

Arguments

data

A numeric matrix containing log2-transformed data with identifiers as row names and samples as columns.

Value

A numeric matrix with the same dimensions as the input, with values converted to linear scale (2^x).

Details

This function can be used to convert log2-transformed proteomics or gene expression data back to their original scale for downstream analyses that require linear values. It preserves the row and column names of the input matrix.

Examples

# Create log2-transformed data matrix
log2_mat <- matrix(rnorm(12, mean = 10, sd = 2), nrow = 4, ncol = 3)
rownames(log2_mat) <- paste0("Protein", 1:4)
colnames(log2_mat) <- paste0("Sample", 1:3)

# View original log2 values
print(log2_mat)
#>            Sample1  Sample2   Sample3
#> Protein1  7.624940 9.878312  6.766672
#> Protein2 10.724835 7.612918 10.991696
#> Protein3  8.901129 9.760184 12.599502
#> Protein4 11.385900 8.583784  6.768029

# Convert to linear scale
linear_mat <- unlog2_data(log2_mat)
print(linear_mat)
#>            Sample1  Sample2   Sample3
#> Protein1  197.3947 941.1704  108.8858
#> Protein2 1692.3766 195.7567 2036.2453
#> Protein3  478.0870 867.1777 6206.2321
#> Protein4 2676.0691 383.6865  108.9883