enrichplot icon indicating copy to clipboard operation
enrichplot copied to clipboard

error using emapplot on compareCluster results wit all GO onotologies

Open jelman opened this issue 1 year ago • 6 comments

Hello,

I ran compareCluster on three gene lists using the function enrichGO and including ALL GO ontologies. Then, I calculated term similarity with pairwise_termsim and method "JC". When trying to plot with emapplot, I get the following error:

Error in [<-.data.frame(*tmp*, pie_data[i, 2], pie_data[i, 1], value = 1) : missing values are not allowed in subscripted assignments of data frames

If I specify one ontology ("BP" for example), I don't get get this error. I understand why using "AL" wouldn't be possible if I were using semantic similarity in the call to pairwise_termsim, but since I am only using gene overlap should I be able to plot the results? Let me know if you need any other information and thank you in advance for your help.

Jeremy

jelman avatar Feb 17 '23 16:02 jelman

'ont = ALL'should be OK. Please provide repeatable code with your data, I will check caused this error. image

huerqiang avatar Feb 18 '23 09:02 huerqiang

Thank you for the reply. Here is the code I am using. At first, I thought it was because the second gene list only showed significant gene sets for the CC ontology while the others were enriched for gene sets across all three ontologies. However, I tried using different subsets of genes and did not get the error in other scenarios when a list was only enriched in a single ontology. I believe that using these gene lists and not using the universe argument, the error also does not occur. I'm not sure why this particular combination of gene lists and background genes results in the error.

library(clusterProfiler)
library(enrichplot)

load(url("https://www.dropbox.com/s/s6rckb2m0skive6/example_gene_lists.Rda?raw=1"))

gl_3cont <- list("cont1" = cont1_genes, "cont2" = cont2_genes, "cont3" = cont3_genes)

cc_3cont <- compareCluster(gl_3cont, fun="enrichGO", 
                           OrgDb = 'org.Hs.eg.db', 
                           universe = bg_genes,
                           keyType="ENSEMBL", 
                           ont="ALL", 
                           minGSSize = 10, maxGSSize = 1000)
termsim_3cont <- pairwise_termsim(cc_3cont, method="JC", semData = NULL)
p_3cont <- emapplot(termsim_3cont, group_category=TRUE, clusterFunction=cluster::pam)
p_3cont

Thanks again, Jeremy

jelman avatar Feb 18 '23 20:02 jelman

For your information:

If I leave group_category=FALSE (default setting) your code works in my hands....

Yet, I don't know how to specify group_category=TRUE using the new way of providing arguments; if I include cluster = "Cluster" it fails (again; similar like you?)

@huerqiang: do you have any suggestion?

> cc_3cont <- compareCluster(gl_3cont, fun="enrichGO", 
+                            OrgDb = 'org.Hs.eg.db', 
+                            universe = bg_genes,
+                            keyType="ENSEMBL", 
+                            ont="ALL", 
+                            minGSSize = 10, maxGSSize = 1000)
> 
> termsim_3cont <- pairwise_termsim(cc_3cont, method="JC", semData = NULL)
> 
> ## new way of providing arguments.
> cluster.params = list(method = cluster::pam)
> 
> ## works! See screenshot below.
> emapplot(termsim_3cont, cluster.params=cluster.params )
Warning message:
ggrepel: 3 unlabeled data points (too many overlaps). Consider increasing max.overlaps 
>
> ## yet, this results in an error.... ??
> cluster.params = list(cluster = "Cluster",
+                       method = cluster::pam)
> emapplot(termsim_3cont, cluster.params=cluster.params )
Error in group_category || node_label == "all" : 
  invalid 'x' type in 'x || y'
>

image

guidohooiveld avatar Mar 03 '23 14:03 guidohooiveld

For your information:

If I leave group_category=FALSE (default setting) your code works in my hands....

Yet, I don't know how to specify group_category=TRUE using the new way of providing arguments; if I include cluster = "Cluster" it fails (again; similar like you?)

@huerqiang: do you have any suggestion?

> cc_3cont <- compareCluster(gl_3cont, fun="enrichGO", 
+                            OrgDb = 'org.Hs.eg.db', 
+                            universe = bg_genes,
+                            keyType="ENSEMBL", 
+                            ont="ALL", 
+                            minGSSize = 10, maxGSSize = 1000)
> 
> termsim_3cont <- pairwise_termsim(cc_3cont, method="JC", semData = NULL)
> 
> ## new way of providing arguments.
> cluster.params = list(method = cluster::pam)
> 
> ## works! See screenshot below.
> emapplot(termsim_3cont, cluster.params=cluster.params )
Warning message:
ggrepel: 3 unlabeled data points (too many overlaps). Consider increasing max.overlaps 
>
> ## yet, this results in an error.... ??
> cluster.params = list(cluster = "Cluster",
+                       method = cluster::pam)
> emapplot(termsim_3cont, cluster.params=cluster.params )
Error in group_category || node_label == "all" : 
  invalid 'x' type in 'x || y'
>

image

It is a typo bug in enrichplot package. It will be fixed in the Github version(> 1.19.1.992).

huerqiang avatar Mar 05 '23 08:03 huerqiang

@guidohooiveld It will be fixed here: https://github.com/YuLab-SMU/enrichplot/pull/229

huerqiang avatar Mar 05 '23 08:03 huerqiang

I encountered the similar error when doing emap plot. I updated the clusterprofiler package to fix this kind of issue.

JulongWei avatar Oct 09 '23 18:10 JulongWei