enrichplot icon indicating copy to clipboard operation
enrichplot copied to clipboard

emapplot is empty even with different files that worked before and generated emapplot.

Open jalilsharif opened this issue 10 months ago • 11 comments

Hello, I updated enrichplot, clusterprofiler, dose, geosemsim and installed ggtangle, however, all the emapplots are empty.

library(clusterProfiler)
library(enrichplot)
library(tidyverse)
library(org.Hs.eg.db) #org.Rn.eg.db #org.Hs.eg.db
library(RDAVIDWebService)
library(ggplot2)
library(pathview)
library(rrvgo)
library(GOSemSim)
library(ggtangle)




input_data <- read.csv("input.csv")
colnames(input_data)[1] <- "BACKGROUND"
background <- input_data$BACKGROUND
input_data$BACKGROUND <- NULL

cc_object <- compareCluster(geneCluster = input_data,
                    fun = "enrichGO",
                    OrgDb = organism,
                    keyType = "ENSEMBL",
                    minGSSize = 4,
                    maxGSSize = 400,
                    ont = "BP",
                    pAdjustMethod = "BH",
                    pvalueCutoff = 0.05,
                    qvalueCutoff = 0.01,
                    universe = background)

amended_cc_object <- pairwise_termsim(cc_object)   


set.seed(123456)

p1 <- emapplot(amended_cc_object,  layout = igraph::layout_with_fr, showCategory=30, node_label = "category",  group = FALSE,
               group_style = "ggforce",
               label_group_style = "shawdowtext",
               label_format = 30,
               clusterFunction = stats::kmeans,)

print(p1)

this is the code I use. I have used at least three datasets and emapplot is empty in all cases. It used to work on these before.

jalilsharif avatar Feb 10 '25 10:02 jalilsharif

How do you define 'empty'? Nothing is plotted?

Could it be no gene sets survive your significance cut-offs? What happens if you set these at 1 (for testing)?

What is the output of amended_cc_object?

Also, "if you want to keep the universe untouched, aka, not performing intersection with genes that have annotations, you can force it to do so via options(enrichment_force_universe = TRUE)." See: https://github.com/YuLab-SMU/clusterProfiler/issues/283#issuecomment-2071900048

guidohooiveld avatar Feb 11 '25 14:02 guidohooiveld

Hi Guidohooivedl

Jalil is on holiday this week. The error is pasted below and the data already is know to generate plottable objects from data we have previously ran successfully. He didn't leave any more detail regarding his conclusions above but using the code above the error we get is

p1b <- emapplot(amended_cc_object, pie.params = list(pie ="Count"), cex.params = list(category_node =3.0, cex_line=2.0, label_group=4.0),

  •             layout.params = list(layout ="fr"), repel =TRUE, cluster.params = list(cluster = TRUE, label_style='shadowtext', legend = TRUE, group = TRUE), node_label = "category") 
    

p1b Error in geom_edge_link(): ! Problem while converting geom to grob. ℹ Error occurred in the 1st layer. Caused by error in pathAttr(): ! long vectors not supported yet: /Volumes/Builds/R4/R-4.3.0/src/include/Rinlinedfuns.h:537 Run rlang::last_trace() to see where the error occurred.

jamietimmons avatar Feb 12 '25 13:02 jamietimmons

I see. It is difficult to provide help if not all variables/inputs are know.

Anyway: based on the error that was posted above ( /Volumes/Builds/R4/R-4.3.0/src/include/Rinlinedfuns.h:537) I deduce you are running a relatively old version of R (i.e. R-4.3.0) and associated Bioconductor packages. It also suggest that your are using a containerized installation (docker or conda or so).

Yet, when I start up R-4.3.0 that I still have installed at my computer, an emapplot is generated without error per your line of code (using the example dataset). See below. I suggest you rerun the analysis using the example dataset to deduce whether the error is caused by the input data (object) or R-installation.

> library(clusterProfiler)
> library(enrichplot)
> library(org.Hs.eg.db)
>  
> data(gcSample)
> 
> ## to limit universe to 'background'
> options(enrichment_force_universe = TRUE) 
> background <- unique( unlist(gcSample, use.names = FALSE) )
> 
> 
> cc_object <- compareCluster(geneCluster = gcSample,
+                     fun = "enrichGO",
+                     OrgDb = "org.Hs.eg.db",
+                     keyType = "ENTREZID",
+                     minGSSize = 4,
+                     maxGSSize = 400,
+                     ont = "BP",
+                     pAdjustMethod = "BH",
+                     pvalueCutoff = 0.1,
+                     qvalueCutoff = 1,
+                     universe = background)
> 
> amended_cc_object <- pairwise_termsim(cc_object)  
> ## R-4.3.0 (OLD)
> 
> p1b <- emapplot(amended_cc_object,
+                showCategory = 15,
+                pie.params = list(pie ="Count"),
+                cex.params = list(category_node =3.0,
+                    cex_line=2.0,
+                    label_group=4.0),
+                layout.params = list(layout ="fr"),
+                    repel = TRUE,
+                cluster.params = list(cluster = TRUE,
+                    label_style='shadowtext',
+                    legend = TRUE,
+                    group = TRUE),
+               node_label = "category") 
> 
> print(p1b)
Warning message:
ggrepel: 79 unlabeled data points (too many overlaps). Consider increasing max.overlaps 
> 
> packageVersion("clusterProfiler")
[1] ‘4.10.1’
> packageVersion("enrichplot")
[1] ‘1.23.1.992’
> BiocManager::version()
[1] ‘3.18’
> 
> 

Image

Moreover, note that since the current release of R/Bioconductor (i.e R-4.2.2 and Bioconductor 3.20) the cnetplot and emapplot functions have been completely rewritten by @GuangchuangYu (to allow better customization of these ggplot2-objects). As a consequence, the way arguments are provided to these functions also changed. In order to get the same plot that was generated in R-4.3.0 you will need to use this line of code: Note that the argument to increase the size of the node is not working; this bug has been reported, https://github.com/YuLab-SMU/enrichplot/issues/308

> library(clusterProfiler)
> library(enrichplot)
> library(org.Hs.eg.db)
>  
> data(gcSample)
> 
> ## to limit universe to 'background'
> options(enrichment_force_universe = TRUE) 
> background <- unique( unlist(gcSample, use.names = FALSE) )
> 
> 
> cc_object <- compareCluster(geneCluster = gcSample,
+                     fun = "enrichGO",
+                     OrgDb = "org.Hs.eg.db",
+                     keyType = "ENTREZID",
+                     minGSSize = 4,
+                     maxGSSize = 400,
+                     ont = "BP",
+                     pAdjustMethod = "BH",
+                     pvalueCutoff = 0.1,
+                     qvalueCutoff = 1,
+                     universe = background)
> 
> amended_cc_object <- pairwise_termsim(cc_object)  
> 
> ## R-4.4.2 (current)
> p1 <- emapplot(amended_cc_object,
+                showCategory = 15,
+                pie = "Count",
+                size_category = 3,
+                size_edge = 2,
+                layout = igraph::layout_with_fr,
+                clusterFunction = stats::kmeans,
+                label_group_style = "shawdowtext",
+                node_label = "category",
+                group = TRUE)
Coordinate system already present. Adding new coordinate system, which will
replace the existing one.
> 
> print(p1)
Warning message:
ggrepel: 21 unlabeled data points (too many overlaps). Consider increasing max.overlaps 
> 
> packageVersion("clusterProfiler")
[1] ‘4.14.4’
> packageVersion("enrichplot")
[1] ‘1.26.6’
> BiocManager::version()
[1] ‘3.20’
> 

Image

guidohooiveld avatar Feb 12 '25 21:02 guidohooiveld

Hi Guidohooivedl

So your test data/code yields the same error. We get this on two different mac OS installations Our input data has run successfully in past months on the current R versions (no use of containerized installation)

From the details below, we are using 4.15.1.1 for clusterprofiler and 1.24.4 for enrichplot - so later versions than your working code example. We did install the updated version of clusterprofiler and dependencies. So I will investigate the R version and package versions as you suggest.

We didn't know that cnetplot and emapplot functions have been completely rewritten by @GuangchuangYu

Thanks again for your help!

print(p1b) Error in geom_edge_link(): ! Problem while converting geom to grob. ℹ Error occurred in the 1st layer. Caused by error in pathAttr(): ! long vectors not supported yet: /Volumes/Builds/R4/R-4.3.0/src/include/Rinlinedfuns.h:537 Run rlang::last_trace() to see where the error occurred. packageVersion("clusterProfiler") [1] ‘4.15.1.1’ packageVersion("enrichplot") [1] ‘1.24.4’ BiocManager::version() [1] ‘3.17’

jamietimmons avatar Feb 13 '25 10:02 jamietimmons

A quick note for now: your version output shows that you are running an old Bioconductor installation (3.17, current is 3.20) together with the Github version of clusterProfiler (4.15.1.1, current is 4.14.4) and a previous version of enrichplot (1.24.4, current is 1.26.6).

Considering this I am not surprised you run into problems...

My suggestions:

  • install the latest versions of R and Bioconductor (preferred), or
  • run in Bioconductor 3.17 this line to install the compatible versions of clusterProfiler and enrichplot: BiocManager::install(c("clusterProfiler","enrichplot"), force=TRUE)

guidohooiveld avatar Feb 13 '25 10:02 guidohooiveld

Yes, thanks thats what I concluded from your advice - just in the proces of doing now - hopefully resolved after that.

Unfortunately we are running lots of legacy projects and legacy code....and any changes often lead to chaos in other projects, such is R and lack of a team of people to keep on top of all angles. So its don't change if not broken policy.

Your help much appreciated

jamietimmons avatar Feb 13 '25 11:02 jamietimmons

Ps we do use RSwitch on the MacOS to partly deal with the legacy vs current packages/code. Its a very useful and under appreciated little app.

jamietimmons avatar Feb 13 '25 11:02 jamietimmons

Hello,

I have tried installing cran/bioconductor enrich plot with clusterprofiler for Bioconductor 3.18 (R 4.3.3) and also 3.20 (R 4.4.2), only using the bioconductor packages, still getting the same error -

p1b
Error in geom_edge_link():
! Problem while converting geom to grob.
ℹ Error occurred in the 1st layer.
Caused by error in pathAttr():
! long vectors not supported yet: /Volumes/Builds/R4/R-4.3.0/src/include/Rinlinedfuns.h:537
Run rlang::last_trace() to see where the error occurred.

I have excluded the GitHub versions, so no mismatch of versions. I also tried the GitHub versions on 4.4.2 for both enrichplot and clusterprofiler, but the pie in the emapplot cannot be resized. It is not giving us an either labels, pies or no chart at all.

jalilsharif avatar Feb 19 '25 17:02 jalilsharif

Did you also load the library ggtangle? [ library(ggtangle) ]

guidohooiveld avatar Feb 24 '25 09:02 guidohooiveld

I tried both and it hasn't worked, the final solution so far, has been to install the GitHub version for enrichplot and that without ggtangle, however, then I am unable to resize the pie charts. I do not understand the inconsistency in behaviour, the limited information on dependency requirement.

jalilsharif avatar Feb 24 '25 10:02 jalilsharif

As said, there is indeed a known issue with resizing the nodes of an emapplot. This has been reported. See: https://github.com/YuLab-SMU/enrichplot/issues/308. Hopefully @GuangchuangYu is able to fix this quickly.

Also: in case more feedback is appreciated, it would be helpful if you could share (part of) your input file "input.csv".

guidohooiveld avatar Feb 24 '25 10:02 guidohooiveld