ctlab / fgsea

Fast Gene Set Enrichment Analysis
Other
379 stars 67 forks source link

plotGseaTable not displaying the results #101

Closed RobertWhitener closed 2 years ago

RobertWhitener commented 3 years ago

Hi,

I'm having an issue with getting plotGseaTable to actually render the table. Besides explicitly loading the gridExtra package, I have copied the Vignette code directly, and everything else is working, including the enrichment graph for Programmed Cell Death. I also have everything else working using my own RNK and pathways files using the examples from the vignette

I am able to write the image out to a file using png() and then dev.off(), but I would prefer to inspect the plot before writing tons of files to disk while trying to adjust simple parameters to get things looking nice.

I've tried both using the render = FALSE and render = TRUE and rendering later, with the same effect, so I'm wondering if it is something going on with my RStudio?

Thanks! Robert

Here is my sessionInfo():

`> sessionInfo() R version 4.1.0 (2021-05-18) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252

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

other attached packages: [1] gridExtra_2.3 ggplot2_3.3.5 fgsea_1.19.2 data.table_1.14.0

loaded via a namespace (and not attached): [1] Rcpp_1.0.7 pillar_1.6.1 compiler_4.1.0 tools_4.1.0 digest_0.6.27 evaluate_0.14 lifecycle_1.0.0
[8] tibble_3.1.2 gtable_0.3.0 lattice_0.20-44 pkgconfig_2.0.3 rlang_0.4.11 Matrix_1.3-3 fastmatch_1.1-0
[15] rstudioapi_0.13 cli_3.0.1 patchwork_1.1.1 yaml_2.2.1 parallel_4.1.0 xfun_0.24 withr_2.4.2
[22] dplyr_1.0.7 knitr_1.33 generics_0.1.0 vctrs_0.3.8 grid_4.1.0 tidyselect_1.1.1 glue_1.4.2
[29] R6_2.5.0 snow_0.4-3 fansi_0.5.0 BiocParallel_1.26.1 rmarkdown_2.9 farver_2.1.0 purrr_0.3.4
[36] magrittr_2.0.1 scales_1.1.1 ellipsis_0.3.2 htmltools_0.5.1.1 colorspace_2.0-2 labeling_0.4.2 utf8_1.2.1
[43] munsell_0.5.0 crayon_1.4.1 `

assaron commented 3 years ago

Are there any errors or warnings? Ensure that you have Rstudio plot panel to be showing and of sufficient size. You can also try to call dev.off(); dev.new() before plotGseaTable call.

RobertWhitener commented 3 years ago

Hi Assaron,

The code completes without showing any errors or warnings. It just doesn't display it either in the plot panel or inline.

If I call dev.off() first, my code stops because it can't shut off the null device.

If I use: dev.new() ; plotGseaTable(pathways, stats, fgseaRes, render = TRUE) ; dev.off(); I don't get any output except "null device 1" (from the dev.off() command).

While: dev.new(); plotGseaTable(pathways, stats, fgseaRes, render = FALSE) ; dev.off();

Outputs a df.

assaron commented 3 years ago

Calling multiple times dev.off() until it fails and then running dev.new() closes all the old devices, in case there are some problems with that.

Does simple base R plotting works for you? For example plot(1) and grid::grid.draw(grid::textGrob("asdf")).

assaron commented 3 years ago

Also, did you try to upgrade you rstudio to the latest version?

RobertWhitener commented 3 years ago

Hi,

my RStudio is Version 1.4.1717 (the latest version according to the Update option).

Since I had the console open for my other issue I have open, I also just tried the plotGseaTable() directly from the console. plot(1) and grid::grid.draw(grid::textGrob("asdf")) open a new device and draw the output correctly in both R console and RStudio.

however

>plotGseaTable(pathways=PATHWAY, stats = STATS, fgseaRes = RESULTS)

in R console correctly opens a new device but never draws the plot (it just processes indefinitely). Closing all devices then calling dev.new() first results in the same behavior.

assaron commented 3 years ago

Sorry, but I have now ideas what else to try.

RobertWhitener commented 3 years ago

Thanks for the assistance with trying to figure this out! I'll keep poking at it and let you know if I discover anything.

melonheader commented 2 years ago

Hi @RobertWhitener @assaron ,

I stumbled upon the same problem. To my suprise, wrapping plotGseaTable(pathways, stats, fgseaRes, render = FALSE) call inside of as_ggplot()solves the issue. Maybe there were some package updates that silently changed behaviour of the original function?

Overall, plotGseaTable(pathways, stats, fgseaRes, render = T) returns NULL as_ggplot( plotGseaTable(pathways, stats, fgseaRes, render = F) ) returns the plot

assaron commented 2 years ago

@melonheader Thanks for the workaround. As I can't reproduce the issue, it's hard to debug it and make a fix. Probably going fully for ggplot here could indeed solve the problem.

camvanbergen commented 2 years ago

Thanks for the as_ggplot, worked in my case! (don't forget to load the package or type ggpubr::as_ggplot...)

assaron commented 2 years ago

Thanks everyone, I've switched to cowplot::plot_grid for arranging element, now it should work fine for everyone

mem728 commented 2 years ago

Hi @assaron , I just wanted to let you know that today I had the same problem described here, I reinstalled fgsea (which didn't solve the issue) before finding this thread and using as_ggplot (which did solve the issue). For me, the plot didn't render in rstudio or when trying to save as a pdf. Because as_ggplot works it's not an issue, but I wanted to let you know that I don't think switching to cowplot fixed it.

assaron commented 2 years ago

@mem728 Did you install the package from github? The version with fixes is not yet available at Bioconductor