noriakis / ggkegg

Analyzing and visualizing KEGG information using the grammar of graphics
https://noriakis.github.io/software/ggkegg
MIT License
201 stars 16 forks source link

Error: Image must have single frame to write a native raster #10

Closed yvazirabad closed 6 months ago

yvazirabad commented 7 months ago

Hello,

I am excited to use ggkegg. However, I cannot run the first example code block using pathway "ko01100". I get the error "Error: Image must have single frame to write a native raster." This error seems to come from the magick R package.

https://cpp.hotexamples.com/examples/magick/Blob/-/cpp-blob-class-examples.html#0x39145acda6fd2a210063e9946b2a82f0947bc65496a64405d5733254faf68110-168,,183,

Do you have any idea how this error happens?

Here is my sessionInfo() as well. attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] dplyr_1.1.4 ggfx_1.0.1 ggkegg_1.0.2 tidygraph_1.2.3 igraph_1.5.1 XML_3.99-0.15 ggraph_2.1.0
[8] ggplot2_3.4.4

loaded via a namespace (and not attached): [1] tidyselect_1.2.0 viridisLite_0.4.2 farver_2.1.1 blob_1.2.4
[5] filelock_1.0.2 viridis_0.6.4 Biostrings_2.68.1 bitops_1.0-7
[9] fastmap_1.1.1 RCurl_1.98-1.13 BiocFileCache_2.8.0 tweenr_2.0.2
[13] digest_0.6.33 lifecycle_1.0.4 Cairo_1.6-1 KEGGREST_1.40.0
[17] RSQLite_2.3.3 magrittr_2.0.3 compiler_4.3.1 rlang_1.1.2
[21] tools_4.3.1 utf8_1.2.4 data.table_1.14.8 labeling_0.4.3
[25] graphlayouts_1.0.0 bit_4.0.5 curl_5.1.0 withr_2.5.2
[29] purrr_1.0.2 BiocGenerics_0.48.1 grid_4.3.1 polyclip_1.10-6
[33] stats4_4.3.1 fansi_1.0.5 colorspace_2.1-0 scales_1.2.1
[37] MASS_7.3-60 cli_3.6.1 crayon_1.5.2 ragg_1.2.5
[41] generics_0.1.3 rstudioapi_0.15.0 httr_1.4.7 rjson_0.2.21
[45] DBI_1.1.3 cachem_1.0.8 ggforce_0.4.1 stringr_1.5.0
[49] zlibbioc_1.48.0 AnnotationDbi_1.62.2 XVector_0.40.0 vctrs_0.6.4
[53] shadowtext_0.1.2 IRanges_2.36.0 GetoptLong_1.0.5 patchwork_1.1.3
[57] S4Vectors_0.40.1 bit64_4.0.5 ggrepel_0.9.4 systemfonts_1.0.5
[61] magick_2.7.5 tidyr_1.3.0 glue_1.6.2 stringi_1.8.1
[65] gtable_0.3.4 GenomeInfoDb_1.36.1 munsell_0.5.0 tibble_3.2.1
[69] pillar_1.9.0 GenomeInfoDbData_1.2.11 R6_2.5.1 dbplyr_2.3.3
[73] textshaping_0.3.6 Biobase_2.62.0 png_0.1-8 memoise_2.0.1
[77] Rcpp_1.0.11 gridExtra_2.3 org.Hs.eg.db_3.17.0 pkgconfig_2.0.3
[81] GlobalOptions_0.1.2

Respectfully, Ibrahim Vazirabad

noriakis commented 7 months ago

Dear @yvazirabad,

Thank you very much for using the package, and reporting the issue. As you stated, the error seems to come from magick package. ggkegg uses the magick internally only in the overlay_raw_map() and the first example in the README.md does not use the function. So it might be related to the ggfx::with_outer_glow function. Could you try the following code without with_outer_glow to see if the error remains?

pathway("ko01100") |>
    process_line() |>
    highlight_module(module("M00021")) |>
    highlight_module(module("M00338")) |>
    ggraph(x=x, y=y) +
        geom_node_point(size=1, aes(color=I(fgcolor),
            filter=fgcolor!="none" & type!="line")) +
        geom_edge_link0(width=0.1, aes(color=I(fgcolor),
            filter=type=="line"& fgcolor!="none")) +
        geom_edge_link0(width=2,
            aes(color=I(fgcolor),
                filter=(M00021 | M00338))) +
        geom_node_point(size=2,
            aes(color=I(fgcolor),
                filter=(M00021 | M00338))) +
        geom_node_text(size=2,
            aes(x=x, y=y,
                label=graphics_name,
                filter=name=="path:ko00270"),
            repel=TRUE, family="sans", bg.colour="white") +
        theme_void()

Sincerely, Noriaki Sato

yvazirabad commented 7 months ago

Hello Noriaki,

It seems that you are correct. Removing the with_outer_glow function allowed the code fragment to run with no error. I was able to generate the same plot. I can now continue with using ggkegg (thank you), but it remains to be seen why this function is causing problems.

-Ibrahim

noriakis commented 7 months ago

Thank you for the update. Yes, I would like to look into the issue to see if we can find a solution. Would you share the OS and the R version you are using, please?

yvazirabad commented 7 months ago

Hello,

The R version is 4.3.1, I was running it through RStudio Server.

R version 4.3.1 (2023-06-16) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

noriakis commented 7 months ago

Thank you for sharing the information. I will look into the issue.

noriakis commented 7 months ago

Hi @yvazirabad, currently I cannot reproduce the error in almost the same environment. Could you please share the ImageMagick version in case it relates?

magick identify -version
yvazirabad commented 6 months ago

Hello, I ended up using my personal computer's R version and not the server version. The error is gone. Thank you.