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()

Value

data.frame

Examples

library(edgeR)
#> Loading required package: limma
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)
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 -4.670184765  6.471306 2.935376e+00 0.08681348 0.6512474
#> 2      gene2 -0.972224178 11.106996 1.588557e-01 0.69025475 0.9327767
#> 3      gene3  4.468352582  9.790229 2.756184e+00 0.09703586 0.6512474
#> 4      gene4  0.891703989  6.510413 1.431944e-01 0.70516596 0.9347288
#> 5      gene5 -0.004093871 10.393113 2.990887e-06 0.99862030 0.9988132
#> 6      gene6  0.260978806  9.757698 1.252055e-02 0.91091769 0.9795696