edgerWrp: Wrapper applying an edgeR differential analysis workflow

View source: R/edgerWrp.R

edgerWrpR Documentation

Wrapper applying an edgeR differential analysis workflow

Description

edgerWrp is a wrapper using functions from the edgeR package (Robinson et al. 2010, Bioinformatics; McCarthy et al. 2012, Nucleic Acids Research) to fit models and perform a moderated test for each entity.

Usage

edgerWrp(
  count,
  lib_size = NULL,
  option = c("glm", "glmQL"),
  design,
  contrast = NULL,
  normalize = TRUE,
  normalize_method = "TMM",
  ...
)

Arguments

count

A matrix with features (e.g., genes or microbes) in rows and samples in columns.

lib_size

A numeric vector with library sizes for each sample. If NULL (default), the column sums of count are used.

option

Either "glm" or "glmQL". If "glm", glmFit and glmLRT are used; otherwise, glmQLFit and glmQLFTest are used. Details about the difference between the two options can be found in the help pages of glmQLFit.

design

A numeric design matrix, e.g. created by model.matrix. Please refer to design in glmQLFit and glmFit for more details.

contrast

A numeric vector specifying one contrast of the linear model coefficients to be tested. Its length must equal the number of columns of design. If NULL, the last coefficient will be tested. Please refer to contrast in glmQLFTest and glmLRT for more details.

normalize

A logical scalar, specifying whether normalization factors should be calculated (using calcNormFactors).

normalize_method

Normalization method to be used. Please refer to method in calcNormFactors for more details.

...

More arguments to pass to glmFit (if option = "glm" or glmQLFit (if option = "glmQL").

Details

The function performs the following steps:

  • Create a DGEList object. If lib_size is given, set the library sizes to these values, otherwise use the column sums of the count matrix.

  • If normalize is TRUE, estimate normalization factors using calcNormFactors.

  • Estimate dispersions with estimateDisp.

  • Depending on the value of option, apply either the LRT or QLF edgeR workflows (i.e., either glmFit + glmLRT or glmQLFit + glmQLFTest), testing for the specified contrast.

Value

The output of glmQLFTest or glmLRT depending on the specified option.

Author(s)

Ruizhu Huang

Examples

suppressPackageStartupMessages({
    library(TreeSummarizedExperiment)
})
## Read example data
x <- readRDS(system.file("extdata/da_sim_100_30_18de.rds",
                         package = "treeclimbR"))

## Run differential abundance analysis
out <- edgerWrp(count = assay(x), option = "glm",
                design = model.matrix(~ group, data = colData(x)),
                contrast = c(0, 1))

## The output is an edgeR DGELRT object
class(out)


fionarhuang/treeclimbR documentation built on May 19, 2024, 1:18 p.m.