satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.29k stars 915 forks source link

Stitching matrices of class “data.frame” is not yet supported #7493

Open JuRaFrDe opened 1 year ago

JuRaFrDe commented 1 year ago

Hi guys,

I try to analyse a dataset which includes 7 replicates of two condition each. After running the pipeline with SCTransform(merged_seurat, vst.flavor = "v2") on my merged files and adjusting for batches using harmony I got good clustering and tried to follow up by using PrepSCTFindMarkers().

I the following issue: "Error in StitchMatrix(): ! Stitching matrices of class “data.frame” is not yet supported"

Is this a known problem or what do I do to solve it? Thanks for your help!

saketkc commented 1 year ago

Hi @JuRaFrDe ,

I am unable to reproduce this. Can you paste your full code here with sessionInfo()?

adbeggs commented 1 year ago

I'm having the same issue... I have taken a mouse inDrop seq dataset and succesfully imported 6 datasets with 2 different conditions into Seurat, presenting as a merged object according to the vignette. I run this code:

merged.data <- IntegrateLayers(object = merged.data, method = CCAIntegration,orig.reduction = "pca", new.reduction = "integrated.cca",verbose = TRUE)
merged.data <- FindNeighbors(merged.data, reduction = "integrated.cca", dims = 1:30)
merged.data <- FindClusters(merged.data, resolution = 2, cluster.name = "cca_clusters")
merged.data <- RunUMAP(merged.data, reduction = "integrated.cca", dims = 1:30, reduction.name = "umap.cca")

And get a lovely plot with 21 clusters, which is excellent. When I try and run the below I get:

> markers <- FindMarkers(merged.data,assay="RNA",ident.1=0)
Error in FindMarkers.StdAssay(object = data.use, slot = slot, cells.1 = cells$cells.1,  :
  data layers are not joined. Please run JoinLayers

So then I try JoinLayers:

> JoinLayers(merged.data)
Error in `StitchMatrix()`:
! Stitching matrices of class "data.frame" is not yet supported
Run `rlang::last_trace()` to see where the error occurred.

> rlang::last_trace(drop=FALSE)
<error/rlang_error>
Error in `StitchMatrix()`:
! Stitching matrices of class "data.frame" is not yet supported
---
Backtrace:
    ▆
 1. ├─SeuratObject::JoinLayers(merged.data)
 2. └─SeuratObject:::JoinLayers.Seurat(merged.data)
 3.   ├─SeuratObject::JoinLayers(...)
 4.   └─SeuratObject:::JoinLayers.Assay5(...)
 5.     └─SeuratObject:::JoinSingleLayers(...)
 6.       ├─SeuratObject::StitchMatrix(...)
 7.       └─SeuratObject:::StitchMatrix.default(...)
 8.         └─rlang::abort(...)

Not sure what I am doing wrong.

SessionInfo:

 > 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

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

time zone: Europe/London
tzcode source: system (glibc)

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

other attached packages:
 [1] Azimuth_0.4.6.9004      shinyBS_0.61.1          SeuratDisk_0.0.0.9020
 [4] panc8.SeuratData_3.0.2  patchwork_1.1.2         cowplot_1.1.1
 [7] ifnb.SeuratData_3.1.0   SeuratData_0.2.2        Matrix_1.5-4.1
[10] dplyr_1.1.2             Seurat_4.9.9.9058       SeuratObject_4.9.9.9091
[13] sp_2.0-0

loaded via a namespace (and not attached):
  [1] fs_1.6.2                          ProtGenerics_1.32.0
  [3] matrixStats_1.0.0                 spatstat.sparse_3.0-2
  [5] bitops_1.0-7                      DirichletMultinomial_1.42.0
  [7] devtools_2.4.5                    TFBSTools_1.38.0
  [9] httr_1.4.6                        RColorBrewer_1.1-3
 [11] profvis_0.3.8                     tools_4.3.1
 [13] sctransform_0.3.5                 utf8_1.2.3
 [15] R6_2.5.1                          DT_0.28
 [17] lazyeval_0.2.2                    uwot_0.1.16
 [19] rhdf5filters_1.12.1               urlchecker_1.0.1
 [21] withr_2.5.0                       prettyunits_1.1.1
 [23] gridExtra_2.3                     progressr_0.13.0
 [25] cli_3.6.1                         Biobase_2.60.0
 [27] spatstat.explore_3.2-1            fastDummies_1.7.3
 [29] EnsDb.Hsapiens.v86_2.99.0         shinyjs_2.1.0
 [31] labeling_0.4.2                    spatstat.data_3.0-1
 [33] readr_2.1.4                       ggridges_0.5.4
 [35] pbapply_1.7-2                     Rsamtools_2.16.0
 [37] R.utils_2.12.2                    parallelly_1.36.0
 [39] sessioninfo_1.2.2                 BSgenome_1.68.0
 [41] RSQLite_2.3.1                     generics_0.1.3
 [43] BiocIO_1.10.0                     gtools_3.9.4
 [45] ica_1.0-3                         spatstat.random_3.1-5
 [47] googlesheets4_1.1.1               GO.db_3.17.0
 [49] fansi_1.0.4                       S4Vectors_0.38.1
 [51] abind_1.4-5                       R.methodsS3_1.8.2
 [53] lifecycle_1.0.3                   yaml_2.3.7
 [55] SummarizedExperiment_1.30.2       rhdf5_2.44.0
 [57] BiocFileCache_2.8.0               Rtsne_0.16
 [59] grid_4.3.1                        blob_1.2.4
 [61] promises_1.2.0.1                  shinydashboard_0.7.2
 [63] crayon_1.5.2                      miniUI_0.1.1.1
 [65] lattice_0.21-8                    annotate_1.78.0
 [67] GenomicFeatures_1.52.1            KEGGREST_1.40.0
 [69] pillar_1.9.0                      GenomicRanges_1.52.0
 [71] rjson_0.2.21                      future.apply_1.11.0
 [73] codetools_0.2-19                  fastmatch_1.1-3
 [75] leiden_0.4.3                      glue_1.6.2
 [77] data.table_1.14.8                 remotes_2.4.2.1
 [79] vctrs_0.6.3                       png_0.1-8
 [81] spam_2.9-1                        cellranger_1.1.0
 [83] poweRlaw_0.70.6                   gtable_0.3.3
 [85] cachem_1.0.8                      Signac_1.9.0.9000
 [87] S4Arrays_1.0.4                    mime_0.12
 [89] pracma_2.4.2                      survival_3.5-5
 [91] gargle_1.5.1                      RcppRoll_0.3.0
 [93] ellipsis_0.3.2                    fitdistrplus_1.1-11
 [95] ROCR_1.0-11                       nlme_3.1-162
 [97] usethis_2.2.2                     bit64_4.0.5
 [99] progress_1.2.2                    filelock_1.0.2
[101] RcppAnnoy_0.0.21                  GenomeInfoDb_1.36.1
[103] rprojroot_2.0.3                   irlba_2.3.5.1
[105] KernSmooth_2.23-21                colorspace_2.1-0
[107] seqLogo_1.66.0                    BiocGenerics_0.46.0
[109] DBI_1.1.3                         tidyselect_1.2.0
[111] processx_3.8.2                    bit_4.0.5
[113] compiler_4.3.1                    curl_5.0.1
[115] hdf5r_1.3.8                       xml2_1.3.5
[117] desc_1.4.2                        DelayedArray_0.26.6
[119] plotly_4.10.2                     rtracklayer_1.60.0
[121] caTools_1.18.2                    scales_1.2.1
[123] lmtest_0.9-40                     callr_3.7.3
[125] rappdirs_0.3.3                    stringr_1.5.0
[127] digest_0.6.33                     goftest_1.2-3
[129] presto_1.0.0                      spatstat.utils_3.0-3
[131] XVector_0.40.0                    htmltools_0.5.5
[133] pkgconfig_2.0.3                   MatrixGenerics_1.12.2
[135] dbplyr_2.3.3                      fastmap_1.1.1
[137] ensembldb_2.24.0                  rlang_1.1.1
[139] htmlwidgets_1.6.2                 shiny_1.7.4.1
[141] farver_2.1.1                      zoo_1.8-12
[143] jsonlite_1.8.7                    BiocParallel_1.34.2
[145] R.oo_1.25.0                       RCurl_1.98-1.12
[147] magrittr_2.0.3                    GenomeInfoDbData_1.2.10
[149] dotCall64_1.0-2                   Rhdf5lib_1.22.0
[151] munsell_0.5.0                     Rcpp_1.0.11
[153] reticulate_1.30                   stringi_1.7.12
[155] zlibbioc_1.46.0                   MASS_7.3-60
[157] plyr_1.8.8                        pkgbuild_1.4.2
[159] parallel_4.3.1                    listenv_0.9.0
[161] ggrepel_0.9.3                     CNEr_1.36.0
[163] deldir_1.0-9                      Biostrings_2.68.1
[165] splines_4.3.1                     tensor_1.5
[167] hms_1.1.3                         BSgenome.Hsapiens.UCSC.hg38_1.4.5
[169] ps_1.7.5                          igraph_1.5.0
[171] spatstat.geom_3.2-4               RcppHNSW_0.4.1
[173] reshape2_1.4.4                    biomaRt_2.56.1
[175] stats4_4.3.1                      pkgload_1.3.2.1
[177] TFMPvalue_0.0.9                   XML_3.99-0.14
[179] tzdb_0.4.0                        JASPAR2020_0.99.10
[181] httpuv_1.6.11                     RANN_2.6.1
[183] tidyr_1.3.0                       purrr_1.0.1
[185] polyclip_1.10-4                   future_1.33.0
[187] scattermore_1.2                   ggplot2_3.4.2
[189] xtable_1.8-4                      restfulr_0.0.15
[191] AnnotationFilter_1.24.0           RSpectra_0.16-1
[193] later_1.3.1                       googledrive_2.1.1
[195] viridisLite_0.4.2                 tibble_3.2.1
[197] memoise_2.0.1                     AnnotationDbi_1.62.2
[199] GenomicAlignments_1.36.0          IRanges_2.34.1
[201] cluster_2.1.4                     globals_0.16.2
kthorner commented 1 year ago

Hi everyone,

I can also report this issue when trying to find markers for an integrated SCT v2 object. My observation is PrepSCTFindMarkers() works if the data are initially matrices, AKA I ran Read10X() followed by passing it to CreateSeuratObject(). With the same datasets, if I pre-processed the counts, read them in with read.table() and pass the data frames to CreateSeuratObject(), all individual/integration steps work as expected but PrepSCTFindMarkers() gives the same error. Not sure why the RNA assay would be influencing anything... Using R/4.2.1 and Seurat 4.9.9.9042

greengarden0925 commented 10 months ago

markers <- FindMarkers(merged.data,assay="RNA",ident.1=0) Error in FindMarkers.StdAssay(object = data.use, slot = slot, cells.1 = cells$cells.1, : data layers are not joined. Please run JoinLayers

At to markers <- FindMarkers(JoinLayers(merged.data),assay="RNA",ident.1=0) , I revised to markers <- FindMarkers(merged.data,assay="RNA",ident.1=0) and it worked for me. It seems that the system regard "merged.data" as separate dataset which necessitate "JoinLayers" to join these different assays together.