Skip to contents

Create a data.frame from an edgeR results object. This function calls edgeR::topTags() on the object and extracts the table data.frame with all features. This function returns all rows unsorted by default i.e. topTags(..., n=Inf, sort.by="none").

Usage

edger_to_df(x, ...)

Arguments

x

edgeR results object to be converted

...

Additional arguments passed to edgeR::topTags(). n and sort.by are fixed and cannot be supplied. If filtering arguments (e.g. p.value) leave no rows, a 0-row data.frame is returned.

Value

data.frame

Examples

library(edgeR)
library(coriell)

# create some fake data
x <- data.frame(
  ctl1 = rnbinom(1000, size = 0.4, prob = 1e-5),
  ctl2 = rnbinom(1000, size = 0.4, prob = 1e-5),
  trt1 = rnbinom(1000, size = 0.4, prob = 1e-5),
  trt2 = rnbinom(1000, size = 0.4, prob = 1e-5),
  row.names = paste0("gene", 1:1000)
)

# run edger pipeline
group <- factor(c(1, 1, 2, 2))
y <- DGEList(counts = x, group = group)
y <- calcNormFactors(y)
#> calcNormFactors has been renamed to normLibSizes
design <- model.matrix(~group)
y <- estimateDisp(y, design)

# To perform quasi-likelihood F-tests:
fit <- glmQLFit(y, design)
qlf <- glmQLFTest(fit, coef = 2)

# convert the results object to a dataframe -- do not filter the results
res_df <- edger_to_df(qlf)

head(res_df)
#>   feature_id      logFC    logCPM          F       PValue        FDR
#> 1      gene1  -1.402956 10.105751  0.3630773 5.468705e-01 0.94424154
#> 2      gene2 -13.101124  6.149114 16.0052193 6.546748e-05 0.03273374
#> 3      gene3  -4.409160  9.226123  2.7029653 1.003190e-01 0.69418291
#> 4      gene4  -3.552844  9.709009  1.9407925 1.637373e-01 0.73755553
#> 5      gene5  -1.195803 10.592819  0.2623449 6.085703e-01 0.94424154
#> 6      gene6   1.236282 10.423917  0.2821887 5.953293e-01 0.94424154