ctlab / fgsea

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

Error in plotGseaTable() #40

Closed PaulineMarangoni closed 5 years ago

PaulineMarangoni commented 5 years ago

Good evening!

I posted here a while ago when I was starting to get familiarized with the fgsea package, and the help that was provided to you helped me go a long way! I'm also done with my analyses, except that I am now generating panels that would be suitable for figures in articles. I am getting an error when trying to get the plotGseaTable() over and over again, and from what I understand it seems that it might be a formatting issue. I'm putting the code and the error below, I'd be happy to share more of the coding if that is necessary!

> topPathwaysUp_1.1 <- fgseaRes[ES > 0][head(order(pval), n=10), pathway] > topPathwaysDown_1.1 <- fgseaRes[ES < 0][head(order(pval), n=10), pathway] > topPathways_1.1 <- c(topPathwaysUp_1.1, rev(topPathwaysDown_1.1)) > plotGseaTable(examplePathways[topPathways_1.1], ranks_1.1, fgseaRes, gseaParam = 0.5) Error: Aesthetics must be either length 1 or the same as the data (1): x, xend, yend

Any idea / advice to fix this? Thanks much for your help! -Pauline

chrismiddleton commented 5 years ago

I'm having the same issue as Pauline above. You can reproduce the issue even when using the example pathways and ranks. Here's an example:

library(fgsea)
exampleResult <- fgsea(examplePathways, exampleRanks, 10)
plotGseaTable(examplePathways, exampleRanks, exampleResult)

Error:

Error: Aesthetics must be either length 1 or the same as the data (1): x, xend, yend
assaron commented 5 years ago

Could you paste your sessionInfo() output?

chrismiddleton commented 5 years ago

Here's the sessionInfo output before running the example above:

> library(fgsea)
Loading required package: Rcpp
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin17.7.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /usr/local/Cellar/openblas/0.3.5/lib/libopenblasp-r0.3.5.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] fgsea_1.8.0 Rcpp_1.0.1 

loaded via a namespace (and not attached):
 [1] magrittr_1.5        tidyselect_0.2.5    munsell_0.5.0       BiocParallel_1.16.6 lattice_0.20-38     colorspace_1.4-1   
 [7] R6_2.4.0            rlang_0.3.1         fastmatch_1.1-0     plyr_1.8.4          dplyr_0.8.0.1       tools_3.5.2        
[13] grid_3.5.2          data.table_1.12.0   gtable_0.2.0        yaml_2.2.0          lazyeval_0.2.2      assertthat_0.2.0   
[19] tibble_2.1.1        crayon_1.3.4        Matrix_1.2-16       gridExtra_2.3       purrr_0.3.2         ggplot2_3.1.0      
[25] glue_1.3.1          compiler_3.5.2      pillar_1.3.1        scales_1.0.0        pkgconfig_2.0.2    
> exampleResult <- fgsea(examplePathways, exampleRanks, 10)
> plotGseaTable(examplePathways, exampleRanks, exampleResult)
Error: Aesthetics must be either length 1 or the same as the data (1): x, xend, yend
assaron commented 5 years ago

Can you try to install the version from github with devtools::install_github("ctlab/fgsea") and check if the error still happens?

chrismiddleton commented 5 years ago

@assaron I just uninstalled the version I had and installed the latest from Github, but I got the same error when running this code:

> exampleResult <- fgsea(examplePathways, exampleRanks, 10)
> plotGseaTable(examplePathways, exampleRanks, exampleResult)
Error: Aesthetics must be either length 1 or the same as the data (1): x, xend, yend
assaron commented 5 years ago

@chrismiddleton Sorry, I can't reproduce this, so will have to ask for more details from you.

First of all, please confirm, that doing plotGseaTable(examplePathways[1], exampleRanks, exampleResult) also gives the error (normally it should plot table with only one pathway).

Second, please, paste here the output of traceback() call run just after the error occurs.

Finally, I suspect that the function check_aesthetics gives the error. So I would much appretiate if you make a breakpoint in it (with debug(ggplot2:::check_aesthetics), run the plotGseaTable function and print the values of check_aesthetics arguments: x and n.

For me it looks like this: 2019-03-29-191501_1916x1047_scrot

assaron commented 5 years ago

Oops, it's actually should be called three times, so after print(x) and print(n), enter f and repeat two more times.

2019-03-29-191844_1916x1047_scrot

chrismiddleton commented 5 years ago

@assaron Thanks for the info. Calling with examplePathways[1] works fine. It's the case where you pass the whole examplePathways that it fails with the error message. Does it succeed for you when passing the whole examplePathways?

assaron commented 5 years ago

Oh, got it. Never waited till the end. Yes, I can reproduce the error now.

assaron commented 5 years ago

It seems to happen, when the intersection between a pathway and the genes in the ranks vector is zero. For the examplePathways it's pathway 477 which contains only one gene, not present in the exampleRanks. Such pathways shouldn't have a significant p-value (and, actually, they should be filtered by the size option), so I don't quite understand, how it happend for you in the real case scenario.

chrismiddleton commented 5 years ago

@assaron Thank you for looking into it. I can't remember if I saw this with real data or just trying to run it with the examplePathways and exampleRanks. Perhaps I worded my initial comment poorly.