Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compareCluster does not give a warning/message that numeric universe is ignored for fun = "enrichGO" #654

Open
IwanParf opened this issue Jan 5, 2024 · 0 comments

Comments

@IwanParf
Copy link

IwanParf commented Jan 5, 2024

Dear clusterProfiler developers,
thank you for this great tool!
I noticed an inconsistent behaviour between calling enrichGO directly and within compareCluster.
when I do enrichGO and provide universe in numeric format, the tests are calculated and at the end I get a message, that universe was ignored due to being numeric (universe is not in character and will be ignored...) (As a side note, one could simply do as.character in the function call to avoid this problem altogether?)

My problem now is that when I call enrichGO within compareCluster, I do not get this warning/message, which leads to different results of course.

Here's a minimal example:

library(clusterProfiler)
library(tidyverse)
library(org.Hs.eg.db)

genes <- as.data.frame(org.Hs.egSYMBOL) %>% pull(gene_id) %>% .[1:100]
universe <- as.data.frame(org.Hs.egSYMBOL) %>% pull(gene_id) %>% .[1:1000]
test <- enrichGO(genes, OrgDb = org.Hs.eg.db, ont = "BP", universe = as.numeric(universe))

This generates test and gives a warning/message: universe is not in character and will be ignored...

test@result$BgRatio[1]

This prints the background ratio of the first gene set: 10/18903 , i.e. the universe (which is max 1000 entries) was ignored and replaced by all genes in org.Hs.eg.db

test2 <- compareCluster(
geneClusters = list(genes = genes), # usually, it makes no sense to run compareCluster with only one entry in the list but this is for the sake of the example
fun = "enrichGO",
OrgDb = org.Hs.eg.db,
universe = as.numeric(universe),
ont = "BP")

This time no warning/message!

test2@compareClusterResult$BgRatio[1]
Again, this prints the background ratio of the first gene set: 10/18903 , i.e. the universe (which is max 1000 entries) was ignored and replaced by all genes in org.Hs.eg.db without a warning.

When I do the above steps with plain universe without as.numeric(), universe is accepted and used as background.

Can the message/warning be preserved in the internal call of enrichGO and still pasted to the console, or the universe be converted to character by default to prevent this problem in the first place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant