calculateRelativeFC: Calculate logFCs relative to WT using edgeR

View source: R/calculateRelativeFC.R

calculateRelativeFCR Documentation

Calculate logFCs relative to WT using edgeR

Description

Calculate logFCs and associated p-values for a given comparison, using either limma or the Negative Binomial quasi-likelihood framework of edgeR. The observed counts for the WT variants can be used as offsets in the model.

Usage

calculateRelativeFC(
  se,
  design,
  coef = NULL,
  contrast = NULL,
  WTrows = NULL,
  selAssay = "counts",
  pseudocount = 1,
  method = "edgeR",
  normMethod = ifelse(is.null(WTrows), "TMM", "sum")
)

Arguments

se

SummarizedExperiment object.

design

Design matrix. The rows of the design matrix must be in the same order as the columns in se.

coef

Coefficient(s) to test with edgeR or limma.

contrast

Numeric contrast to test with edgeR or limma.

WTrows

Vector of row names that will be used as the reference when calculating logFCs and statistics. If more than one value is provided, the sum of the corresponding counts is used to generate offsets. If NULL, offsets will be defined as the effective library sizes (using TMM normalization factors).

selAssay

Assay to select from se for the analysis.

pseudocount

Pseudocount to add when calculating log-fold changes.

method

Either 'edgeR' or 'limma'. If set to 'limma', voom is used to transform the counts and estimate observation weights before applying limma. In this case, the results also contain the standard errors of the logFCs.

normMethod

Character scalar indicating which normalization method should be used to calculate size factors. Should be either "TMM" or "csaw" when WTrows is NULL, and "geomean" or "sum" when WTrows is provided.

Value

A data.frame with output from the statistical testing framework (edgeR or limma).

Author(s)

Charlotte Soneson, Michael Stadler

Examples

se <- readRDS(system.file("extdata", "GSE102901_cis_se.rds",
                          package = "mutscan"))[1:200, ]
design <- stats::model.matrix(~ Replicate + Condition,
                              data = SummarizedExperiment::colData(se))
                              
## Calculate "absolute" log-fold changes with edgeR
res <- calculateRelativeFC(se, design, coef = "Conditioncis_output", 
                           method = "edgeR")
head(res)
## Calculate log-fold changes relative to the WT sequence with edgeR
stopifnot("f.0.WT" %in% rownames(se))
res <- calculateRelativeFC(se, design, coef = "Conditioncis_output", 
                           method = "edgeR", WTrows = "f.0.WT")
head(res)

## Calculate "absolute" log-fold changes with limma
res <- calculateRelativeFC(se, design, coef = "Conditioncis_output", 
                           method = "limma")
head(res)
## Calculate log-fold changes relative to the WT sequence with limma
stopifnot("f.0.WT" %in% rownames(se))
res <- calculateRelativeFC(se, design, coef = "Conditioncis_output", 
                           method = "limma", WTrows = "f.0.WT")
head(res)


fmicompbio/mutscan documentation built on Oct. 24, 2024, 2:41 p.m.