thackl / gggenomes

A grammar of graphics for comparative genomics
https://thackl.github.io/gggenomes/
Other
606 stars 65 forks source link

ggplot2 error using example data #138

Closed jzluo closed 1 year ago

jzluo commented 1 year ago

Hi, I'm running into an issue that also occurs with the example data:

seqs <- read_seqs(ex("emales/emales.fna"))
gggenomes(seqs=seqs)
Reading 'fasta' with `read_seq_len()`:
* file_id: emales [/home/jon/projects/pkdplot/renv/library/R-4.2/x86_64-pc-linux-gnu/gggenomes/extdata/emales/emales.fna]
Error in `geom_blank()`:
! Problem while computing layer data.
ℹ Error occurred in the 1st layer.
Caused by error in `unrowname()`:
! Can only remove rownames from <data.frame> and <matrix> objects
Backtrace:
  1. base (local) `<fn>`(x)
  2. ggplot2:::print.ggplot(x)
  4. ggplot2:::ggplot_build.ggplot(x)
  5. ggplot2:::by_layer(...)
 12. ggplot2 (local) f(l = layers[[i]], d = data[[i]])
 13. l$layer_data(plot$data)
 14. ggplot2::layer_data(..., self = self)
 15. ggplot2:::unrowname(data)
 Error in geom_blank() : 
ℹ Error occurred in the 1st layer.
Caused by error in `unrowname()`:
! Can only remove rownames from <data.frame> and <matrix> objects
> sessionInfo()
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 22.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] gggenomes_0.9.5.9000 snakecase_0.11.0     jsonlite_1.8.4       thacklr_0.0.0.9000   gggenes_0.4.1       
 [6] vctrs_0.5.1          forcats_0.5.2        stringr_1.5.0        dplyr_1.0.10         purrr_1.0.0         
[11] readr_2.1.3          tidyr_1.2.1          tibble_3.1.8         ggplot2_3.4.0        tidyverse_1.3.2     

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.0    xfun_0.36           haven_2.5.1         gargle_1.2.1        colorspace_2.0-3   
 [6] generics_0.1.3      utf8_1.2.2          rlang_1.0.6         pillar_1.8.1        glue_1.6.2         
[11] withr_2.5.0         DBI_1.1.3           bit64_4.0.5         dbplyr_2.2.1        modelr_0.1.10      
[16] readxl_1.4.1        lifecycle_1.0.3     ggfittext_0.9.1     munsell_0.5.0       gtable_0.3.1       
[21] cellranger_1.1.0    rvest_1.0.3         knitr_1.41          tzdb_0.3.0          parallel_4.2.2     
[26] fansi_1.0.3         broom_1.0.2         renv_0.16.0         scales_1.2.1        backports_1.4.1    
[31] googlesheets4_1.0.1 vroom_1.6.0         bit_4.0.5           fs_1.5.2            hms_1.1.2          
[36] stringi_1.7.8       grid_4.2.2          cli_3.5.0           tools_4.2.2         magrittr_2.0.3     
[41] crayon_1.5.2        pkgconfig_2.0.3     ellipsis_0.3.2      xml2_1.3.3          reprex_2.0.2       
[46] googledrive_2.0.0   lubridate_1.9.0     timechange_0.1.1    assertthat_0.2.1    httr_1.4.4         
[51] rstudioapi_0.14     R6_2.5.1            compiler_4.2.2
jzluo commented 1 year ago

This appears to be fixed by downgrading ggplot2 from 3.4.0 to 3.3.6.

shaodongyan commented 1 year ago

This appears to be fixed by downgrading ggplot2 from 3.4.0 to 3.3.6.

But Error: package ‘ggplot2’ 3.3.6 is loaded, but >= 3.4.0 is required by ‘gggenomes’

matinnuhamunada commented 1 year ago

I have the same issue, how do you downgrade ggplot2 to 3.3.6 @jzluo?

lukesarre commented 1 year ago

I've also run into the same problem. Has anyone else been able to downgrade ggplot2 successfully, or otherwise get around this issue?

iimog commented 1 year ago

I can reproduce the issue. I'll try to look into this as soon as possible.

thackl commented 1 year ago

This only happened if gggenomes() was called without any + geom_*. In that case, a geom_blank() is added automatically. But geom_blank() is not a aware of the gggenomes internal data structure and tried to access the wrong data, causing the error. This should now be fixed