noriakis / ggkegg

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

"Error in `vec_slice()` " bug report in example data' #16

Closed zqr2008 closed 1 month ago

zqr2008 commented 8 months ago

Hi, thanks for developing the package. It is of great help to me. However, I run into the bug.

The code report error after I run the example data:

`rm(list = ls()) library(ggkegg) library(ggfx) library(igraph) library(tidygraph) library(dplyr)

g <- pathway("hsa04110") pseudo_lfc <- sample(seq(0,3,0.1), length(V(g)), replace=TRUE) names(pseudo_lfc) <- V(g)$name

ggkegg("hsa04110", convert_org = c("pathway","hsa","ko"), numeric_attribute = pseudo_lfc)+ geom_edge_parallel2( aes(color=subtype_name), arrow = arrow(length = unit(1, 'mm')), start_cap = square(1, 'cm'), end_cap = square(1.5, 'cm')) + geom_node_rect(aes(filter=.data$type == "group"), fill="transparent", color="red") + geom_node_rect(aes(fill=numeric_attribute, filter=.data$type == "gene")) + geom_node_text(aes(label=converted_name, filter=.data$type == "gene"), size=2.5, color="black") + with_outer_glow( geom_node_text(aes(label=converted_name, filter=converted_name=="PCNA"), size=2.5, color="red"), colour="white", expand=4 ) + scale_edge_color_manual(values=viridis::plasma(11)) + scale_fill_viridis(name="LFC") + theme_void()`

The reported error information:

Error in vec_slice(): ! Can't subset elements past the end. ℹ Location 2 doesn't exist. ℹ There is only 1 element. Run rlang::last_trace() to see where the error occurred.

Backtrace information: Backtrace: ▆

  1. ├─ggkegg::ggkegg(...)
  2. │ ├─base::unlist(...)
  3. │ └─base::lapply(...)
  4. │ └─ggkegg (local) FUN(X[[i]], ...)
  5. │ └─ggkegg:::obtain_map_and_cache(co, pid)
  6. │ └─BiocFileCache::BiocFileCache()
  7. │ └─BiocFileCache:::.sql_create_db(bfc)
  8. │ └─BiocFileCache:::.sql_validate_version(bfc)
  9. │ └─BiocFileCache:::.sql_schema_version(bfc)
    1. │ ├─base::tryCatch(...)
    2. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
    3. │ ├─tbl(src, "metadata") %>% collect(n = Inf)
    4. │ ├─dplyr::tbl(src, "metadata")
    5. │ └─dbplyr:::tbl.src_dbi(src, "metadata")
    6. │ └─dbplyr::tbl_sql(c(subclass, "dbi"), src = src, from = from, ...)
    7. │ ├─vars %||% dbplyr_query_fields(src$con, from)
    8. │ └─dbplyr:::dbplyr_query_fields(src$con, from)
    9. │ └─dbplyr:::dbplyr_fallback(con, "db_query_fields", ...)
    10. │ ├─rlang::eval_bare(expr((!!fun)(con, ...)))
    11. │ └─dbplyr:::db_query_fields.DBIConnection(con, ...)
    12. │ ├─dbplyr::sql_query_fields(con, sql, ...)
    13. │ └─dbplyr:::sql_query_fields.DBIConnection(con, sql, ...)
    14. │ └─dbplyr:::dbplyr_query_select(...)
    15. │ └─dbplyr:::dbplyr_fallback(con, "sql_select", ...)
    16. │ ├─rlang::eval_bare(expr((!!fun)(con, ...)))
    17. │ └─dbplyr:::sql_select.DBIConnection(con, ...)
    18. │ ├─dbplyr::sql_query_select(...)
    19. │ └─dbplyr:::sql_query_select.DBIConnection(...)
    20. │ └─dbplyr:::sql_select_clauses(...)
    21. │ └─dbplyr:::sql_format_clauses(out, lvl, con)
    22. │ └─purrr::map(clauses, sql_format_clause, lvl = lvl, con = con)
    23. │ └─dbplyr (local) .f(.x[[i]], ...)
    24. │ ├─dbplyr::escape(x$parts, collapse = paste0(x$sep, " "), con = con)
    25. │ └─dbplyr:::escape.dbplyr_table_ident(...)
    26. │ └─purrr::map_chr(x, ~table_ident_name(.x) %||% "")
    27. │ ├─.x[[i]]
    28. │ └─vctrs:::[[.vctrs_rcrd(.x, i)
    29. │ └─vctrs::vec_slice(vec_data(x), i)
    30. └─dplyr::collect(., n = Inf)

The sessinoInfo in my rstudio: R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=Chinese (Simplified)_China.utf8 [2] LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8 [4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.utf8

time zone: Asia/Shanghai tzcode source: internal

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.6 tidygraph_1.3.0 [5] igraph_1.6.0 XML_3.99-0.16 ggraph_2.1.0 ggplot2_3.4.4

loaded via a namespace (and not attached): [1] tidyselect_1.2.0 viridisLite_0.4.2
[3] farver_2.1.1 blob_1.2.4
[5] filelock_1.0.2 viridis_0.6.4
[7] Biostrings_2.70.1 bitops_1.0-7
[9] fastmap_1.1.1 RCurl_1.98-1.13
[11] BiocFileCache_2.10.1 tweenr_2.0.2
[13] digest_0.6.33 lifecycle_1.0.4
[15] Cairo_1.6-2 KEGGREST_1.42.0
[17] RSQLite_2.3.4 magrittr_2.0.3
[19] compiler_4.3.2 rlang_1.1.2
[21] tools_4.3.2 utf8_1.2.2
[23] data.table_1.14.10 labeling_0.4.3
[25] graphlayouts_1.0.2 bit_4.0.5
[27] curl_5.2.0 withr_2.5.2
[29] purrr_0.3.5 BiocGenerics_0.48.1
[31] grid_4.3.2 polyclip_1.10-6
[33] stats4_4.3.2 fansi_1.0.3
[35] colorspace_2.0-3 scales_1.3.0
[37] MASS_7.3-60 cli_3.6.2
[39] crayon_1.5.2 ragg_1.2.7
[41] generics_0.1.3 rstudioapi_0.15.0
[43] httr_1.4.7 rjson_0.2.21
[45] DBI_1.2.0 cachem_1.0.8
[47] ggforce_0.4.1 stringr_1.5.1
[49] zlibbioc_1.48.0 AnnotationDbi_1.64.1
[51] XVector_0.42.0 vctrs_0.6.5
[53] shadowtext_0.1.2 IRanges_2.32.0
[55] GetoptLong_1.0.5 patchwork_1.1.3
[57] S4Vectors_0.36.1 bit64_4.0.5
[59] ggrepel_0.9.2 systemfonts_1.0.5
[61] magick_2.8.2 tidyr_1.2.1
[63] glue_1.6.2 stringi_1.7.8
[65] gtable_0.3.4 GenomeInfoDb_1.38.5
[67] munsell_0.5.0 tibble_3.2.1
[69] pillar_1.9.0 GenomeInfoDbData_1.2.11 [71] R6_2.5.1 dbplyr_2.4.0
[73] textshaping_0.3.7 Biobase_2.62.0
[75] png_0.1-8 memoise_2.0.1
[77] Rcpp_1.0.9 gridExtra_2.3
[79] org.Hs.eg.db_3.18.0 pkgconfig_2.0.3
[81] GlobalOptions_0.1.2

noriakis commented 8 months ago

Thank you for reporting the issue. I apologize for the delayed response.

Currently, I cannot reproduce the error and it seems that it is coming from BiocFileCache.

Could you clear the cache and try again?

On Mon, Jan 8, 2024 at 6:43 PM zqr2008 @.***> wrote:

Hi, thanks for developing the package. It is of great help to me. However, I run into the bug.

The code report error after I run the example data:

`rm(list = ls()) library(ggkegg) library(ggfx) library(igraph) library(tidygraph) library(dplyr)

g <- pathway("hsa04110") pseudo_lfc <- sample(seq(0,3,0.1), length(V(g)), replace=TRUE) names(pseudo_lfc) <- V(g)$name

ggkegg("hsa04110", convert_org = c("pathway","hsa","ko"), numeric_attribute = pseudo_lfc)+ geom_edge_parallel2( aes(color=subtype_name), arrow = arrow(length = unit(1, 'mm')), start_cap = square(1, 'cm'), end_cap = square(1.5, 'cm')) + geom_node_rect(aes(filter=.data$type == "group"), fill="transparent", color="red") + geom_node_rect(aes(fill=numeric_attribute, filter=.data$type == "gene")) + geom_node_text(aes(label=converted_name, filter=.data$type == "gene"), size=2.5, color="black") + with_outer_glow( geom_node_text(aes(label=converted_name, filter=converted_name=="PCNA"), size=2.5, color="red"), colour="white", expand=4 ) + scale_edge_color_manual(values=viridis::plasma(11)) + scale_fill_viridis(name="LFC") + theme_void()`

The reported error information:

Error in vec_slice(): ! Can't subset elements past the end. ℹ Location 2 doesn't exist. ℹ There is only 1 element. Run rlang::last_trace() to see where the error occurred.

Backtrace information: Backtrace: ▆

  1. ├─ggkegg::ggkegg(...)
  2. │ ├─base::unlist(...)
  3. │ └─base::lapply(...)
  4. │ └─ggkegg (local) FUN(X[[i]], ...)
  5. │ └─ggkegg:::obtain_map_and_cache(co, pid)
  6. │ └─BiocFileCache::BiocFileCache()
  7. │ └─BiocFileCache:::.sql_create_db(bfc)
  8. │ └─BiocFileCache:::.sql_validate_version(bfc)
  9. │ └─BiocFileCache:::.sql_schema_version(bfc)
  10. │ ├─base::tryCatch(...)
  11. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
  12. │ ├─tbl(src, "metadata") %>% collect(n = Inf)
  13. │ ├─dplyr::tbl(src, "metadata")
  14. │ └─dbplyr:::tbl.src_dbi(src, "metadata")
  15. │ └─dbplyr::tbl_sql(c(subclass, "dbi"), src = src, from = from, ...)
  16. │ ├─vars %||% dbplyr_query_fields(src$con, from)
  17. │ └─dbplyr:::dbplyr_query_fields(src$con, from)
  18. │ └─dbplyr:::dbplyr_fallback(con, "db_query_fields", ...)
  19. │ ├─rlang::eval_bare(expr((!!fun)(con, ...)))
  20. │ └─dbplyr:::db_query_fields.DBIConnection(con, ...)
  21. │ ├─dbplyr::sql_query_fields(con, sql, ...)
  22. │ └─dbplyr:::sql_query_fields.DBIConnection(con, sql, ...)
  23. │ └─dbplyr:::dbplyr_query_select(...)
  24. │ └─dbplyr:::dbplyr_fallback(con, "sql_select", ...)
  25. │ ├─rlang::eval_bare(expr((!!fun)(con, ...)))
  26. │ └─dbplyr:::sql_select.DBIConnection(con, ...)
  27. │ ├─dbplyr::sql_query_select(...)
  28. │ └─dbplyr:::sql_query_select.DBIConnection(...)
  29. │ └─dbplyr:::sql_select_clauses(...)
  30. │ └─dbplyr:::sql_format_clauses(out, lvl, con)
  31. │ └─purrr::map(clauses, sql_format_clause, lvl = lvl, con = con)
  32. │ └─dbplyr (local) .f(.x[[i]], ...)
  33. │ ├─dbplyr::escape(x$parts, collapse = paste0(x$sep, " "), con = con)
  34. │ └─dbplyr:::escape.dbplyr_table_ident(...)
  35. │ └─purrr::map_chr(x, ~table_ident_name(.x) %||% "")
  36. │ ├─.x[[i]]
  37. │ └─vctrs:::[[.vctrs_rcrd(.x, i)
  38. │ └─vctrs::vec_slice(vec_data(x), i)
  39. └─dplyr::collect(., n = Inf)

The sessinoInfo in my rstudio: R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=Chinese (Simplified)_China.utf8 [2] LC_CTYPE=Chinese (Simplified)_China.utf8 [3] LC_MONETARY=Chinese (Simplified)_China.utf8 [4] LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.utf8

time zone: Asia/Shanghai tzcode source: internal

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.6 tidygraph_1.3.0 [5] igraph_1.6.0 XML_3.99-0.16 ggraph_2.1.0 ggplot2_3.4.4

loaded via a namespace (and not attached): [1] tidyselect_1.2.0 viridisLite_0.4.2 [3] farver_2.1.1 blob_1.2.4 [5] filelock_1.0.2 viridis_0.6.4 [7] Biostrings_2.70.1 bitops_1.0-7 [9] fastmap_1.1.1 RCurl_1.98-1.13 [11] BiocFileCache_2.10.1 tweenr_2.0.2 [13] digest_0.6.33 lifecycle_1.0.4 [15] Cairo_1.6-2 KEGGREST_1.42.0 [17] RSQLite_2.3.4 magrittr_2.0.3 [19] compiler_4.3.2 rlang_1.1.2 [21] tools_4.3.2 utf8_1.2.2 [23] data.table_1.14.10 labeling_0.4.3 [25] graphlayouts_1.0.2 bit_4.0.5 [27] curl_5.2.0 withr_2.5.2 [29] purrr_0.3.5 BiocGenerics_0.48.1 [31] grid_4.3.2 polyclip_1.10-6 [33] stats4_4.3.2 fansi_1.0.3 [35] colorspace_2.0-3 scales_1.3.0 [37] MASS_7.3-60 cli_3.6.2 [39] crayon_1.5.2 ragg_1.2.7 [41] generics_0.1.3 rstudioapi_0.15.0 [43] httr_1.4.7 rjson_0.2.21 [45] DBI_1.2.0 cachem_1.0.8 [47] ggforce_0.4.1 stringr_1.5.1 [49] zlibbioc_1.48.0 AnnotationDbi_1.64.1 [51] XVector_0.42.0 vctrs_0.6.5 [53] shadowtext_0.1.2 IRanges_2.32.0 [55] GetoptLong_1.0.5 patchwork_1.1.3 [57] S4Vectors_0.36.1 bit64_4.0.5 [59] ggrepel_0.9.2 systemfonts_1.0.5 [61] magick_2.8.2 tidyr_1.2.1 [63] glue_1.6.2 stringi_1.7.8 [65] gtable_0.3.4 GenomeInfoDb_1.38.5 [67] munsell_0.5.0 tibble_3.2.1 [69] pillar_1.9.0 GenomeInfoDbData_1.2.11 [71] R6_2.5.1 dbplyr_2.4.0 [73] textshaping_0.3.7 Biobase_2.62.0 [75] png_0.1-8 memoise_2.0.1 [77] Rcpp_1.0.9 gridExtra_2.3 [79] org.Hs.eg.db_3.18.0 pkgconfig_2.0.3 [81] GlobalOptions_0.1.2

— Reply to this email directly, view it on GitHub https://github.com/noriakis/ggkegg/issues/16, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHNHVP4VIOC2JRWYTGH63ILYNO5VRAVCNFSM6AAAAABBRFBJG6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3TAMBXGI3DINI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

noriakis commented 1 month ago

Closing, but feel free to reopen if the problem persists!