Here is what I am doing when clusterProfiler did not give any results with calculated universe genes:
res.cer = as.data.frame(results(dds_cer_comb))
prep_genelist <- function(res){
overallBaseMean <- as.matrix(res[, "baseMean", drop = F])
de_genes = rownames(res[which(res$padj < 0.05), ])
library(genefilter)
backG <- genefinder(overallBaseMean, de_genes, 10, method = "manhattan")
backG <- rownames(overallBaseMean)[as.vector(sapply(backG, function(x)x$indices))]
backG <- setdiff(backG, de_genes)
genelist = list(de_genes, backG)
names(genelist) = c("de_genes", "backG_genes")
return(genelist)
}
cer.genes = prep_genelist(res.cer)
resultGO = enrichGO(cer.genes$de_genes, universe = cer.genes$backG_genes, keytype = "ENSEMBL", qvalueCutoff = 0.2, ont="BP",
minGSSize = 5, maxGSSize = 5000, OrgDb='org.Hs.eg.db')
resultGO
#
over-representation test
#
...@organism Homo sapiens
...@ontology BP
...@keytype ENSEMBL
...@gene chr [1:4257] "ENSG00000000003" "ENSG00000000419" "ENSG00000001167" "ENSG00000001497" ...
...pvalues adjusted by 'BH' with cutoff <0.05
...0 enriched terms found
'data.frame': 0 obs. of 9 variables:
$ ID : chr
$ Description: chr
$ GeneRatio : chr
$ BgRatio : chr
$ pvalue : num
$ p.adjust : num
$ qvalue : num
$ geneID : chr
$ Count : int
...Citation
Guangchuang Yu, Li-Gen Wang, Yanyan Han and Qing-Yu He.
clusterProfiler: an R package for comparing biological themes among
gene clusters. OMICS: A Journal of Integrative Biology
2012, 16(5):284-287
see https://guangchuangyu.github.io/2014/08/why-clusterprofiler-fails/