GreenleafLab / ArchR

ArchR : Analysis of Regulatory Chromatin in R (www.ArchRProject.com)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addGeneIntegrationMatrix "Error in slot(object = object, name = \"features\")[[layer]] <- features : more elements supplied than there are to replace"

ShuhuanYu opened this issue · comments

Hi everyone, I am using ArchR to integrate scATAC-seq data with scRNA-seq(using addGeneIntegrationMatrix function), and I got these errors below. I have tried many possible solutions but failed, including changing Seurat version to Seurat v5 beta, installing BPCells, or changing the scRNA input…
It seems to be a problem with Seurat's "CreateSeuratObject" but I don't know how to solve it.

Code:

counts <- readRDS("../scRNA_integration/scRNA_integrated_counts.rds")
meta <- readRDS("../scRNA_integration/scRNA_integrated_metadata.rds")
scRNA <- SummarizedExperiment(assays = list(counts = counts), colData = meta)
proj <- addGeneIntegrationMatrix(
ArchRProj = proj,
useMatrix = "GeneScoreMatrix",
matrixName = "GeneIntegrationMatrix",
reducedDims = "IterativeLSI",
seRNA = scRNA,
addToArrow = FALSE,
groupRNA = "celltype",
nameCell = "predictedCell",
nameGroup = "predictedGroup",
nameScore = "predictedScore"
)

Error:

Error in .safelapply(seq_along(blockList), function(i) { :
Error Found Iteration 1 :
[1] "Error in slot(object = object, name = "features")[[layer]] <- features : \n more elements supplied than there are to replace\n"
<simpleError in slot(object = object, name = "features")[[layer]] <- features: more elements supplied than there are to replace>
Error Found Iteration 2 :
[1] "Error in slot(object = object, name = "features")[[layer]] <- features : \n more elements supplied than there are to replace\n"
<simpleError in slot(object = object, name = "features")[[layer]] <- features: more elements supplied than there are to replace>
Error Found Iteration 3 :
[1] "Error in slot(object = object, name = "features")[[layer]] <- features : \n more elements supplied than there are to replace\n"
<simpleError in slot(object = object, name = "features")[[layer]] <- features: more elements supplied than there are to replace>
Error Found Iteration 4 :
[1] "Error in slot(object = object, name = "features")[[layer]] <- features :
In addition: Warning message:
In mclapply(..., mc.cores = threads, mc.preschedule = preschedule) :
9 function calls resulted in an error

ArchR log file:
ArchR-addGeneIntegrationMatrix-622d6436250c4-Date-2024-01-05_Time-18-53-37.055589.log

sessionInfo():

R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

Random number generation:
RNG: L'Ecuyer-CMRG
Normal: Inversion
Sample: Rejection

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

time zone: Asia/Shanghai
tzcode source: system (glibc)

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

other attached packages:
[1] Seurat_5.0.1.9001 SeuratObject_5.0.1
[3] sp_2.1-2 rhdf5_2.44.0
[5] SummarizedExperiment_1.30.2 Biobase_2.60.0
[7] MatrixGenerics_1.12.3 Rcpp_1.0.11
[9] Matrix_1.6-4 GenomicRanges_1.52.1
[11] GenomeInfoDb_1.36.4 IRanges_2.34.1
[13] S4Vectors_0.38.2 BiocGenerics_0.46.0
[15] matrixStats_1.2.0 data.table_1.14.10
[17] stringr_1.5.1 plyr_1.8.9
[19] magrittr_2.0.3 ggplot2_3.4.4
[21] gtable_0.3.4 gtools_3.9.5
[23] gridExtra_2.3 ArchR_1.0.2

loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-3 jsonlite_1.8.8 spatstat.utils_3.0-4
[4] zlibbioc_1.46.0 vctrs_0.6.5 ROCR_1.0-11
[7] Cairo_1.6-2 spatstat.explore_3.2-5 RCurl_1.98-1.13
[10] htmltools_0.5.7 S4Arrays_1.0.6 Rhdf5lib_1.22.1
[13] sctransform_0.4.1 parallelly_1.36.0 KernSmooth_2.23-22
[16] htmlwidgets_1.6.4 ica_1.0-3 plotly_4.10.3
[19] zoo_1.8-12 igraph_1.6.0 mime_0.12
[22] lifecycle_1.0.4 pkgconfig_2.0.3 R6_2.5.1
[25] fastmap_1.1.1 GenomeInfoDbData_1.2.10 fitdistrplus_1.1-11
[28] future_1.33.1 shiny_1.8.0 digest_0.6.33
[31] colorspace_2.1-0 patchwork_1.1.3 tensor_1.5
[34] RSpectra_0.16-1 irlba_2.3.5.1 progressr_0.14.0
[37] fansi_1.0.6 spatstat.sparse_3.0-3 httr_1.4.7
[40] polyclip_1.10-6 abind_1.4-5 compiler_4.3.1
[43] withr_2.5.2 fastDummies_1.7.3 MASS_7.3-60
[46] DelayedArray_0.26.7 tools_4.3.1 lmtest_0.9-40
[49] httpuv_1.6.13 future.apply_1.11.1 goftest_1.2-3
[52] glue_1.6.2 nlme_3.1-164 rhdf5filters_1.12.1
[55] promises_1.2.1 Rtsne_0.17 cluster_2.1.6
[58] reshape2_1.4.4 generics_0.1.3 spatstat.data_3.0-3
[61] tidyr_1.3.0 utf8_1.2.4 XVector_0.40.0
[64] spatstat.geom_3.2-7 RcppAnnoy_0.0.21 ggrepel_0.9.4
[67] RANN_2.6.1 pillar_1.9.0 spam_2.10-0
[70] RcppHNSW_0.5.0 later_1.3.2 splines_4.3.1
[73] dplyr_1.1.4 lattice_0.22-5 survival_3.5-7
[76] deldir_2.0-2 tidyselect_1.2.0 miniUI_0.1.1.1
[79] pbapply_1.7-2 scattermore_1.2 stringi_1.8.3
[82] lazyeval_0.2.2 codetools_0.2-19 tibble_3.2.1
[85] cli_3.6.2 uwot_0.1.16 xtable_1.8-4
[88] reticulate_1.34.0 munsell_0.5.0 spatstat.random_3.2-2
[91] globals_0.16.2 png_0.1-8 ellipsis_0.3.2
[94] dotCall64_1.1-1 bitops_1.0-7 listenv_0.9.0
[97] viridisLite_0.4.2 scales_1.3.0 ggridges_0.5.5
[100] leiden_0.4.3.1 purrr_1.0.2 crayon_1.5.2
[103] rlang_1.1.2 cowplot_1.1.2

Hi @ShuhuanYu! Thanks for using ArchR! Please make sure that your post belongs in the Issues section. Only bugs and error reports belong in the Issues section. Usage questions and feature requests should be posted in the Discussions section, not in Issues.

It is worth noting that there are very few actual bugs in ArchR. If you are getting an error, it is probably something specific to your dataset, usage, or computational environment, all of which are extremely challenging to troubleshoot. As such, we require reproducible examples (preferably using the tutorial dataset) from users who want assistance. If you cannot reproduce your error, we will not be able to help.
Before going through the work of making a reproducible example, search the previous Issues, Discussions, function definitions, or the ArchR manual and you will likely find the answers you are looking for.
If your post does not contain a reproducible example, it is unlikely to receive a response.

__In addition to a reproducible example, you must do the following things before we help you, unless your original post already contained this information:
1. If you've encountered an error, have you already searched previous Issues to make sure that this hasn't already been solved?
2. Did you post your log file? If not, add it now.
3. Remove any screenshots that contain text and instead copy and paste the text using markdown's codeblock syntax (three consecutive backticks). You can do this by editing your original post.

Changing Seurat version to 4.4.1 solved this problem, and you need to change SeuratObject version simultaneously.

After repeated testing, I finally know the answer to this question:

This error occurred in the RNAIntegration.R of the ArchR package
This code in the RNAIntegration.R file:
seuratATAC <- Seurat::CreateSeuratObject(counts = mat[head(seq_len(nrow(mat)), 5), , drop = FALSE])

The Seurat::CreateSeuratObject function requires that the rownames of mat must be vector, not matrix. But the rownames passed to mat in the previous code was actually a matrix, so you only need to add a command line before this code, this will cast the rownames of mat to a vector:

rownames(mat) <- as.character(rownames(mat))

And then this error was completely eliminated.

How do I add that line of code, I changed the R script separately and then source loaded it and got an error.

Error in .validInput(input = ArchRProj, name = "ArchRProj", valid = c("ArchRProj")) :
没有".validInput"这个函数