最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

r markdown - caught segfault (address 0x2b) error when knitting BPCells + Seurat object - Stack Overflow

programmeradmin0浏览0评论

I have an integrated Seurat object with approximately ~480k cells, integrated using the sketch-based method detailed here (leveraging the on-disk storage capabilities of BPCells). I keep getting this error only when I try to knit a file trying to process the Seurat object:

 *** caught segfault ***
address 0x2b, cause 'memory not mapped'

Traceback:
 1: iter_function(x@dir, x@buffer_size, x@dimnames[[1]], x@dimnames[[2]],     nrow(x))
 2: iterate_matrix(x@matrix)
 3: iterate_matrix(x@matrix)
 4: iterate_matrix(x@matrix)
 5: iterate_matrix(x@matrix)
 6: iter_function(iterate_matrix(x@matrix), row_names, col_names,     is.null(rownames(x)), is.null(colnames(x)))
 7: iterate_matrix(x@matrix)
 8: iterate_matrix(x@matrix)
 9: iterate_matrix(x@matrix)
10: iterate_matrix(x@matrix)
11: iterate_matrix_log1psimd_cpp(iterate_matrix(x@matrix))
12: iterate_matrix(x@matrix)
13: iterate_matrix(x@matrix)
14: iter_function(iterate_matrix(x@matrix), row_names, col_names,     is.null(rownames(x)), is.null(colnames(x)))
15: FUN(X[[i]], ...)
16: FUN(X[[i]], ...)
17: lapply(x@matrix_list, iterate_matrix)
18: iterate_matrix(x@matrix)
19: iterate_matrix(x@matrix)
20: iterate_matrix(x@matrix)
21: iterate_matrix(x@matrix)
22: iter_function(iterate_matrix(x@matrix), row_names, col_names,     is.null(rownames(x)), is.null(colnames(x)))
23: iterate_matrix(t(x))
24: iterate_matrix(t(x))
25: iterate_matrix(mat)
26: iterate_matrix(mat)
27: write_matrix_memory(convert_matrix_type(from, "double"), compress = FALSE)
28: asMethod(object)
29: as(from, "dgCMatrix")
30: as.matrix(as(from, "dgCMatrix"))
31: asMethod(object)
32: as(t(x = LayerData(object = object, layer = lyr, cells = lcells,     features = lvars)[lvars, lcells, drop = FALSE]), "matrix")
33: FetchData.Assay5(object = object[[DefaultAssay(object = object)]],     vars = default.vars, cells = cells, layer = layer, ...)
34: FetchData(object = object[[DefaultAssay(object = object)]], vars = default.vars,     cells = cells, layer = layer, ...)
35: FetchData.Seurat(object = object, vars = c(dims, "ident", features),     cells = cells, slot = slot)
36: FetchData(object = object, vars = c(dims, "ident", features),     cells = cells, slot = slot)
37: FeaturePlot(adata_sub, features = c(canon_genes, "HBB", "PPBP",     "CD34"), reduction = "full.noLonza_UMAP", raster = TRUE)
38: eval(expr, envir)
39: eval(expr, envir)
40: withVisible(eval(expr, envir))
41: withCallingHandlers(code, message = function (cnd) {    watcher$capture_plot_and_output()    if (on_message$capture) {        watcher$push(cnd)    }    if (on_message$silence) {        invokeRestart("muffleMessage")    }}, warning = function (cnd) {    if (getOption("warn") >= 2 || getOption("warn") < 0) {        return()    }    watcher$capture_plot_and_output()    if (on_warning$capture) {        cnd <- sanitize_call(cnd)        watcher$push(cnd)    }    if (on_warning$silence) {        invokeRestart("muffleWarning")    }}, error = function (cnd) {    watcher$capture_plot_and_output()    cnd <- sanitize_call(cnd)    watcher$push(cnd)    switch(on_error, continue = invokeRestart("eval_continue"),         stop = invokeRestart("eval_stop"), error = invokeRestart("eval_error",             cnd))})
42: eval(call)
43: eval(call)
44: with_handlers({    for (expr in tle$exprs) {        ev <- withVisible(eval(expr, envir))        watcher$capture_plot_and_output()        watcher$print_value(ev$value, ev$visible, envir)    }    TRUE}, handlers)
45: doWithOneRestart(return(expr), restart)
46: withOneRestart(expr, restarts[[1L]])
47: withRestartList(expr, restarts[-nr])
48: doWithOneRestart(return(expr), restart)
49: withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
50: withRestartList(expr, restarts[-nr])
51: doWithOneRestart(return(expr), restart)
52: withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
53: withRestartList(expr, restarts)
54: withRestarts(with_handlers({    for (expr in tle$exprs) {        ev <- withVisible(eval(expr, envir))        watcher$capture_plot_and_output()        watcher$print_value(ev$value, ev$visible, envir)    }    TRUE}, handlers), eval_continue = function() TRUE, eval_stop = function() FALSE,     eval_error = function(cnd) {        signalCondition(cnd)        stop(cnd)    })
55: evaluate::evaluate(...)
56: evaluate(code, envir = env, new_device = FALSE, keep_warning = if (is.numeric(options$warning)) TRUE else options$warning,     keep_message = if (is.numeric(options$message)) TRUE else 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))
57: in_dir(input_dir(), expr)
58: in_input_dir(evaluate(code, envir = env, new_device = FALSE,     keep_warning = if (is.numeric(options$warning)) TRUE else options$warning,     keep_message = if (is.numeric(options$message)) TRUE else 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)))
59: eng_r(options)
60: block_exec(params)
61: call_block(x)
62: process_group(group)
63: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),     error = function(e) if (xfun::pkg_available("rlang", "1.0.0")) rlang::entrace(e))
64: xfun:::handle_error(withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),     error = function(e) if (xfun::pkg_available("rlang", "1.0.0")) rlang::entrace(e)),     function(loc) {        setwd(wd)        write_utf8(res, output %n% stdout())        paste0("\nQuitting from lines ", loc)    }, if (labels[i] != "") sprintf(" [%s]", labels[i]), get_loc)
65: process_file(text, output)
66: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
67: rmarkdown::render(f, output_format = output_format, output_options = output_options,     knit_root_dir = NULL, envir = envir, quiet = quiet, encoding = encoding)
68: withCallingHandlers(expr, message = function(c) if (inherits(c,     classes)) tryInvokeRestart("muffleMessage"))
69: suppressMessages(output_file <- rmarkdown::render(f, output_format = output_format,     output_options = output_options, knit_root_dir = NULL, envir = envir,     quiet = quiet, encoding = encoding))
70: generator$render(input_file = input_file, output_format = output_format,     envir = envir, quiet = quiet)
71: rmarkdown::render_site("/mnt/beegfs/hge/projects/indo_sc/scratch/analysis/expression/Indo_sc_expression/analysis/02_manual_annotation.Rmd",     encoding = "UTF-8")
An irrecoverable exception occurred. R is aborting now ...

This happens to multiple Seurat functions (FeaturePlot, NormalizeData, basically anything that tries to process the object) but the error only happens during knitting. A brief example of when the error pops up:

# Load packages
library(pacman)
p_load(workflowr, Seurat, ggplot2, ggsignif, reshape2, speckle, gtsummary,
       RColorBrewer, dplyr, stats, Palo, patchwork, PNWColors, pals, dplyr, tidyverse,
       DESeq2, dittoSeq, edgeR, ggpubr, biomaRt, BPCells, ggpmisc, clusterProfiler,
       enrichplot, .Hs.eg.db, variancePartition, presto, janitor, rstatix)

# Set paths
## Main paths
outdir <- "./analysis/expression/merged/keepUpstream/"
dir.create(paste0(outdir, "annotation/"), showWarnings = FALSE)

figures_path <- paste0(outdir, "annotation/figures/")
dir.create(paste0(outdir, "annotation/figures/"), showWarnings = FALSE)

# From last step
## Clean data (FOR FURTHER ANALYSIS)
adata_sub <- readRDS(paste0(outdir, "Main_subset_Seurat.RDS"))

## have also tried joining the layers, still failed
### adata_sub[["RNA"]] <- JoinLayers(adata_sub[["RNA"]])

# Get list of canonical marker genes ####
canon_list <- list()
canon_list[["CD4+ T"]] <- c("CD3D", "CD3E", "CD8A")
canon_list[["CD8+ T"]] <- c("CD3D", "CD3E", "CD4")

                       
canon_genes <- unlist(canon_list)[!duplicated(unlist(canon_list))]

# Plot feature plots of marker genes ####
All_feature <- FeaturePlot(adata_sub, features = c(canon_genes, "HBB", "PPBP", "CD34"), reduction = "full.noLonza_UMAP", raster = TRUE)

Again, everything works outside of knitting.

I'm running Rstudio server and have tried different resources settings (80-120GB RAM, 8-10 cores) and R versions (4.3.0 and 4.4.0) to no avail. Have put cache in my chunk per this page, no change. Tried reinstalling packages such as this example, and even tried reinstalling all the packages from scratch, still does not work.

Is there an obvious memory allocation setting that I need to adjust for knitting? Thank you

发布评论

评论列表(0)

  1. 暂无评论