This function obtains a set of comparisons from a edgeR analysis, given a named list of contrasts. It allows additional model parameters to be specified and a design matrix to be manually adjusted.
Usage
get_edgeR_res(
se,
contrasts,
design = NULL,
res.list = list(),
block = NULL,
lfc.th = NULL,
norm.ercc = FALSE,
ercc.pattern = "^ERCC-",
use.lrt = FALSE
)
Arguments
- se
A SummarizedExperiment::SummarizedExperiment or edgeR::DGEList object.
- contrasts
A named list of contrasts, e.g.
list("condition_AvB" = c("condition", "A", "B"))
. The first element is the variable of interest, the second is the test, and the third is the reference level. The name of each element in the list will be used as a name in the results table.- design
The design matrix, as output from
model.matrix()
. If not provided, the function will create a design matrix based on the contrasts andblock
(if provided).- res.list
A named list to hold edgeR results. Allows the function to be run multiple times if needed and append to the same list. Defaults to an empty list.
- block
A vector of additional terms to be considered in the model, beyond the main effect. Defaults to
NULL
.- lfc.th
A numeric vector of log2 fold-change thresholds for testing. The function will run
glmTreat()
for each threshold specified. Defaults toNULL
.- norm.ercc
A logical indicating whether to normalize to ERCC spike-ins.
- ercc.pattern
A character string indicating the pattern to match ERCC spike-ins. Defaults to
^ERCC-
.- use.lrt
A logical indicating whether to use the likelihood ratio test (LRT) instead of the quasi-likelihood F-test.
Value
A named list of edgeR::TopTags objects for the specified contrasts.
Details
This function is designed to work with relatively simple designs, e.g. variable of interest with a blocking factor or two. If you need a bunch of interaction terms or nested designs, this function is probably not for you.
Examples
nlibs <- 4
ngenes <- 1000
dispersion.true <- 1/rchisq(ngenes, df=10)
group <- factor(c("A", "A", "B", "B"))
design <- model.matrix(~group)
# Generate count data
y <- rnbinom(ngenes*nlibs,mu=20,size=1/dispersion.true)
y <- matrix(y,ngenes,nlibs)
d <- DGEList(y)
#> Error in DGEList(y): could not find function "DGEList"
res <- get_edgeR_res(d, contrasts = list("condition_AvB" = c("group", "A", "B")))
#> Error: object 'd' not found
names(res)
#> Error: object 'res' not found
head(res[[1]])
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'head': object 'res' not found