View source: R/1a-propr-backend.R
logratio | R Documentation |
This function applies a log-ratio transformation to a given data matrix with or without using an alpha parameter.
logratio(counts, ivar, alpha)
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) or index(es) of variable(s) to use as a reference. - Use NA to skip log-ratio transformation and any other pre-processing, like zero replacement. This is useful when the input data is already pre-processed. |
alpha |
The alpha parameter used in the alpha log-ratio transformation. |
A matrix with log-ratio transformed values.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.