norm_edgeR {benchdamic} | R Documentation |
Calculate scaling factors from a phyloseq object to scale the raw library
sizes. Inherited from edgeR calcNormFactors
function.
norm_edgeR( object, method = c("TMM", "TMMwsp", "RLE", "upperquartile", "posupperquartile", "none"), refColumn = NULL, logratioTrim = 0.3, sumTrim = 0.05, doWeighting = TRUE, Acutoff = -1e+10, p = 0.75, verbose = TRUE, ... )
object |
a phyloseq object containing the counts to be normalized. |
method |
normalization method to be used. Choose between |
refColumn |
column to use as reference for |
logratioTrim |
the fraction (0 to 0.5) of observations to be trimmed from each tail of the distribution of log-ratios (M-values) before computing the mean. Used by |
sumTrim |
the fraction (0 to 0.5) of observations to be trimmed from each tail of the distribution of A-values before computing the mean. Used by |
doWeighting |
logical, whether to use (asymptotic binomial precision) weights when computing the mean M-values. Used by |
Acutoff |
minimum cutoff applied to A-values. Count pairs with lower A-values are ignored. Used by |
p |
numeric value between 0 and 1 specifying which quantile of the counts should be used by |
verbose |
an optional logical value. If |
... |
other arguments are not currently used. |
A new column containing the chosen edgeR-based scaling factors is
added to the phyloseq sample_data
slot. The effective library sizes
to use in downstream analysis must be multiplied by the normalization factors.
calcNormFactors
for details.
setNormalizations
and runNormalizations
to fastly set and run normalizations.
set.seed(1) # Create a very simple phyloseq object counts <- matrix(rnbinom(n = 60, size = 3, prob = 0.5), nrow = 10, ncol = 6) metadata <- data.frame("Sample" = c("S1", "S2", "S3", "S4", "S5", "S6"), "group" = as.factor(c("A", "A", "A", "B", "B", "B"))) ps <- phyloseq::phyloseq(phyloseq::otu_table(counts, taxa_are_rows = TRUE), phyloseq::sample_data(metadata)) # Calculate the scaling factors ps_NF <- norm_edgeR(object = ps, method = "TMM") # The phyloseq object now contains the scaling factors: scaleFacts <- phyloseq::sample_data(ps_NF)[, "NF.TMM"] head(scaleFacts) # VERY IMPORTANT: to convert scaling factors to normalization factors # multiply them by the library sizes and renormalize. normFacts = scaleFacts * phyloseq::sample_sums(ps_stool_16S) # Renormalize: multiply to 1 normFacts = normFacts/exp(colMeans(log(normFacts)))