norm_DESeq2 | R Documentation |
Calculate size factors from a phyloseq or TreeSummarizedExperiment object.
Inherited from DESeq2 estimateSizeFactors
function.
norm_DESeq2(
object,
assay_name = "counts",
method = c("ratio", "poscounts", "iterate"),
verbose = TRUE,
...
)
object |
a phyloseq or TreeSummarizedExperiment object. |
assay_name |
the name of the assay to extract from the
TreeSummarizedExperiment object (default |
method |
Method for estimation: either |
verbose |
an optional logical value. If |
... |
other parameters for DESeq2
|
A new column containing the chosen DESeq2-based size factors is
added to the sample_data
slot of the phyloseq object or the
colData
slot of the TreeSummarizedExperiment object.
estimateSizeFactors
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 size factors
ps_NF <- norm_DESeq2(object = ps, method = "poscounts")
# The phyloseq object now contains the size factors:
sizeFacts <- phyloseq::sample_data(ps_NF)[, "NF.poscounts"]
head(sizeFacts)
# VERY IMPORTANT: DESeq2 uses size factors to normalize counts.
# These factors are used internally by a regression model. To make DEseq2
# size factors available for edgeR, we need to transform them into
# normalization factors. This is possible by dividing the factors by the
# library sizes and renormalizing.
normSizeFacts = sizeFacts / colSums(phyloseq::otu_table(ps_stool_16S))
# Renormalize: multiply to 1
normFacts = normSizeFacts/exp(colMeans(log(normSizeFacts)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.