norm_CSS {benchdamic} | R Documentation

## norm_CSS

### Description

Calculate scaling factors from a phyloseq object to scale the raw library sizes. Inherited from metagenomeSeq 'calcNormFactors' function which performs the Cumulative Sum Scaling normalization.

### Usage

    norm_CSS(object, method = "default", verbose = TRUE)

### Arguments

`object` | phyloseq object containing the counts to be normalized.
`method` | normalization scaling parameter (default `method = "default"`). If `"median"`, the median of the normalization factors is used as scaling (Paulson et al. 2013).
`verbose` | an optional logical value. If `TRUE`, information about the steps of the algorithm is printed. Default `verbose = TRUE`.

### Value

A new column containing the CSS scaling factors is added to the phyloseq `sample_data` slot.

### See Also

`calcNormFactors` for details. `setNormalizations` and `runNormalizations` to fastly set and run normalizations.

### Examples

    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_CSS(object = ps, method = "median")
    # The phyloseq object now contains the scaling factors:
    scaleFacts <- phyloseq::sample_data(ps_NF)[, "NF.CSSmedian"]
    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)))

[Package benchdamic version 1.0.0 Index]