Open CarolynBluemcke opened 2 months ago
It is not clear to me what exactly you try to achieve. To increase your chance of getting more feedback I suggest your provide some reproducible code and a picture that illustrates your goal (and problem!).
Yes of course:
My problem is that in the ssplot() function the parameter group_legend=FALSE does not remove the group legend.
I attached a picture with the old result:
and a new result with the occurring legend:
I'm using the ssplot(x, ...) function with GSEA results. The GSEA results were obtained using the GSEA() function with logFC data.
Here is the code in the pipeline that is generating the plot using the previously generated GSEA results (GSEA_all_t2gr_absNES): print(ssplot(pairwise_termsim(GSEA_all_t2gr_absNES),color = "NES",node_label="category", group_legend=FALSE, cex.params = list(category_label = 1),with_edge=TRUE)+ ggtitle("GSEA MSigDb_ALL") + labs(subtitle = subtitle) + theme(plot.title = element_text(hjust = 0.5))+ scale_fill_gradient2(low = "#2166ac",high = "#b2182b", mid = "#f7f7f7", name = "NES"))
Aha, I got your point.
I have never prepared such similarity space plot before, but I believe I can reproduce your problem. That is, unfortunately, I also don't know how to remove the 2nd legend...
Since you indicate that with a previous version of enrichplot
it worked, but with the current version it doesn't anymore, it would be very helpful if you could post what the package versions are in both cases. You may want to use packageVersion("enrichplot")
.
I am pinging Guangchang as well;
@GuangchuangYu : could you please have a look at this? Also on the 'new' way of providing arguments to the ssplot
(i.e. arguments as lists). I tried but it seems these suggested lists (see below) are not recognized when I provide them.
Some reproducible code:
## load libraries
> library(clusterProfiler)
> library(org.Hs.eg.db)
> library(enrichplot)
>
> ## load example data
> data(geneList, package="DOSE")
>
> ## run GSEA using GOBP categories
> res <- gseGO(geneList = geneList,
+ OrgDb = org.Hs.eg.db,
+ ont = "BP",
+ eps = 0,
+ minGSSize = 15,
+ maxGSSize = 500,
+ pvalueCutoff = 0.05)
using 'fgsea' for GSEA analysis, please cite Korotkevich et al (2019).
preparing geneSet collections...
GSEA analysis...
leading edge analysis...
done...
>
> res2 <- pairwise_termsim(res)
>
> ## similarity space plot
> ssplot(res2, color = "NES")
Warning messages:
1: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'layout.params = list(coords = your_value)' instead of 'coords'.
The coords parameter will be removed in the next version.
2: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'edge.params = list(show = your_value)' instead of 'with_edge'.
The with_edge parameter will be removed in the next version.
3: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'cluster.params = list(cluster = your_value)' instead of 'group_category'.
The group_category parameter will be removed in the next version.
>
Thank you for your help The new version for the enrichplot package is 1.22.0 and the old one was 1.20.0
Aha, I now understand your issue; I observe the same as you do.
That is: in an older version of enrichplot
, the ssplot
is generated correctly, but in an newer version a 2nd legend is there (labelled color2
), and the generation of this legend cannot be disabled (the argument group_legend=FALSE
is not taken into account anymore).
Prepare and use the same data and results with both R
-versions.
## load libraries
library(clusterProfiler)
library(org.Hs.eg.db)
library(enrichplot)
## load and prepare example data / results
data(geneList, package="DOSE")
## run GSEA using GOBP categories
res <- gseGO(geneList = geneList,
OrgDb = org.Hs.eg.db,
ont = "BP",
eps = 0,
minGSSize = 15,
maxGSSize = 500,
pvalueCutoff = 0.05)
res2 <- pairwise_termsim(res)
When using an older version of R
and enrichplot
, ssplot
behaves as expected:
> R.Version()$version.string
[1] "R version 4.3.0 (2023-04-21 ucrt)"
> packageVersion('enrichplot')
[1] ‘1.23.1.992’
>
With group_legend=FALSE
:
ssplot(res2, color = "NES", group_legend=FALSE)
With group_legend=TRUE
:
ssplot(res2, color = "NES", group_legend=TRUE)
When using the latest version of enrichplot
, ssplot
produces a plot with a legend that cannot be disabled (and also is wrongly labelled (color2
)).
> R.Version()$version.string
[1] "R version 4.4.0 Patched (2024-05-21 r86580 ucrt)"
> packageVersion('enrichplot')
[1] ‘1.25.2.1’
>
With group_legend=FALSE
:
ssplot(res2, color = "NES", group_legend=FALSE)
With group_legend=TRUE
(= same plot as with FALSE
, but legend title is now groups
):
ssplot(res2, color = "NES", group_legend=TRUE)
Moreover, warnings are returned but the new way of specifying the arguments (as lists) doesn't seem to work either...
> ssplot(res2, color = "NES", group_legend=TRUE)
Warning messages:
1: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'layout.params = list(coords = your_value)' instead of 'coords'.
The coords parameter will be removed in the next version.
2: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'edge.params = list(show = your_value)' instead of 'with_edge'.
The with_edge parameter will be removed in the next version.
3: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'cluster.params = list(cluster = your_value)' instead of 'group_category'.
The group_category parameter will be removed in the next version.
4: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'cluster.params = list(legend = your_value)' instead of 'group_legend'.
The group_legend parameter will be removed in the next version.
>
Alright - thank you for all your help! Are you planning to correct this in a new version?
I have contacted Guangchuang Yu (@GuangchuangYu), the maintainer of enrichplot
, regarding this issue, so I assume he will fix this. I am not able to say anything regarding ETAs... Note that Moon Festival is being celebrated these days.
Hi! I have the same problem with emapplot, where the color2 legends cannot be turned off! I am using version 1.24.2. I note that in a previous version, the legends could be turned off as well.
Hi, I wanted to ask if it it possible to load an older version of enrichplot without changing the version of R using devtools?
I am currently using R Version 4.3.3 and BiocManager 3.18
The code became quite messy as my student was involved in the development, making it difficult to maintain. I’ve rewritten all the network visualization functions, primarily in this commit and this one. Please use the latest GitHub version and report any issues you encounter.
@GuangchuangYu: Thanks for having a look at this!
Unfortunately the latest GitHub version seems to have introduced some other bugs with ssplot
... One is on using an unused argument
, and if no argument is used an error is thrown regarding a clusterFunction parameter
.
The cnetplot
seems also not to work properly; for example the color of the nodes can not be changed.
The same for the emapplot
: no nodes are drawn.
> ## install latest version of enrichplot from GitHub
> ## I noticed the package ggtangle was also installed
> BiocManager::install(c('YuLab-SMU/enrichplot'), force=TRUE)
>
> <<snip>>
>
> ## run same example code as per post above
> ## load libraries
> library(clusterProfiler)
> library(org.Hs.eg.db)
> library(enrichplot)
>
> ## load and prepare example data / results
> data(geneList, package="DOSE")
>
> ## run GSEA using GOBP categories
> res <- gseGO(geneList = geneList,
+ OrgDb = org.Hs.eg.db,
+ ont = "BP",
+ eps = 0,
+ minGSSize = 15,
+ maxGSSize = 500,
+ pvalueCutoff = 0.05)
>
> res2 <- pairwise_termsim(res)
>
ssplot()
> ssplot(res2, color = "NES", group_legend=TRUE)
Error in emapplot_internal(x, showCategory = showCategory, ...) :
unused argument (group_legend = TRUE)
>
> ssplot(res2, color = "NES")
Wrong clusterFunction parameter or unsupported clustering method; set to default `clusterFunction = kmeans`
Error: number of cluster centres must lie between 1 and nrow(x)
>
> ssplot(res2)
Wrong clusterFunction parameter or unsupported clustering method; set to default `clusterFunction = kmeans`
Error: number of cluster centres must lie between 1 and nrow(x)
>
cnetplot
> cnetplot(res2, showCategory = 5, color_category = "#94e5b6")
Warning message:
ggrepel: 1 unlabeled data points (too many overlaps). Consider increasing max.overlaps
>
Expected node color (#94e5b6):
emapplot
> emapplot(res2, showCategory = 5)
>
No nodes are drawn.
> packageVersion("enrichplot")
[1] ‘1.25.5’
> packageVersion("ggtangle")
[1] ‘0.0.3’
> packageVersion("clusterProfiler")
[1] ‘4.12.6’
>
> sessionInfo()
R version 4.4.0 Patched (2024-05-21 r86580 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: Europe/Amsterdam
tzcode source: internal
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] enrichplot_1.25.5 org.Hs.eg.db_3.19.1 AnnotationDbi_1.66.0
[4] IRanges_2.38.1 S4Vectors_0.42.1 Biobase_2.64.0
[7] BiocGenerics_0.50.0 clusterProfiler_4.12.6
loaded via a namespace (and not attached):
[1] tidyselect_1.2.1 dplyr_1.1.4 farver_2.1.2
[4] blob_1.2.4 R.utils_2.12.3 Biostrings_2.72.1
[7] lazyeval_0.2.2 fastmap_1.2.0 digest_0.6.37
[10] lifecycle_1.0.4 KEGGREST_1.44.1 tidytree_0.4.6
[13] RSQLite_2.3.7 magrittr_2.0.3 compiler_4.4.0
[16] rlang_1.1.4 tools_4.4.0 igraph_2.1.1
[19] utf8_1.2.4 data.table_1.16.2 ggtangle_0.0.3
[22] labeling_0.4.3 bit_4.5.0 gson_0.1.0
[25] plyr_1.8.9 RColorBrewer_1.1-3 aplot_0.2.3
[28] BiocParallel_1.38.0 withr_3.0.1 purrr_1.0.2
[31] R.oo_1.26.0 grid_4.4.0 fansi_1.0.6
[34] GOSemSim_2.31.2 colorspace_2.1-1 GO.db_3.19.1
[37] ggplot2_3.5.1 scales_1.3.0 cli_3.6.3
[40] crayon_1.5.3 treeio_1.28.0 generics_0.1.3
[43] ggtree_3.12.0 httr_1.4.7 reshape2_1.4.4
[46] ape_5.8 DBI_1.2.3 qvalue_2.36.0
[49] cachem_1.1.0 DOSE_3.99.1 stringr_1.5.1
[52] zlibbioc_1.50.0 splines_4.4.0 parallel_4.4.0
[55] ggplotify_0.1.2 XVector_0.44.0 yulab.utils_0.1.7
[58] vctrs_0.6.5 Matrix_1.7-1 jsonlite_1.8.9
[61] tidydr_0.0.5 gridGraphics_0.5-1 patchwork_1.3.0
[64] bit64_4.5.2 ggrepel_0.9.6 ggnewscale_0.5.0
[67] tidyr_1.3.1 snow_0.4-4 glue_1.8.0
[70] codetools_0.2-20 cowplot_1.1.3 stringi_1.8.4
[73] gtable_0.3.5 GenomeInfoDb_1.40.1 UCSC.utils_1.0.0
[76] munsell_0.5.1 tibble_3.2.1 pillar_1.9.0
[79] fgsea_1.30.0 GenomeInfoDbData_1.2.12 R6_2.5.1
[82] lattice_0.22-6 R.methodsS3_1.8.2 png_0.1-8
[85] memoise_2.0.1 ggfun_0.1.7 Rcpp_1.0.13
[88] fastmatch_1.1-4 nlme_3.1-166 fs_1.6.4
[91] pkgconfig_2.0.3
>
Added: for completeness / reference the output generated by enrichplot
1.25.3
(and not 1.25.5
).
Using the same code as above: ssplot:
> ssplot(res2, color = "NES", group_legend=TRUE)
Warning messages:
1: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'layout.params = list(coords = your_value)' instead of 'coords'.
The coords parameter will be removed in the next version.
2: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'edge.params = list(show = your_value)' instead of 'with_edge'.
The with_edge parameter will be removed in the next version.
3: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'cluster.params = list(cluster = your_value)' instead of 'group_category'.
The group_category parameter will be removed in the next version.
4: In emapplot.enrichResult(x, showCategory = showCategory, ...) :
Use 'cluster.params = list(legend = your_value)' instead of 'group_legend'.
The group_legend parameter will be removed in the next version.
>
cnetplot:
> cnetplot(res2, showCategory = 5, color_category = "#94e5b6")
Warning messages:
1: In cnetplot.enrichResult(x, ...) :
Use 'color.params = list(category = your_value)' instead of 'color_category'.
The color_category parameter will be removed in the next version.
2: ggrepel: 3 unlabeled data points (too many overlaps). Consider increasing max.overlaps
>
emapplot:
> emapplot(res2, showCategory = 5)
>
> packageVersion("enrichplot")
[1] ‘1.25.3’
emapplot
is fine. I can't reproduce the issue.
For the ssplot
issue, the parameter group_legend
was change to group
.
Thanks for the updates, yet it still isn't working for me...
ssplot: Error still is thrown regarding clustering method....
> ssplot(res2, color = "NES", group = TRUE)
Wrong clusterFunction parameter or unsupported clustering method; set to default `clusterFunction = kmeans`
Error: number of cluster centres must lie between 1 and nrow(x)
>
emapplot: Same, empty graphics window as earlier reporrted is returned (so only lines are there).
See screenshot above, and attached PDF. Maybe this is specific for Windows? emapplot.test.pdf
> pdf("emapplot.test.pdf")
> emapplot(res2, showCategory = 5)
> dev.off()
windows
2
A am out of clues on what may cause this emapplot
behavior.... Will wait until the end of the week for the release of R-4.2.2
and Bioconductor 3.20,
to see whether this may be solved..
> packageVersion("enrichplot")
[1] ‘1.25.6’
>
> packageVersion("ggtangle")
[1] ‘0.0.4’
>
> sessionInfo()
R version 4.4.2 RC (2024-10-23 r87274 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: Europe/Amsterdam
tzcode source: internal
attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] DOSE_3.99.1 GOSemSim_2.31.2 enrichplot_1.25.6
[4] org.Hs.eg.db_3.19.1 AnnotationDbi_1.66.0 IRanges_2.38.1
[7] S4Vectors_0.42.1 Biobase_2.64.0 BiocGenerics_0.50.0
[10] clusterProfiler_4.13.4
loaded via a namespace (and not attached):
[1] tidyselect_1.2.1 dplyr_1.1.4 farver_2.1.2
[4] blob_1.2.4 R.utils_2.12.3 Biostrings_2.72.1
[7] lazyeval_0.2.2 fastmap_1.2.0 digest_0.6.37
[10] lifecycle_1.0.4 KEGGREST_1.44.1 tidytree_0.4.6
[13] RSQLite_2.3.7 magrittr_2.0.3 compiler_4.4.2
[16] rlang_1.1.4 tools_4.4.2 igraph_2.1.1
[19] utf8_1.2.4 ggtangle_0.0.4 data.table_1.16.2
[22] labeling_0.4.3 bit_4.5.0 curl_5.2.3
[25] gson_0.1.0 plyr_1.8.9 RColorBrewer_1.1-3
[28] aplot_0.2.3 BiocParallel_1.38.0 withr_3.0.1
[31] purrr_1.0.2 R.oo_1.26.0 grid_4.4.2
[34] fansi_1.0.6 colorspace_2.1-1 GO.db_3.19.1
[37] ggplot2_3.5.1 scales_1.3.0 cli_3.6.3
[40] crayon_1.5.3 treeio_1.28.0 generics_0.1.3
[43] remotes_2.5.0 ggtree_3.12.0 httr_1.4.7
[46] reshape2_1.4.4 ape_5.8 DBI_1.2.3
[49] qvalue_2.36.0 cachem_1.1.0 stringr_1.5.1
[52] zlibbioc_1.50.0 splines_4.4.2 parallel_4.4.2
[55] ggplotify_0.1.2 BiocManager_1.30.25 XVector_0.44.0
[58] yulab.utils_0.1.7 vctrs_0.6.5 Matrix_1.7-1
[61] jsonlite_1.8.9 tidydr_0.0.5 gridGraphics_0.5-1
[64] patchwork_1.3.0 bit64_4.5.2 ggrepel_0.9.6
[67] ggnewscale_0.5.0 tidyr_1.3.1 snow_0.4-4
[70] glue_1.8.0 codetools_0.2-20 cowplot_1.1.3
[73] stringi_1.8.4 gtable_0.3.6 GenomeInfoDb_1.40.1
[76] UCSC.utils_1.0.0 munsell_0.5.1 tibble_3.2.1
[79] pillar_1.9.0 fgsea_1.30.0 GenomeInfoDbData_1.2.12
[82] R6_2.5.1 lattice_0.22-6 R.methodsS3_1.8.2
[85] png_0.1-8 memoise_2.0.1 ggfun_0.1.7
[88] Rcpp_1.0.13 fastmatch_1.1-4 nlme_3.1-166
[91] fs_1.6.4 pkgconfig_2.0.3
>
maybe you can wait for the new release of Bioconductor, so that our session info is similar with all are latest release versions.
for goplot
, I just change it to label as Description
and can be use GOID if specify ID = "ID"
.
It now also supports formatted the label, e.g., `ID="{ID}\n{Description}" produce:
maybe you can wait for the new release of Bioconductor, so that our session info is similar with all are latest release versions.
I updated to the new (latest) release of R
, Bioconductor
, clusterProfiler
and enrichplot
, and the graphs that gave me problems are now properly generated!
> R.Version()$version.string
[1] "R version 4.4.2 (2024-10-31 ucrt)"
> packageVersion("clusterProfiler")
[1] ‘4.14.0’
> packageVersion("enrichplot")
[1] ‘1.26.1’
>
Hi, I'm working with a Pipeline using the Space Layout and Concept Networks. In contrast to previous executions with the same code a second legend "color 2" appears in both plots. This disrupts the layout of the plots due to the long generated names.
I tried to set group_legend=FALSE (even though it should already be the default) and group_legend=TRUE - but this only changed the order of the 2 displayed legends without removing it.
How can I stop the display of this legend? I would really appreciate the help. Thank you. Carolyn