DOSE icon indicating copy to clipboard operation
DOSE copied to clipboard

Universal background gene list used in enricher function

Open merckey opened this issue 2 years ago • 1 comments

Dear Guangchuang, Big fan of all the R suites your group develop! I have a question regarding the universal gene list used in the enricher function for the Over Representation Analysis.

Test enrichment overall all the GSEA Hallmark genesets and didn't supply a background universe gene list. My understanding is that the program will generate a "universal" list using the TMER2GENE list.

library(clusterProfiler)
library(msigdbr)

genesets = msigdbr(species = "Homo sapiens", category = "H")
h = genesets  %>% dplyr::select(gs_name, gene_symbol)

# randomly select some genes as input
set.seed(1)
sel_genes = sample(h$gene_symbol,20)

# test on all hallmark genesets
egmt.h <- enricher(sel_genes, TERM2GENE=h, pvalueCutoff = 1,qvalueCutoff=0.05,maxGSSize = 3000)
egmt.h@result$BgRatio[1]

However, when I try to test enrichment overall a selected GSEA Hallmark geneset with a universe gene list manually created from hallmark genesets, it reported the following error.

# test only HALLMARK_ADIPOGENESIS gene set.
egmt.h.single <- enricher(sel_genes, TERM2GENE=h[h$gs_name=="HALLMARK_ADIPOGENESIS",],pvalueCutoff = 1,qvalueCutoff=0.05,maxGSSize = 3000,universe = unique(h$gene_symbol))

# with the following error.
--> No gene can be mapped....
--> Expected input gene ID: CAVIN1,LAMA4,NDUFA5,GPD2,SLC27A1,CAT
--> return NULL...

So I checked the code for this function and found that the universe gene list is not used as background gene for the statistical test. Please correct me if I'm wrong.

Thank you for your help!

Jin

https://github.com/YuLab-SMU/DOSE/blob/20c57bc217fa9aa17dc642ec047bd80a1848efe5/R/enricher_internal.R#L60

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 
 clusterProfiler_4.2.1


loaded via a namespace (and not attached):

DOSE_3.20.1 

merckey avatar Jan 12 '22 15:01 merckey

The universe passed by the user is indeed used as a background for enrichment analysis.

Your issue cannot be reproduced, see the following screenshot:

image

GuangchuangYu avatar Apr 24 '22 03:04 GuangchuangYu