neurogenomics / EpiCompare

Comparison, benchmarking & QC of epigenetic datasets
https://doi.org/doi:10.18129/B9.bioc.EpiCompare
12 stars 3 forks source link

`downloadthis:::download_this.ggplot(...)`: `Error: ! Unknown graphics device "rds"` #142

Closed bschilder closed 1 year ago

bschilder commented 1 year ago

1. Bug description

Seems to occur when I pass a plotly object directly to download_button

Console output

Error:
! Unknown graphics device "rds"
Backtrace:
 1. EpiCompare::download_button(...)
 3. downloadthis:::download_this.ggplot(...)
 5. ggplot2 (local) `<fn>`(device = "rds", plot = `<gg>`, filename = `<fs::path>`)
Quitting from lines 311-327 (EpiCompare.Rmd) 
Error: [ENOENT] Failed to remove '/var/folders/zq/h7mtybc533b1qzkys_ttgpth0000gn/T/RtmpLk9ikT/filee00679d24958.rds': no such file or directory 

Expected behaviour

Generates button to download plotly object.

2. Reproducible example

Code

{
  data("encode_H3K27ac")
  data("CnT_H3K27ac")
  data("CnR_H3K27ac")
  data("CnT_H3K27ac_picard")
  data("CnR_H3K27ac_picard")
  # Create directory for test outputs
  outpath <- file.path(tempdir(),"EpiCompare_testthat") 
  # create named peaklist, reference and picard list
  peaklist <- list("CnT"=CnT_H3K27ac, "CnR"=CnR_H3K27ac)
  reference <- list("ENCODE"=encode_H3K27ac)
  picard_list <- list("CnT"=CnT_H3K27ac_picard, "CnR"=CnR_H3K27ac_picard)
}
html_file <- EpiCompare::EpiCompare(peakfiles = peaklist,
                                      genome_build = "hg19", 
                                      picard_files = picard_list,
                                      reference = NULL,
                                      interact = TRUE,
                                      tss_distance = c(-50,50),
                                      run_all = TRUE,
                                      output_dir = outpath)

3. Session info

(Add output of the R function utils::sessionInfo() below. This helps us assess version/OS conflicts which could be causing bugs.)

``` R version 4.2.1 (2022-06-23) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Monterey 12.4 Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.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] EpiCompare_1.3.3 loaded via a namespace (and not attached): [1] utf8_1.2.3 tidyselect_1.2.0 [3] RSQLite_2.2.20 AnnotationDbi_1.60.0 [5] htmlwidgets_1.6.1 grid_4.2.1 [7] BiocParallel_1.32.5 scatterpie_0.1.8 [9] munsell_0.5.0 ragg_1.2.5 [11] codetools_0.2-19 withr_2.5.0 [13] colorspace_2.1-0 GOSemSim_2.24.0 [15] Biobase_2.58.0 filelock_1.0.2 [17] highr_0.10 knitr_1.42 [19] rstudioapi_0.14 stats4_4.2.1 [21] DOSE_3.24.2 MatrixGenerics_1.10.0 [23] GenomeInfoDbData_1.2.9 polyclip_1.10-4 [25] seqPattern_1.30.0 bit64_4.0.5 [27] farver_2.1.1 vctrs_0.5.2 [29] treeio_1.22.0 generics_0.1.3 [31] xfun_0.37 timechange_0.2.0 [33] BiocFileCache_2.6.0 downloadthis_0.3.2 [35] R6_2.5.1 GenomeInfoDb_1.34.9 [37] graphlayouts_0.8.4 locfit_1.5-9.7 [39] bitops_1.0-7 BRGenomics_1.10.0 [41] cachem_1.0.6 fgsea_1.24.0 [43] gridGraphics_0.5-1 DelayedArray_0.24.0 [45] assertthat_0.2.1 vroom_1.6.1 [47] promises_1.2.0.1 BiocIO_1.8.0 [49] scales_1.2.1 ggraph_2.1.0 [51] enrichplot_1.18.3 gtable_0.3.1 [53] tidygraph_1.2.3 rlang_1.0.6 [55] systemfonts_1.0.4 splines_4.2.1 [57] rtracklayer_1.58.0 lazyeval_0.2.2 [59] impute_1.72.3 bsplus_0.1.4 [61] BiocManager_1.30.19 yaml_2.3.7 [63] reshape2_1.4.4 GenomicFeatures_1.50.4 [65] httpuv_1.6.9 qvalue_2.30.0 [67] tools_4.2.1 ggplotify_0.1.0 [69] gridBase_0.4-7 ggplot2_3.4.1 [71] ellipsis_0.3.2 gplots_3.1.3 [73] jquerylib_0.1.4 RColorBrewer_1.1-3 [75] BiocGenerics_0.44.0 Rcpp_1.0.10 [77] plyr_1.8.8 base64enc_0.1-3 [79] progress_1.2.2 zlibbioc_1.44.0 [81] purrr_1.0.1 RCurl_1.98-1.10 [83] prettyunits_1.1.1 viridis_0.6.2 [85] cowplot_1.1.1 S4Vectors_0.36.1 [87] SummarizedExperiment_1.28.0 ggrepel_0.9.3 [89] fs_1.6.1 magrittr_2.0.3 [91] data.table_1.14.6 matrixStats_0.63.0 [93] hms_1.1.2 patchwork_1.1.2 [95] mime_0.12 evaluate_0.20 [97] xtable_1.8-4 HDO.db_0.99.1 [99] XML_3.99-0.13 IRanges_2.32.0 [101] gridExtra_2.3 testthat_3.1.6 [103] compiler_4.2.1 biomaRt_2.54.0 [105] tibble_3.1.8 KernSmooth_2.23-20 [107] crayon_1.5.2 shadowtext_0.1.2 [109] htmltools_0.5.4 ggfun_0.0.9 [111] later_1.3.0 tzdb_0.3.0 [113] tidyr_1.3.0 geneplotter_1.76.0 [115] aplot_0.1.9 lubridate_1.9.2 [117] DBI_1.1.3 tweenr_2.0.2 [119] ChIPseeker_1.34.1 genomation_1.30.0 [121] dbplyr_2.3.0 MASS_7.3-58.2 [123] rappdirs_0.3.3 boot_1.3-28.1 [125] Matrix_1.5-3 readr_2.1.4 [127] brio_1.1.3 cli_3.6.0 [129] parallel_4.2.1 igraph_1.4.0 [131] GenomicRanges_1.50.2 pkgconfig_2.0.3 [133] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 GenomicAlignments_1.34.0 [135] plotly_4.10.1 xml2_1.3.3 [137] ggtree_3.6.2 annotate_1.76.0 [139] bslib_0.4.2 XVector_0.38.0 [141] yulab.utils_0.0.6 stringr_1.5.0 [143] digest_0.6.31 Biostrings_2.66.0 [145] rmarkdown_2.20.1 fastmatch_1.1-3 [147] tidytree_0.4.2 restfulr_0.0.15 [149] curl_5.0.0 shiny_1.7.4 [151] Rsamtools_2.14.0 gtools_3.9.4 [153] rjson_0.2.21 lifecycle_1.0.3 [155] nlme_3.1-162 jsonlite_1.8.4 [157] viridisLite_0.4.1 BSgenome_1.66.2 [159] fansi_1.0.4 pillar_1.8.1 [161] lattice_0.20-45 KEGGREST_1.38.0 [163] fastmap_1.1.0 httr_1.4.4 [165] plotrix_3.8-2 GO.db_3.16.0 [167] interactiveDisplayBase_1.36.0 glue_1.6.2 [169] png_0.1-8 BiocVersion_3.16.0 [171] bit_4.0.5 ggforce_0.4.1 [173] stringi_1.7.12 sass_0.4.5 [175] blob_1.2.3 textshaping_0.3.6 [177] DESeq2_1.38.3 AnnotationHub_3.6.0 [179] caTools_1.18.2 memoise_2.0.1 [181] dplyr_1.1.0 ape_5.6-2 ```
bschilder commented 1 year ago

This seems to be resolved when I pass download_button() a named list (with the plot and the data) rather than just the plotly object itself. This is a good idea to have anyways, as it enhanced reproducibility and flexibility of the plots.

download_button(object=plotly_object, ...)

# vs.

download_button(object=list(plot=plotly_object, data=plotly_data), ...) 
bschilder commented 1 year ago

Just applied to all relevant plotting functions and indeed it solves the issue!