logratio: Perform log-ratio transformation

View source: R/1a-propr-backend.R

logratioR Documentation

Perform log-ratio transformation

Description

This function applies a log-ratio transformation to a given data matrix with or without using an alpha parameter.

Usage

logratio(counts, ivar, alpha)

Arguments

counts

A data matrix representing counts. It is assumed that the matrix contains numerical values only.

ivar

An indicator specifying the method for log-ratio transformation. It can take the following values: - "clr" (default): Centered log-ratio transformation. - "alr": Additive log-ratio transformation ("pcor.bshrink" metric only). - "iqlr": Inter-quartile log-ratio transformation from ALDEx2. - The explicit name(s) of variable(s) to use as a reference. Use NA to skip log-ratio transformation.

alpha

The alpha parameter used in the alpha log-ratio transformation.

Value

A matrix with log-ratio transformed values.

Examples

# Sample counts matrix
counts_matrix <- matrix(c(10, 20, 30, 40, 0, 50, 60, 70, 0), nrow = 3, byrow = TRUE)
colnames(counts_matrix) <- c("A", "B", "C")
rownames(counts_matrix) <- c("Sample1", "Sample2", "Sample3")

# Perform log-ratio transformation without alpha
logratio_without_alpha(counts_matrix, use = "A")

# Perform log-ratio transformation with alpha 0.5
logratio_with_alpha(counts_matrix, use = "A", alpha = 0.5)

# Skip log-ratio transformation
logratio(counts_matrix, ivar = NA)


tpq/propr documentation built on April 21, 2024, 12:50 p.m.