Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seurat Merge Error #6462

Closed
meaksu opened this issue Sep 25, 2022 · 6 comments
Closed

Seurat Merge Error #6462

meaksu opened this issue Sep 25, 2022 · 6 comments
Labels
bug Something isn't working more-information-needed We need more information before this can be addressed

Comments

@meaksu
Copy link

meaksu commented Sep 25, 2022

Hi,
I'm getting an error when trying to merge two Seurat objects:

> myeloid_subset <- merge(myeloid_subset, y = myeloid_strays_1) Error in apply(X = GetAssayData(object = object, assay = assay, slot = "scale.data")[, : dim(X) must have a positive length

I've run very similar code before and had no error. I thought maybe it was because the subsets weren't scaled which I never needed before, but even after scaling both myeloid_subset and myeloid_strays, and making sure the scale.data slot for the all assays were non-zero, I'm still getting the same error. Do you know what could be causing this? Thanks

@meaksu meaksu added the bug Something isn't working label Sep 25, 2022
@timoast
Copy link
Collaborator

timoast commented Oct 7, 2022

Can you show the output of sessionInfo()?

@timoast timoast added the more-information-needed We need more information before this can be addressed label Oct 7, 2022
@paulitikka
Copy link

paulitikka commented Nov 10, 2022

I am getting the same error with almost the same R code settings:

epimuneen<- merge(pb11, y = c(pb11), project = "tot") # ->

'Error in apply(X = GetAssayData(object = object, assay = assay, slot = "scale.data")[, :
dim(X) must have a positive length
In addition: Warning message:
In CheckDuplicateCellNames(object.list = objects) :
Some cell names are duplicated across objects provided. Renaming to enforce unique cell names.'

Fyi: the merge worked with a smaller cell number with this dataset, but with other dataset it did work for whatever size.
The dataset that does not merge looked like this (after beign reduced in size, pb11 <- pb11[,tna1]): pb11
An object of class Seurat
35067 features across 544 samples within 3 assays
Active assay: RNA (18079 features, 0 variable features)
2 other assays present: SCT, integrated
2 dimensional reductions calculated: pca, umap

(And the good merging one looked like: pb22
An object of class Seurat
39685 features across 5051 samples within 3 assays
Active assay: RNA (18993 features, 0 variable features)
2 other assays present: SCT, integrated
2 dimensional reductions calculated: pca, umap)

sessionInfo():

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Finnish_Finland.utf8 LC_CTYPE=Finnish_Finland.utf8 LC_MONETARY=Finnish_Finland.utf8 LC_NUMERIC=C LC_TIME=Finnish_Finland.utf8

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

other attached packages:
[1] ggvenn_0.1.9 parallelDist_0.2.6 leidenbase_0.1.12 BiocManager_1.30.19 clustifyr_1.8.0 affy_1.74.0 sctransform_0.3.5
[8] cowplot_1.1.1 scales_1.2.1 slingshot_2.4.0 TrajectoryUtils_1.4.0 princurve_2.1.6 destiny_3.10.0 ggbeeswarm_0.6.0
[15] ggthemes_4.2.4 runjags_2.2.1-7 oligo_1.60.0 oligoClasses_1.58.0 ArrayExpress_1.56.0 affyio_1.66.0 conos_1.5.0
[22] igraph_1.3.5 BH_1.78.0-0 namespace_0.9.1 circlize_0.4.15 ComplexHeatmap_2.12.1 org.Hs.eg.db_3.15.0 shiny_1.7.3
[29] Signac_1.8.0 Rmisc_1.5.1 plyr_1.8.7 lattice_0.20-45 bit64_4.0.5 bit_4.0.4 glmGamPoi_1.8.0
[36] scran_1.24.1 cluster_2.1.4 factoextra_1.0.7 gdata_2.18.0.1 rlist_0.4.6.2 rpart.plot_3.1.1 rpart_4.1.19
[43] WriteXLS_6.4.0 PRROC_1.3.1 reshape2_1.4.4 devtools_2.4.5 usethis_2.1.6 DESeq2_1.36.0 harmony_0.1.0
[50] Rcpp_1.0.9 stringi_1.7.8 SCINA_1.2.0 gplots_3.1.3 MASS_7.3-58.1 sleepwalk_0.3.2 forcats_0.5.2
[57] stringr_1.4.1 purrr_0.3.5 readr_2.1.3 tidyr_1.2.1 tibble_3.1.8 tidyverse_1.3.2 popsicleR_0.2.0
[64] scMCA_0.2.0 celldex_1.6.0 umap_0.2.9.0 neldermead_1.0-12 optimsimplex_1.0-8 optimbase_1.0-10 RANN_2.6.1
[71] ggplotify_0.1.0 RColorBrewer_1.1-3 ggExtra_0.10.0 crayon_1.5.2 magrittr_2.0.3 gridExtra_2.3 session_1.0.3
[78] future_1.29.0 SingleR_1.10.0 gtools_3.9.3 ape_5.6-2 clustree_0.5.0 ggraph_2.1.0 corrplot_0.92
[85] patchwork_1.1.2 SeuratWrappers_0.3.0 scDblFinder_1.10.0 DoubletFinder_2.0.3 m3addon_0.2 scrubletR_0.1.0 monocle_2.24.0
[92] testthat_3.1.5 DDRTree_0.1.5 irlba_2.3.5.1 VGAM_1.1-7 xlsx_0.6.5.9000 R.utils_2.12.1 R.oo_1.25.0
[99] R.methodsS3_1.8.2 htmltools_0.5.3 dplyr_1.0.10 scMerge_1.12.0 IntEREst_1.20.0 edgeR_3.38.4 limma_3.54.0
[106] Rsamtools_2.12.0 org.Mm.eg.db_3.15.0 scRNAseq_2.10.0 zellkonverter_1.6.5 SMITE_1.24.0 VISION_3.0.0 singleCellTK_2.6.0
[113] DelayedArray_0.22.0 Matrix_1.5-1 biomaRt_2.52.0 SCopeLoomR_0.13.0 stxBrain.SeuratData_0.1.1 SeuratData_0.2.2 SeuratDisk_0.0.0.9020
[120] LoomExperiment_1.14.0 BiocIO_1.6.0 rhdf5_2.42.0 loomR_0.2.1.9000 hdf5r_1.3.7 R6_2.5.1 jsonlite_1.8.3
[127] scater_1.24.0 ggplot2_3.4.0 scuttle_1.8.0 SingleCellExperiment_1.18.1 SummarizedExperiment_1.26.1 MatrixGenerics_1.8.1 matrixStats_0.62.0
[134] reticulate_1.26 rjson_0.2.21 tximeta_1.14.1 GenomicFeatures_1.48.4 AnnotationDbi_1.58.0 Biobase_2.56.0 eisaR_1.8.0
[141] BSgenome_1.64.0 rtracklayer_1.56.1 Biostrings_2.64.1 XVector_0.36.0 GenomicRanges_1.48.0 GenomeInfoDb_1.32.4 IRanges_2.30.1
[148] S4Vectors_0.34.0 BiocGenerics_0.44.0 rlang_1.0.6 Seurat_4.2.1 SeuratObject_4.1.3 sp_1.5-1

loaded via a namespace (and not attached):
[1] graph_1.74.0 urlchecker_1.0.1 abind_1.4-5 fastICA_1.2-3 GO.db_3.15.0 phangorn_2.10.0
[7] batchelor_1.14.0 dqrng_0.3.0 loe_1.1 HDF5Array_1.26.0 modelr_0.1.9 ellipsis_0.3.2
[13] memoise_2.0.1 ruv_0.9.7.1 munsell_0.5.0 pcaMethods_1.88.0 loo_2.5.1 locfit_1.5-9.6
[19] ggridges_0.5.4 seqinr_4.2-16 listenv_0.8.0 blob_1.2.3 interactiveDisplayBase_1.34.0 fgsea_1.22.0
[25] nloptr_2.0.3 lme4_1.1-31 sparseMatrixStats_1.10.0 mclust_6.0.0 RcppRoll_0.3.0 DropletUtils_1.16.0
[31] jpeg_0.1-9 vipor_0.4.5 ensembldb_2.20.2 progressr_0.11.0 fastmatch_1.1-3 basilisk_1.8.1
[37] leiden_0.4.3 dir.expiry_1.4.0 XML_3.99-0.12 basilisk.utils_1.8.0 foreach_1.5.2 openssl_2.0.4
[43] iotools_0.3-2 webutils_1.1 maps_3.4.1 laeken_0.5.2 tidyselect_1.2.0 filelock_1.0.2
[49] withr_2.5.0 RcppParallel_5.1.5 RMySQL_0.10.24 qlcMatrix_0.9.7 densityClust_0.3.2 future.apply_1.10.0
[55] DEoptimR_1.0-11 tzdb_0.3.0 googlesheets4_1.0.1 graphlayouts_0.8.3 rappdirs_0.3.3 doParallel_1.0.17
[61] DBI_1.1.3 shape_1.4.6 rprojroot_2.0.3 httr_1.4.4 spatstat.data_3.0-0 parallelly_1.32.1
[67] xml2_1.3.3 ff_4.0.7 deldir_1.0-6 interp_1.1-3 fastmap_1.1.0 ExperimentHub_2.4.0
[73] spatstat.geom_3.0-3 glue_1.6.2 tidygraph_1.2.2 swagger_3.33.1 viridis_0.6.2 fs_1.5.2
[79] bbmle_1.0.25 labeling_0.4.2 gargle_1.2.1 plotly_4.10.1 spatstat.sparse_3.0-0 clue_0.3-62
[85] mvtnorm_1.1-3 cli_3.4.1 geneLenDataBase_1.32.0 profvis_0.3.7 dbplyr_2.2.1 minqa_1.2.5
[91] BiocFileCache_2.4.0 plumber_1.2.1 latticeExtra_0.6-30 RCurl_1.98-1.9 polyclip_1.10-4 pillar_1.8.1
[97] prettyunits_1.1.1 remotes_2.4.2 ROCR_1.0-11 gtable_0.3.1 xfun_0.34 restfulr_0.0.15
[103] tweenr_2.0.2 miniUI_0.1.1.1 sccore_1.0.2 slam_0.1-50 survival_3.4-0 RBGL_1.72.0
[109] scattermore_0.8 lifecycle_1.0.3 KernSmooth_2.23-20 globals_0.16.1 spatstat.utils_3.0-1 scatterplot3d_0.3-42
[115] mgcv_1.8-41 backports_1.4.1 viridisLite_0.4.1 utf8_1.2.2 xlsxjars_0.6.1 GetoptLong_1.0.5
[121] Rtsne_0.16 fitdistrplus_1.1-8 BiocParallel_1.32.0 pbmcapply_1.5.1 generics_0.1.3 RUnit_0.4.32
[127] askpass_1.1 reldist_1.7-1 spatstat.explore_3.0-3 affxparser_1.68.1 zlibbioc_1.42.0 htmlTable_2.4.1
[133] sessioninfo_1.2.2 ResidualMatrix_1.8.0 ggrepel_0.9.2 monocle3_1.2.9 hms_1.1.2 png_0.1-7
[139] timechange_0.1.1 coda_0.19-4 pbapply_1.5-0 StanHeaders_2.21.0-7 wordspace_0.2-8 assertthat_0.2.1
[145] lazyeval_0.2.2 fields_14.1 numDeriv_2016.8-1.1 broom_1.0.1 htmlwidgets_1.5.4 annotate_1.74.0
[151] bluster_1.6.0 callr_3.7.3 beachmat_2.14.0 BiocNeighbors_1.16.0 caTools_1.18.2 rsvd_1.0.5
[157] beeswarm_0.4.0 ggforce_0.4.1 spatstat.random_3.0-1 fansi_1.0.3 ade4_1.7-20 rstan_2.21.7
[163] ggplot.multistats_1.0.0 anndata_0.7.5.5 DEXSeq_1.42.0 robustbase_0.95-0 knitr_1.40 brio_1.1.3
[169] ranger_0.14.1 bdsmatrix_1.3-6 logging_0.10-108 tximport_1.24.0 tools_4.2.2 BioNet_1.56.0
[175] data.table_1.14.4 RcppAnnoy_0.0.20 rhdf5filters_1.10.0 inline_0.3.19 dotCall64_1.0-2 statmod_1.4.37
[181] ps_1.7.2 GlobalOptions_0.1.2 ica_1.0-3 shinythemes_1.2.0 RcppEigen_0.3.3.9.3 AnnotationFilter_1.20.0
[187] combinat_0.0-8 bitops_1.0-7 quadprog_1.5-8 digest_0.6.30 proxy_0.4-27 pkgload_1.3.1
[193] Rhdf5lib_1.20.0 yulab.utils_0.0.5 ScaledMatrix_1.6.0 haven_2.5.1 rstudioapi_0.14 sparsesvd_0.2-1
[199] densEstBayes_1.0-2.1 xts_0.12.2 VIM_6.2.2 geneplotter_1.74.0 pheatmap_1.0.12 terra_1.6-17
[205] vctrs_0.5.0 uwot_0.1.14 zoo_1.8-11 cachem_1.0.6 vcd_1.4-10 colorspace_2.0-3
[211] BiasedUrn_2.0.8 curl_4.3.3 httpuv_1.6.6 carData_3.0-5 leidenAlg_1.0.5 Formula_1.2-4
[217] AnnotationHub_3.4.0 BiocVersion_3.15.2 GenomicAlignments_1.32.1 desc_1.4.2 base64enc_0.1-3 lubridate_1.9.0
[223] genefilter_1.78.0 class_7.3-20 ProtGenerics_1.28.0 startupmsg_0.9.6 DelayedMatrixStats_1.20.0 permute_0.9-7
[229] nnet_7.3-18 reprex_2.0.2 sfsmisc_1.1-13 later_1.3.0 M3Drop_1.22.0 hwriter_1.3.2.1
[235] tensor_1.5 DT_0.26 goseq_1.48.0 nlme_3.1-160 spam_2.9-1 hexbin_1.28.2
[241] jrc_0.5.1 rgeos_0.5-9 GSVAdata_1.32.0 car_3.1-1 xgboost_1.6.0.1 pkgbuild_1.3.1
[247] checkmate_2.1.0 rvest_1.0.3 compiler_4.2.2 xtable_1.8-4 rJava_1.0-6 farver_2.1.1
[253] googledrive_2.0.0 codetools_0.2-18 gridGraphics_0.5-1 svMisc_1.2.3 yaml_2.3.6 goftest_1.2-3
[259] preprocessCore_1.58.0 docopt_0.7.1 cellranger_1.1.0 GenomeInfoDbData_1.2.9 RcppHNSW_0.4.1 RSpectra_0.16-1
[265] promises_1.2.0.1 RSQLite_2.2.18 TTR_0.24.3 biocViews_1.64.1 FNN_1.1.3.1 lmtest_0.9-40
[271] readxl_1.4.1 BiocSingular_1.14.0 vegan_2.6-4 seqLogo_1.62.0 boot_1.3-28 metapod_1.4.0
[277] reactome.db_1.81.0 fishpond_2.2.0 HSMMSingleCell_1.16.0 KEGGREST_1.36.3 iterators_1.0.14 distr_2.8.0
[283] entropy_1.3.1 progress_1.2.2 processx_3.8.0 Hmisc_4.7-1 e1071_1.7-12 smoother_1.1
[289] foreign_0.8-83 mime_0.12 pkgconfig_2.0.3

@paulitikka
Copy link

A partial solution would be to make the Seurat dataframe again:
ok=pb11@meta.data
uu=GetAssayData(pb11); uu=data.frame(uu); mat <- as(as.matrix(uu), "sparseMatrix"); pb11 <- CreateSeuratObject(counts=mat) #to get merge working... :) #https://www.biostars.org/p/9527335/#9527339
pb11@meta.data=ok

@reberya
Copy link

reberya commented Jan 16, 2023

Bumping this w/ same issue and error message

> dat3 <- merge(x=dat1, y = dat2)
Error in apply(X = GetAssayData(object = object, assay = assay, slot = "scale.data")[,  : 
  dim(X) must have a positive length

Notably this is integrated data w/ SCT performed. After setting the SCT assay to NULL as so, the merge works

dat1[['SCT']] <- NULL
dat1[['SCT']] <- NULL
dat3 <- merge(x=dat1, y = dat2)

@Elo-mars
Copy link

Elo-mars commented Feb 16, 2024

Thanks you @reberya !
I've been stuck with this issue for hours!

I really don't understand why doing this would work so ... especially because I did the same merge with other samples coming from different tissues (but from the same batch, and they all got exactly the same preprocessing), and only for a subset of these I got this issue ... doesn't male sense to me

THANKS!

@rsatija
Copy link
Collaborator

rsatija commented Jun 24, 2024

The solution reberya posted should fix this in the short term. You can re-run SCT after merging. we are working on a longer-term fix. merging of objects (post-SCT),as can be problematic in some cases.

@rsatija rsatija closed this as completed Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working more-information-needed We need more information before this can be addressed
Projects
None yet
Development

No branches or pull requests

6 participants