seurat icon indicating copy to clipboard operation
seurat copied to clipboard

*** caught segfault *** address (nil), cause 'memory not mapped': ATACseq integration vignette [cca reduction]

Open elhaam opened this issue 2 years ago • 5 comments

Hi there, thanks for the helpful package! I am using RNAseq and ATACseq integration vignette on SNARE-seq Human data for 1047 cells. I generated the fragments file for this data using sinto package. I am facing the same problems as 3274 and 2386, as follows:

transfer.anchors <- FindTransferAnchors(reference = rna, query = atac, features = VariableFeatures(object = rna), reference.assay = "RNA", query.assay = "ACTIVITY", reduction = "cca")

Running CCA *** caught segfault *** address (nil), cause 'memory not mapped'

Traceback: 1: Standardize(mat = object1, display_progress = FALSE) 2: RunCCA.default(object1 = data1, object2 = data2, standardize = TRUE, num.cc = num.cc, verbose = verbose, ) 3: RunCCA(object1 = data1, object2 = data2, standardize = TRUE, num.cc = num.cc, verbose = verbose, ) 4: RunCCA.Seurat(object1 = reference, object2 = query, features = features, num.cc = max(dims), renormalize = FALSE, rescale = FALSE, verbose = verbose) 5: RunCCA(object1 = reference, object2 = query, features = features, num.cc = max(dims), renormalize = FALSE, rescale = FALSE, verbose = verbose) 6: FindTransferAnchors(reference = pbmc_rna, query = pbmc_atac, features = VariableFeatures(object = pbmc_rna), reference.assay = "RNA", query.assay = "ACTIVITY", reduction = "cca")

Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace

My session info on the server:

R version 4.1.3 (2022-03-10) Platform: x86_64-conda-linux-gnu (64-bit) Running under: Ubuntu 18.04.6 LTS

Matrix products: default BLAS/LAPACK: /home/ejafari/.conda/envs/seurat/lib/libopenblasp-r0.3.20.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] 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 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats4 stats graphics grDevices utils datasets methods [8] base

other attached packages: [1] EnsDb.Hsapiens.v86_2.99.0 ensembldb_2.18.4 [3] AnnotationFilter_1.18.0 GenomicFeatures_1.46.5 [5] AnnotationDbi_1.56.2 Biobase_2.54.0 [7] GenomicRanges_1.46.1 GenomeInfoDb_1.30.1 [9] IRanges_2.28.0 S4Vectors_0.32.4 [11] BiocGenerics_0.40.0 Signac_1.6.0 [13] patchwork_1.1.1 sp_1.4-7 [15] SeuratObject_4.1.0 Seurat_4.1.1 [17] dplyr_1.0.9

loaded via a namespace (and not attached): [1] fastmatch_1.1-3 BiocFileCache_2.2.1 [3] plyr_1.8.7 igraph_1.3.1 [5] lazyeval_0.2.2 splines_4.1.3 [7] BiocParallel_1.28.3 listenv_0.8.0 [9] scattermore_0.8 SnowballC_0.7.0 [11] ggplot2_3.3.6 digest_0.6.29 [13] htmltools_0.5.2 fansi_1.0.3 [15] memoise_2.0.1 magrittr_2.0.3 [17] tensor_1.5 cluster_2.1.3 [19] ROCR_1.0-11 globals_0.15.0 [21] Biostrings_2.62.0 matrixStats_0.62.0 [23] docopt_0.7.1 spatstat.sparse_2.1-1 [25] prettyunits_1.1.1 colorspace_2.0-3 [27] rappdirs_0.3.3 blob_1.2.3 [29] ggrepel_0.9.1 sparsesvd_0.2 [31] crayon_1.5.1 RCurl_1.98-1.6 [33] jsonlite_1.8.0 progressr_0.10.0 [35] spatstat.data_2.2-0 survival_3.3-1 [37] zoo_1.8-10 glue_1.6.2 [39] polyclip_1.10-0 gtable_0.3.0 [41] zlibbioc_1.40.0 XVector_0.34.0 [43] leiden_0.4.2 DelayedArray_0.20.0 [45] future.apply_1.9.0 abind_1.4-5 [47] scales_1.2.0 DBI_1.1.2 [49] spatstat.random_2.2-0 miniUI_0.1.1.1 [51] Rcpp_1.0.8.3 progress_1.2.2 [53] viridisLite_0.4.0 xtable_1.8-4 [55] reticulate_1.25 spatstat.core_2.4-4 [57] bit_4.0.4 htmlwidgets_1.5.4 [59] httr_1.4.3 RColorBrewer_1.1-3 [61] ellipsis_0.3.2 ica_1.0-2 [63] XML_3.99-0.9 pkgconfig_2.0.3 [65] farver_2.1.0 dbplyr_2.1.1 [67] ggseqlogo_0.1 uwot_0.1.11 [69] deldir_1.0-6 utf8_1.2.2 [71] tidyselect_1.1.2 rlang_1.0.2 [73] reshape2_1.4.4 later_1.3.0 [75] cachem_1.0.6 munsell_0.5.0 [77] tools_4.1.3 cli_3.3.0 [79] generics_0.1.2 RSQLite_2.2.14 [81] ggridges_0.5.3 stringr_1.4.0 [83] fastmap_1.1.0 yaml_2.3.5 [85] goftest_1.2-3 bit64_4.0.5 [87] fitdistrplus_1.1-8 purrr_0.3.4 [89] RANN_2.6.1 KEGGREST_1.34.0 [91] pbapply_1.5-0 future_1.25.0 [93] nlme_3.1-157 mime_0.12 [95] slam_0.1-50 RcppRoll_0.3.0 [97] xml2_1.3.3 biomaRt_2.50.3 [99] compiler_4.1.3 filelock_1.0.2 [101] curl_4.3.2 plotly_4.10.0 [103] png_0.1-7 spatstat.utils_2.3-1 [105] tibble_3.1.7 tweenr_1.0.2 [107] stringi_1.7.6 rgeos_0.5-9 [109] lattice_0.20-45 ProtGenerics_1.26.0 [111] Matrix_1.4-1 vctrs_0.4.1 [113] pillar_1.7.0 lifecycle_1.0.1 [115] spatstat.geom_2.4-0 lmtest_0.9-40 [117] RcppAnnoy_0.0.19 data.table_1.14.2 [119] cowplot_1.1.1 bitops_1.0-7 [121] irlba_2.3.5 rtracklayer_1.54.0 [123] httpuv_1.6.5 BiocIO_1.4.0 [125] R6_2.5.1 promises_1.2.0.1 [127] KernSmooth_2.23-20 gridExtra_2.3 [129] lsa_0.73.3 parallelly_1.31.1 [131] codetools_0.2-18 MASS_7.3-57 [133] assertthat_0.2.1 SummarizedExperiment_1.24.0 [135] rjson_0.2.21 GenomicAlignments_1.30.0 [137] qlcMatrix_0.9.7 sctransform_0.3.3 [139] Rsamtools_2.10.0 GenomeInfoDbData_1.2.7 [141] hms_1.1.1 mgcv_1.8-40 [143] parallel_4.1.3 grid_4.1.3 [145] rpart_4.1.16 tidyr_1.2.0 [147] MatrixGenerics_1.6.0 Rtsne_0.16 [149] ggforce_0.3.3 shiny_1.7.1 [151] restfulr_0.0.13

My Linux system has 48 CPU cores (96 virtual processors with hyperthreading) and 1.5TB of RAM. I also tried it on my personal MacBook in Rstudio but this line of code with "cca" reduction makes Rstudio crash with a fatal error.

p.n: I tried the solutions discussed in this link but didn't help. I also tried setting the default assay for the scATAC-seq data to "RNA" as mentioned in this answer and [this one] (https://github.com/satijalab/seurat/issues/3364), but the error is not fixed.

length(intersect(rownames(rna[["RNA"]]), rownames(atac[["ACTIVITY"]]))) 1657

length(VariableFeatures(rna)) [1] 2000

Could you please help me with this? Thank you very much!

elhaam avatar Jun 01 '22 01:06 elhaam

Just a quick update to add: I can run FindTransferAnchors(...) when I use default values for parameter weight.reduction. But when I use FindTransferAnchors(weight.reduction = "cca", ...) for integration, I get the error I mentioned above and my R session gets killed.

elhaam avatar Jun 06 '22 02:06 elhaam

Hi, could you post the code you are running and info on the two objects?

torkencz avatar Jun 17 '22 18:06 torkencz

Thanks for getting back to me! Sure, I have my Rscript in the following using Ref: https://satijalab.org/seurat/articles/pbmc3k_tutorial.html#####setup-the-seurat-object-1

library(dplyr) library(Seurat) library(patchwork) library(Signac) library(EnsDb.Hsapiens.v86) #####setwd("~/Downloads/alignment/Seurat/")

Load the RNA dataset

rna.dir <- "Raw/GSE126074_CellLineMixture_SNAREseq_cDNA_counts.tsv" rna <- read.csv(file = rna.dir , row.names = 1, header= TRUE, sep = '\t')

Initialize the Seurat object with the raw (non-normalized data).

rna <- CreateSeuratObject(counts = rna, project = "RNA") rna rna[["percent.mt"]] <- PercentageFeatureSet(rna, pattern = "^MT-") VlnPlot(rna, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3) plot1 <- FeatureScatter(rna, feature1 = "nCount_RNA", feature2 = "percent.mt") plot2 <- FeatureScatter(rna, feature1 = "nCount_RNA", feature2 = "nFeature_RNA") plot1 + plot2 rna <- subset(rna, subset = nFeature_RNA > 200) ##### pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5) rna <- FindVariableFeatures(rna, selection.method = "vst", nfeatures = 2000) top10 <- head(VariableFeatures(rna), 10) plot1 <- VariableFeaturePlot(rna) plot2 <- LabelPoints(plot = plot1, points = top10, repel = TRUE) plot1 + plot2 all.genes <- rownames(rna) rna <- ScaleData(rna, features = all.genes) rna <- RunPCA(rna) print(rna[["pca"]], dims = 1:5, nfeatures = 5) rna <- RunUMAP(rna, dims = 1:30) DimPlot(rna, reduction = "umap")

saveRDS(pbmc, file = "../output/pbmc_tutorial.rds")

############# RNA worked successfully so far! Now: focus on ATAC ###################################

atac.dir <- "Raw/GSE126074_CellLineMixture_SNAREseq_chromatin_counts.tsv" atac <- read.csv(file = atac.dir , row.names = 1, header= TRUE, sep = '\t') grange.counts <- StringToGRanges(rownames(atac), sep = c(":", "-")) grange.use <- seqnames(grange.counts) %in% standardChromosomes(grange.counts) atac <- atac[as.vector(grange.use), ] annotations <- GetGRangesFromEnsDb(ensdb = EnsDb.Hsapiens.v86) seqlevelsStyle(annotations) <- 'UCSC' genome(annotations) <- "hg38" frag.file <- "Raw/fragments.sort.bed.gz" chrom_assay <- CreateChromatinAssay( counts = atac, sep = c(":", "-"), genome = 'hg38', fragments = frag.file, min.cells = 10, annotation = annotations, validate.fragments = F ##### added by Elham due to an error: double check this: https://github.com/timoast/signac/issues/518 ) #####atac <- chrom_assay fragments_obj <- CreateFragmentObject( path = frag.file, cells = colnames(atac), validate.fragments = F ) atac <- CreateSeuratObject(counts = chrom_assay) DefaultAssay(atac) <- "RNA" atac <- RunTFIDF(atac) atac <- FindTopFeatures(atac, min.cutoff = "q0") atac <- FindVariableFeatures(atac, selection.method = "vst", nfeatures = 2000) atac <- RunSVD(atac) atac <- RunUMAP(atac, dims = 2:30, reduction = "lsi") ##### reduction.name = "umap.atac", reduction.key = "atacUMAP_" gene.activities <- GeneActivity(atac, features = VariableFeatures(rna))

add gene activities as a new assay

atac[["ACTIVITY"]] <- CreateAssayObject(counts = gene.activities)

normalize gene activities

DefaultAssay(atac) <- "ACTIVITY" atac <- NormalizeData(atac) atac <- ScaleData(atac, features = rownames(atac)) DefaultAssay(atac) <- "RNA"

transfer.anchors <- FindTransferAnchors(reference = rna, query = atac, features = VariableFeatures(rna), reference.assay = "RNA", query.assay = "ACTIVITY") # #features = intersect(rownames(rna[["RNA"]]), rownames(atac[["ACTIVITY"]])), #reduction = "cca" # CCA not working and R session gets killed if I keep this line in my code

If I comment out reduction = "cca" then my code works fine, but otherwise, it kills my kernel.

atac An object of class Seurat 3657 features across 1047 samples within 2 assays Active assay: RNA (2000 features, 0 variable features) 1 other assay present: ACTIVITY 2 dimensional reductions calculated: lsi, umap

rna An object of class Seurat 18666 features across 1047 samples within 1 assay Active assay: RNA (18666 features, 2000 variable features) 2 dimensional reductions calculated: pca, umap

Thanks for helping with this issue!

elhaam avatar Jun 18 '22 16:06 elhaam

Hi, I have the same issue. Running FindTransferAnchors with cca causes a segfault. I have sufficient overlap in features between the two datasets, and this works without cca (thanks @elhaam for the suggestion to try without cca).

I'm running this in the Signac docker image (timoast/signac:1.7.0). But the session info is below in case it helps.

sessionInfo()
> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] GenomeInfoDb_1.30.1   IRanges_2.28.0        S4Vectors_0.32.3
[4] BiocGenerics_0.40.0   ggplot2_3.3.5         Signac_1.7.0
[7] SeuratDisk_0.0.0.9019 SeuratObject_4.0.4    Seurat_4.1.0

loaded via a namespace (and not attached):
  [1] Rtsne_0.15             colorspace_2.0-3       deldir_1.0-6
  [4] ellipsis_0.3.2         ggridges_0.5.3         XVector_0.34.0
  [7] GenomicRanges_1.46.1   spatstat.data_2.1-2    leiden_0.3.9
 [10] listenv_0.8.0          ggrepel_0.9.1          bit64_4.0.5
 [13] RSpectra_0.16-0        fansi_1.0.2            codetools_0.2-18
 [16] splines_4.1.0          RcppRoll_0.3.0         polyclip_1.10-0
 [19] jsonlite_1.8.0         Rsamtools_2.8.0        ica_1.0-2
 [22] cluster_2.1.2          png_0.1-7              uwot_0.1.11
 [25] shiny_1.7.1            sctransform_0.3.3      spatstat.sparse_2.1-0
 [28] compiler_4.1.0         httr_1.4.2             assertthat_0.2.1
 [31] Matrix_1.3-3           fastmap_1.1.0          lazyeval_0.2.2
 [34] cli_3.3.0              later_1.3.0            htmltools_0.5.2
 [37] tools_4.1.0            igraph_1.2.11          gtable_0.3.0
 [40] glue_1.6.2             GenomeInfoDbData_1.2.7 RANN_2.6.1
 [43] reshape2_1.4.4         dplyr_1.0.8            fastmatch_1.1-3
 [46] Rcpp_1.0.8             scattermore_0.8        Biostrings_2.62.0
 [49] vctrs_0.3.8            nlme_3.1-152           lmtest_0.9-39
 [52] spatstat.random_2.1-0  stringr_1.4.0          globals_0.14.0
 [55] mime_0.12              miniUI_0.1.1.1         lifecycle_1.0.1
 [58] irlba_2.3.5            goftest_1.2-3          future_1.24.0
 [61] zlibbioc_1.40.0        MASS_7.3-54            zoo_1.8-9
 [64] scales_1.1.1           spatstat.core_2.4-0    promises_1.2.0.1
 [67] spatstat.utils_2.3-0   parallel_4.1.0         RColorBrewer_1.1-2
 [70] reticulate_1.24        pbapply_1.5-0          gridExtra_2.3
 [73] rpart_4.1-15           stringi_1.7.6          BiocParallel_1.28.3
 [76] rlang_1.0.2            pkgconfig_2.0.3        matrixStats_0.61.0
 [79] bitops_1.0-7           lattice_0.20-44        ROCR_1.0-11
 [82] purrr_0.3.4            tensor_1.5             patchwork_1.1.1
 [85] htmlwidgets_1.5.4      cowplot_1.1.1          bit_4.0.4
 [88] tidyselect_1.1.2       parallelly_1.30.0      RcppAnnoy_0.0.19
 [91] plyr_1.8.6             magrittr_2.0.2         R6_2.5.1
 [94] generics_0.1.2         DBI_1.1.2              pillar_1.7.0
 [97] withr_2.5.0            mgcv_1.8-35            fitdistrplus_1.1-8
[100] survival_3.2-11        abind_1.4-5            RCurl_1.98-1.6
[103] tibble_3.1.6           future.apply_1.8.1     crayon_1.5.0
[106] hdf5r_1.3.5            KernSmooth_2.23-20     utf8_1.2.2
[109] spatstat.geom_2.3-2    plotly_4.10.0          grid_4.1.0
[112] data.table_1.14.2      digest_0.6.29          xtable_1.8-4
[115] tidyr_1.2.0            httpuv_1.6.5           munsell_0.5.0
[118] viridisLite_0.4.0

cflerin avatar Jul 04 '22 12:07 cflerin

I followed the scripts in Integrating scRNA-seq and scATAC-seq data and got the same error as @elhaam 's when running FindTransferAnchors. Are there any solutions? Please see my sessionInfo. `> sessionInfo() R version 4.1.3 (2022-03-10) Platform: x86_64-conda-linux-gnu (64-bit) Running under: CentOS Stream 8

Matrix products: default BLAS/LAPACK: /home/jliu25/anaconda3/envs/seurat4/lib/libopenblasp-r0.3.20.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] 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 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] nlme_3.1-158 matrixStats_0.62.0 spatstat.sparse_2.1-1 [4] RcppAnnoy_0.0.19 RColorBrewer_1.1-3 httr_1.4.3 [7] sctransform_0.3.3 tools_4.1.3 utf8_1.2.2 [10] R6_2.5.1 irlba_2.3.5 rpart_4.1.16 [13] KernSmooth_2.23-20 uwot_0.1.11 mgcv_1.8-40 [16] rgeos_0.5-9 DBI_1.1.3 lazyeval_0.2.2 [19] colorspace_2.0-3 sp_1.5-0 tidyselect_1.1.2 [22] gridExtra_2.3 compiler_4.1.3 progressr_0.10.1 [25] cli_3.3.0 plotly_4.10.0 Seurat_4.1.1 [28] scales_1.2.0 lmtest_0.9-40 spatstat.data_2.2-0 [31] ggridges_0.5.3 pbapply_1.5-0 goftest_1.2-3 [34] stringr_1.4.0 digest_0.6.29 spatstat.utils_2.3-1 [37] pkgconfig_2.0.3 htmltools_0.5.2 parallelly_1.32.0 [40] fastmap_1.1.0 htmlwidgets_1.5.4 rlang_1.0.3 [43] shiny_1.7.1 generics_0.1.3 zoo_1.8-10 [46] jsonlite_1.8.0 spatstat.random_2.2-0 ica_1.0-2 [49] dplyr_1.0.9 magrittr_2.0.3 patchwork_1.1.1 [52] Matrix_1.4-1 Rcpp_1.0.8.3 munsell_0.5.0 [55] fansi_1.0.3 abind_1.4-5 reticulate_1.25 [58] lifecycle_1.0.1 stringi_1.7.6 MASS_7.3-57 [61] Rtsne_0.16 plyr_1.8.7 grid_4.1.3 [64] parallel_4.1.3 listenv_0.8.0 promises_1.2.0.1 [67] ggrepel_0.9.1 crayon_1.5.1 deldir_1.0-6 [70] miniUI_0.1.1.1 lattice_0.20-45 cowplot_1.1.1 [73] splines_4.1.3 tensor_1.5 pillar_1.7.0 [76] igraph_1.3.2 spatstat.geom_2.4-0 future.apply_1.9.0 [79] reshape2_1.4.4 codetools_0.2-18 leiden_0.4.2 [82] glue_1.6.2 SeuratObject_4.1.0 data.table_1.14.2 [85] png_0.1-7 vctrs_0.4.1 httpuv_1.6.5 [88] polyclip_1.10-0 gtable_0.3.0 RANN_2.6.1 [91] purrr_0.3.4 spatstat.core_2.4-4 tidyr_1.2.0 [94] scattermore_0.8 future_1.26.1 assertthat_0.2.1 [97] ggplot2_3.3.6 mime_0.12 xtable_1.8-4 [100] later_1.3.0 survival_3.3-1 viridisLite_0.4.0 [103] tibble_3.1.7 cluster_2.1.3 globals_0.15.1 [106] fitdistrplus_1.1-8 ellipsis_0.3.2 ROCR_1.0-11 `

LiuJJ0327 avatar Jul 06 '22 04:07 LiuJJ0327

Hello, I got the same issue. Is there any solution ?

heomanism avatar Apr 04 '23 02:04 heomanism

You can try the RPCA based integration as suggested in this vignette.

saketkc avatar Jun 30 '23 19:06 saketkc