thackl / gggenomes

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

geom_gene() doesn't work #148

Closed kir1to455 closed 1 year ago

kir1to455 commented 1 year ago

Hi thackl, When I use geom_gene() to plot "emale_genes" data, it works perfectly! gggenomes(emale_genes) + geom_gene(aes(fill=strand), position="strand") However, when I use geom_gene() in my dataset, the picture it draws is blank. Therefore, I use dplyr::select(seq_id,start,end,strand) for "emale_genes" dataset. test2 <- emale_genes %>% dplyr::select(seq_id,start,end,strand) gggenomes(genes = test2 )+ geom_gene(aes(fill=strand), position="strand") Surprisingly, it can no longer work. Did I miss any parameters?

Best wishes, Kirito

thackl commented 1 year ago

Hi Kirito,

thanks for reaching out. Not sure what the problem is. I ran your code and both versions work for me. Can you share the output of sessionInfo(). Do you get any other warnings or so

p1 <- gggenomes(emale_genes) + geom_gene(aes(fill=strand), position="strand")

test2 <- emale_genes %>% dplyr::select(seq_id,start,end,strand)
p2 <- gggenomes(genes = test2 )+ geom_gene(aes(fill=strand), position="strand")

p1+p2

image

kir1to455 commented 1 year ago

Thanks for your reply so fast! Here is my sessionInfo:

sessionInfo() R version 4.1.3 (2022-03-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS: /usr/bin/R-4.1.3/lib64/R/lib/libRblas.so LAPACK: /usr/bin/R-4.1.3/lib64/R/lib/libRlapack.so

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

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

other attached packages: [1] gggenomes_0.9.7.9000 snakecase_0.11.0 jsonlite_1.8.3 tibble_3.1.8 thacklr_0.0.0.9000 tidyr_1.2.1 stringr_1.4.1
[8] readr_2.1.3 purrr_0.3.5 gggenes_0.4.1 vctrs_0.5.0 ggplot2_3.4.1 dplyr_1.0.10

loaded via a namespace (and not attached): [1] bitops_1.0-7 matrixStats_0.63.0 fs_1.5.2 usethis_2.1.6 devtools_2.4.5
[6] rprojroot_2.0.3 GenomeInfoDb_1.30.1 tools_4.1.3 profvis_0.3.7 utf8_1.2.3
[11] R6_2.5.1 DBI_1.1.3 BiocGenerics_0.40.0 colorspace_2.1-0 urlchecker_1.0.1
[16] withr_2.5.0 tidyselect_1.2.0 prettyunits_1.1.1 processx_3.8.0 curl_4.3.3
[21] compiler_4.1.3 textshaping_0.3.6 cli_3.6.0 Biobase_2.54.0 desc_1.4.2
[26] DelayedArray_0.20.0 labeling_0.4.2 rtracklayer_1.54.0 scales_1.2.1 callr_3.7.3
[31] systemfonts_1.0.4 digest_0.6.30 Rsamtools_2.10.0 XVector_0.34.0 pkgconfig_2.0.3
[36] htmltools_0.5.3 sessioninfo_1.2.2 MatrixGenerics_1.6.0 fastmap_1.1.0 htmlwidgets_1.5.4
[41] rlang_1.0.6 rstudioapi_0.14 shiny_1.7.3 farver_2.1.1 BiocIO_1.4.0
[46] generics_0.1.3 BiocParallel_1.28.3 RCurl_1.98-1.9 magrittr_2.0.3 GenomeInfoDbData_1.2.7
[51] Matrix_1.5-3 Rcpp_1.0.10 munsell_0.5.0 S4Vectors_0.32.4 fansi_1.0.4
[56] ggfittext_0.9.1 lifecycle_1.0.3 stringi_1.7.8 yaml_2.3.6 SummarizedExperiment_1.24.0 [61] zlibbioc_1.40.0 pkgbuild_1.4.0 grid_4.1.3 parallel_4.1.3 promises_1.2.0.1
[66] crayon_1.5.2 miniUI_0.1.1.1 lattice_0.20-45 Biostrings_2.62.0 hms_1.1.2
[71] ps_1.7.2 pillar_1.8.1 GenomicRanges_1.46.1 rjson_0.2.21 stats4_4.1.3
[76] pkgload_1.3.2 XML_3.99-0.12 glue_1.6.2 remotes_2.4.2 tzdb_0.3.0
[81] httpuv_1.6.6 gtable_0.3.1 assertthat_0.2.1 cachem_1.0.6 mime_0.12
[86] xtable_1.8-4 restfulr_0.0.15 later_1.3.0 ragg_1.2.4 GenomicAlignments_1.30.0
[91] memoise_2.0.1 IRanges_2.28.0 ellipsis_0.3.2

thackl commented 1 year ago

OK, I think I found the problem. The easiest workaround for you right now should be to add a column type="CDS" to your data.

I'll try to fix the underlying problem in the package when I have more time.

test2 <- emale_genes %>% dplyr::transmute(seq_id,start,end,strand,type="CDS")
kir1to455 commented 1 year ago

Hi thackl, When I add a column type="CDS" ,it can run normally now. Thank you again for your timely reply. Looking forward to the new version of gggenomes!

Best Wishes, Kirito

thackl commented 1 year ago

The latest version should now also be able again to show genes if you don't explicitly provide them with type="CDS".