peakHeatmap returns ` Error: external pointer is not valid` in Rmarkdown
h4rvey-g opened this issue · 1 comments
h4rvey-g commented
The following code works fine in R but returns error in Rmarkdown code chunk.
for (i in seq(1, length(gr_list), by = 4)) {
peakHeatmap(gr_list[i:(i + 3)], color = rainbow(n = 4), TxDb = txdb, upstream = 3000, downstream = 3000) +
facet_grid(chr ~ .id)
}
Quitting from lines 54-58 (05_annotation.Rmd)
Error: external pointer is not valid
In addition: There were 50 or more warnings (use warnings() to see the first 50)
r$> traceback()
42: stop(structure(list(message = "external pointer is not valid",
call = NULL, cppstack = NULL), class = c("Rcpp::exception",
"C++Error", "error", "condition")))
41: result_create(conn@ptr, statement)
40: initialize(value, ...)
39: initialize(value, ...)
38: new("SQLiteResult", sql = statement, ptr = result_create(conn@ptr,
statement), conn = conn, bigint = conn@bigint)
37: .local(conn, statement, ...)
36: dbSendQuery(conn, statement, ...)
35: dbSendQuery(conn, statement, ...)
34: .local(conn, statement, ...)
33: dbGetQuery(conn, paste("SELECT", select.cols, "FROM", name),
row.names = row.names)
32: dbGetQuery(conn, paste("SELECT", select.cols, "FROM", name),
row.names = row.names)
31: .local(conn, name, ...)
30: dbReadTable(dbconn(x), "metadata")
29: dbReadTable(dbconn(x), "metadata")
28: .local(x, ...)
27: metadata(TxDb)
26: metadata(TxDb)
25: unlist(metadata(TxDb))
24: .ChIPseekerEnv(TxDb)
23: getBioRegion(TxDb = TxDb, upstream = upstream, downstream = downstream,
by = "gene", type = "start_site")
22: peakHeatmap(gr_list[i:(i + 3)], color = rainbow(n = 4), TxDb = txdb,
upstream = 3000, downstream = 3000)
21: eval(expr, envir, enclos)
20: eval(expr, envir, enclos)
19: eval_with_user_handlers(expr, envir, enclos, user_handlers)
18: withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers))
17: withCallingHandlers(withVisible(eval_with_user_handlers(expr,
envir, enclos, user_handlers)), warning = wHandler, error = eHandler,
message = mHandler)
16: handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr,
envir, enclos, user_handlers)), warning = wHandler, error = eHandler,
message = mHandler))
15: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr,
envir, enclos, user_handlers)), warning = wHandler, error = eHandler,
message = mHandler)))
14: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos,
debug = debug, last = i == length(out), use_try = stop_on_error !=
2L, keep_warning = keep_warning, keep_message = keep_message,
output_handler = output_handler, include_timing = include_timing)
13: evaluate::evaluate(...)
12: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning),
keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else {
if (options$error && options$include)
0L
else 2L
}, output_handler = knit_handlers(options$render, options))
11: in_dir(input_dir(), expr)
10: in_input_dir(evaluate(code, envir = env, new_device = FALSE,
keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message),
stop_on_error = if (is.numeric(options$error)) options$error else {
if (options$error && options$include)
0L
else 2L
}, output_handler = knit_handlers(options$render, options)))
9: eng_r(options)
8: block_exec(params)
7: call_block(x)
6: process_group.block(group)
5: process_group(group)
4: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),
error = function(e) {
setwd(wd)
cat(res, sep = "\n", file = output %n% "")
message("Quitting from lines ", paste(current_lines(i),
collapse = "-"), " (", knit_concord$get("infile"),
") ")
})
3: process_file(text, output)
2: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
1: rmarkdown::render("05_annotation.Rmd")
r$> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)
Matrix products: default
BLAS/LAPACK: /xxx/.conda/envs/r/lib/libopenblasp-r0.3.21.so
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:
other attached packages:
[1] doParallel_1.0.17 iterators_1.0.14 foreach_1.5.2
[4] TxDb.Mmusculus.UCSC.mm39.refGene_3.12.0 GenomicFeatures_1.50.2 AnnotationDbi_1.60.0
[7] Biobase_2.58.0 optparse_1.7.3 rtracklayer_1.58.0
[10] GenomicRanges_1.50.0 GenomeInfoDb_1.34.1 IRanges_2.32.0
[13] S4Vectors_0.36.0 BiocGenerics_0.44.0 ChIPseeker_1.34.0
[16] forcats_0.5.2 stringr_1.4.1 dplyr_1.0.10
[19] purrr_0.3.5 readr_2.1.3 tidyr_1.2.1
[22] tibble_3.1.8 ggplot2_3.4.0 tidyverse_1.3.2
loaded via a namespace (and not attached):
[1] shadowtext_0.1.2 readxl_1.4.1 backports_1.4.1
[4] fastmatch_1.1-3 BiocFileCache_2.6.0 plyr_1.8.7
[7] igraph_1.3.5 lazyeval_0.2.2 splines_4.2.2
[10] BiocParallel_1.32.0 digest_0.6.30 yulab.utils_0.0.5
[13] htmltools_0.5.3 GOSemSim_2.24.0 viridis_0.6.2
[16] GO.db_3.16.0 fansi_1.0.3 magrittr_2.0.3
[19] memoise_2.0.1 googlesheets4_1.0.1 tzdb_0.3.0
[22] Biostrings_2.66.0 graphlayouts_0.8.3 modelr_0.1.9
[25] matrixStats_0.62.0 enrichplot_1.18.0 prettyunits_1.1.1
[28] colorspace_2.0-3 blob_1.2.3 rvest_1.0.3
[31] rappdirs_0.3.3 ggrepel_0.9.2 haven_2.5.1
[34] xfun_0.34 crayon_1.5.2 RCurl_1.98-1.9
[37] jsonlite_1.8.3 scatterpie_0.1.8 TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
[40] ape_5.6-2 glue_1.6.2 polyclip_1.10-4
[43] gtable_0.3.1 gargle_1.2.1 zlibbioc_1.44.0
[46] XVector_0.38.0 DelayedArray_0.24.0 scales_1.2.1
[49] DOSE_3.24.0 DBI_1.1.3 Rcpp_1.0.9
[52] plotrix_3.8-2 viridisLite_0.4.1 progress_1.2.2
[55] tidytree_0.4.1 gridGraphics_0.5-1 bit_4.0.4
[58] getopt_1.20.3 httr_1.4.4 fgsea_1.24.0
[61] gplots_3.1.3 RColorBrewer_1.1-3 ellipsis_0.3.2
[64] pkgconfig_2.0.3 XML_3.99-0.12 farver_2.1.1
[67] sass_0.4.2 dbplyr_2.2.1 utf8_1.2.2
[70] labeling_0.4.2 ggplotify_0.1.0 tidyselect_1.2.0
[73] rlang_1.0.6 reshape2_1.4.4 munsell_0.5.0
[76] cellranger_1.1.0 tools_4.2.2 cachem_1.0.6
[79] cli_3.4.1 generics_0.1.3 RSQLite_2.2.18
[82] broom_1.0.1 evaluate_0.18 fastmap_1.1.0
[85] yaml_2.3.6 ggtree_3.6.0 knitr_1.40
[88] bit64_4.0.5 fs_1.5.2 tidygraph_1.2.2
[91] caTools_1.18.2 KEGGREST_1.38.0 ggraph_2.1.0
[94] nlme_3.1-160 aplot_0.1.8 xml2_1.3.3
[97] biomaRt_2.54.0 compiler_4.2.2 filelock_1.0.2
[100] curl_4.3.3 png_0.1-7 treeio_1.22.0
[103] reprex_2.0.2 tweenr_2.0.2 bslib_0.4.1
[106] stringi_1.7.8 highr_0.9 lattice_0.20-45
[109] Matrix_1.5-1 vctrs_0.5.0 pillar_1.8.1
[112] lifecycle_1.0.3 jquerylib_0.1.4 data.table_1.14.4
[115] cowplot_1.1.1 bitops_1.0-7 patchwork_1.1.2
[118] qvalue_2.30.0 R6_2.5.1 BiocIO_1.8.0
[121] KernSmooth_2.23-20 gridExtra_2.3 codetools_0.2-18
[124] gtools_3.9.3 boot_1.3-28 MASS_7.3-58.1
[127] assertthat_0.2.1 SummarizedExperiment_1.28.0 rjson_0.2.21
[130] withr_2.5.0 GenomicAlignments_1.34.0 Rsamtools_2.14.0
[133] GenomeInfoDbData_1.2.9 hms_1.1.2 ggfun_0.0.8
[136] grid_4.2.2 HDO.db_0.99.1 rmarkdown_2.18
[139] MatrixGenerics_1.10.0 googledrive_2.0.0 ggforce_0.4.1
[142] lubridate_1.8.0 restfulr_0.0.15
h4rvey-g commented
Solved. The txdb
object should be explicitly exported into foreach
, using the argument .export=txdb
. Or export the whole global environment with .export = ls(globalenv())
.