satijalab / seurat

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

New Error with subsetting in Seurat V5 #8000

Closed aLostMedStudent closed 3 months ago

aLostMedStudent commented 11 months ago

I was previously capable of manipulating this Seurat object with the subset function no without issue. Yesterday I updated my R from 4.1 to 4.3.2 and updated to Seurat V5. The weird thing is that this error is specific to this seurat object (i.e. when I loaded in a different object and used the subset function there was no such error). I would prefer not to have to re-create this object as it is rather larger. Thank you in advance!

The error is listed below:

fibroblasts <- subset(fibroblasts, idents = c("0", "1", "4")) Error in getClassDef(x@superClass, package = packageSlot(x))@virtual : no applicable method for @ applied to an object of class "NULL"

sessionInfo() R version 4.3.2 (2023-10-31) Platform: x86_64-apple-darwin20 (64-bit) Running under: macOS Sonoma 14.1

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York tzcode source: internal

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

other attached packages: [1] Seurat_5.0.0 SeuratObject_5.0.0 sp_2.1-1

loaded via a namespace (and not attached): [1] RColorBrewer_1.1-3 rstudioapi_0.15.0 jsonlite_1.8.7 magrittr_2.0.3 spatstat.utils_3.0-4 farver_2.1.1
[7] fs_1.6.3 vctrs_0.6.4 ROCR_1.0-11 memoise_2.0.1 spatstat.explore_3.2-5 htmltools_0.5.7
[13] usethis_2.2.2 sctransform_0.4.1 parallelly_1.36.0 KernSmooth_2.23-22 htmlwidgets_1.6.2 ica_1.0-3
[19] plyr_1.8.9 plotly_4.10.3 zoo_1.8-12 cachem_1.0.8 igraph_1.5.1 mime_0.12
[25] lifecycle_1.0.4 pkgconfig_2.0.3 Matrix_1.6-2 R6_2.5.1 fastmap_1.1.1 fitdistrplus_1.1-11
[31] future_1.33.0 shiny_1.7.5.1 digest_0.6.33 colorspace_2.1-0 patchwork_1.1.3 ps_1.7.5
[37] tensor_1.5 RSpectra_0.16-1 irlba_2.3.5.1 pkgload_1.3.3 labeling_0.4.3 progressr_0.14.0
[43] fansi_1.0.5 spatstat.sparse_3.0-3 httr_1.4.7 polyclip_1.10-6 abind_1.4-5 compiler_4.3.2
[49] remotes_2.4.2.1 withr_2.5.2 fastDummies_1.7.3 pkgbuild_1.4.2 MASS_7.3-60 sessioninfo_1.2.2
[55] tools_4.3.2 lmtest_0.9-40 httpuv_1.6.12 future.apply_1.11.0 goftest_1.2-3 glue_1.6.2
[61] callr_3.7.3 nlme_3.1-163 promises_1.2.1 grid_4.3.2 Rtsne_0.16 cluster_2.1.4
[67] reshape2_1.4.4 generics_0.1.3 gtable_0.3.4 spatstat.data_3.0-3 tidyr_1.3.0 data.table_1.14.8
[73] utf8_1.2.4 spatstat.geom_3.2-7 RcppAnnoy_0.0.21 ggrepel_0.9.4 RANN_2.6.1 pillar_1.9.0
[79] stringr_1.5.0 spam_2.10-0 RcppHNSW_0.5.0 later_1.3.1 splines_4.3.2 dplyr_1.1.3
[85] lattice_0.22-5 survival_3.5-7 deldir_1.0-9 tidyselect_1.2.0 miniUI_0.1.1.1 pbapply_1.7-2
[91] gridExtra_2.3 scattermore_1.2 devtools_2.4.5 matrixStats_1.1.0 stringi_1.7.12 lazyeval_0.2.2
[97] codetools_0.2-19 tibble_3.2.1 cli_3.6.1 uwot_0.1.16 xtable_1.8-4 reticulate_1.34.0
[103] munsell_0.5.0 processx_3.8.2 Rcpp_1.0.11 globals_0.16.2 spatstat.random_3.2-1 png_0.1-8
[109] parallel_4.3.2 ellipsis_0.3.2 ggplot2_3.4.4 prettyunits_1.2.0 dotCall64_1.1-0 profvis_0.3.8
[115] urlchecker_1.0.1 listenv_0.9.0 viridisLite_0.4.2 scales_1.2.1 ggridges_0.5.4 leiden_0.4.3
[121] purrr_1.0.2 crayon_1.5.2 rlang_1.1.2 cowplot_1.1.1

RijndertAriese commented 11 months ago

Hi, I have the same error unfortunately. It appeared that this was a result from the graphs embedded. If I removed the nn/snn graphs it will subset just fine for me, but I cannot use the subset for subsequent analysis. What worked for me was downgrading to a v4.x Seurat package.

Cheers

frac2738 commented 11 months ago

Same here.

options(Seurat.object.assay.version = "v3")
> Idents(exp_Integrated) <- "ScType"
> exp_Integrated <- subset(exp_Integrated, idents = c("Platelet","HSPC","Eryth","CD4 Proliferating"), invert = TRUE) 
Error in getClassDef(x@superClass, package = packageSlot(x))@virtual :    
no applicable method for `@` applied to an object of class "NULL"

> class(exp_Integrated)
 [1] "Seurat"
 attr(,"package")
 [1] "SeuratObject"

> 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/libf77blas.so.3.10.3 
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3;  LAPACK version 3.9.0

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

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

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

other attached packages:
 [1] dplyr_1.1.3                 HGNChelper_0.8.1            scR_0.9.4                   ggpubr_0.6.0                doParallel_1.0.17               iterators_1.0.14            foreach_1.5.2              
 [8] pROC_1.18.5                 Boruta_8.0.0                ranger_0.15.1               caretEnsemble_2.0.3         caret_6.0-94                lattice_0.22-5              corrplot_0.92              
[15] kableExtra_1.3.4            SCpubr_2.0.2                DESeq2_1.40.2               RColorBrewer_1.1-3          RUVSeq_1.34.0               edgeR_3.42.4                limma_3.56.2               
[22] EDASeq_2.34.0               ShortRead_1.58.0            GenomicAlignments_1.36.0    SummarizedExperiment_1.30.2 MatrixGenerics_1.12.3       matrixStats_1.1.0           Rsamtools_2.16.0           
[29] GenomicRanges_1.52.1        Biostrings_2.68.1           GenomeInfoDb_1.36.4         XVector_0.40.0              IRanges_2.34.1              S4Vectors_0.38.2            BiocParallel_1.34.2        
[36] Biobase_2.60.0              BiocGenerics_0.46.0         factoextra_1.0.7            Seurat_5.0.0                SeuratObject_5.0.0          sp_2.1-1                    ggrepel_0.9.4              
[43] data.table_1.14.8           ggplot2_3.4.4               viridis_0.6.4               viridisLite_0.4.2           pheatmap_1.0.12            

loaded via a namespace (and not attached):
  [1] R.methodsS3_1.8.2       progress_1.2.2          nnet_7.3-19             goftest_1.2-3           vctrs_0.6.4             spatstat.random_3.2-1   digest_0.6.33           png_0.1-8              
  [9] shape_1.4.6             deldir_1.0-9            parallelly_1.36.0       MASS_7.3-60             reshape2_1.4.4          httpuv_1.6.12           withr_2.5.2             xfun_0.41              
 [17] ellipsis_0.3.2          survival_3.5-7          memoise_2.0.1           systemfonts_1.0.5       ragg_1.2.6              zoo_1.8-12              GlobalOptions_0.1.2     pbapply_1.7-2          
 [25] R.oo_1.25.0             prettyunits_1.2.0       KEGGREST_1.40.1         promises_1.2.1          httr_1.4.7              rstatix_0.7.2           restfulr_0.0.15         globals_0.16.2         
 [33] fitdistrplus_1.1-11     ps_1.7.5                rstudioapi_0.15.0       miniUI_0.1.1.1          generics_0.1.3          processx_3.8.2          curl_5.1.0              zlibbioc_1.46.0        
 [41] polyclip_1.10-6         GenomeInfoDbData_1.2.10 desc_1.4.2              xtable_1.8-4            stringr_1.5.0           evaluate_0.23           S4Arrays_1.0.6          BiocFileCache_2.8.0    
 [49] hms_1.1.3               irlba_2.3.5.1           colorspace_2.1-0        filelock_1.0.2          ROCR_1.0-11             reticulate_1.34.0       spatstat.data_3.0-3     magrittr_2.0.3         
 [57] lmtest_0.9-40           later_1.3.1             spatstat.geom_3.2-7     future.apply_1.11.0     scattermore_1.2             XML_3.99-0.15           cowplot_1.1.1           RcppAnnoy_0.0.21       
 [65] class_7.3-22            pillar_1.9.0            nlme_3.1-163            compiler_4.3.1          RSpectra_0.16-1         stringi_1.7.12              gower_1.0.1             tensor_1.5             
 [73] lubridate_1.9.3         plyr_1.8.9              crayon_1.5.2            abind_1.4-5             BiocIO_1.10.0           gridGraphics_0.5-1      locfit_1.5-9.8          bit_4.0.5              
 [81] codetools_0.2-19        textshaping_0.3.7       recipes_1.0.8           plotly_4.10.3           mime_0.12               splines_4.3.1           circlize_0.4.15         Rcpp_1.0.11            
 [89] fastDummies_1.7.3       dbplyr_2.4.0            interp_1.1-4            knitr_1.45              blob_1.2.4              utf8_1.2.4              fs_1.6.3                listenv_0.9.0          
 [97] pkgbuild_1.4.2          openxlsx_4.2.5.2        ggsignif_0.6.4          ggplotify_0.1.2         tibble_3.2.1            Matrix_1.6-2            callr_3.7.3             svglite_2.1.2          
[105] pkgconfig_2.0.3         tools_4.3.1             cachem_1.0.8            RSQLite_2.3.3           rvest_1.0.3             DBI_1.1.3               fastmap_1.1.1           rmarkdown_2.25         
[113] scales_1.2.1            grid_4.3.1              ica_1.0-3               broom_1.0.5             patchwork_1.1.3         dotCall64_1.1-0         carData_3.0-5           RANN_2.6.1             
[121] rpart_4.1.21            farver_2.1.1            yaml_2.3.7              latticeExtra_0.6-30     rtracklayer_1.60.1      cli_3.6.1               purrr_1.0.2             webshot_0.5.5          
[129] leiden_0.4.3            lifecycle_1.0.4         uwot_0.1.16             lava_1.7.3              backports_1.4.1         timechange_0.2.0        gtable_0.3.4            rjson_0.2.21           
[137] ggridges_0.5.4          progressr_0.14.0        jsonlite_1.8.7          RcppHNSW_0.5.0          bitops_1.0-7            bit64_4.0.5             assertthat_0.2.1        Rtsne_0.16             
[145] yulab.utils_0.1.0       spatstat.utils_3.0-4    zip_2.3.0               R.utils_2.12.2          timeDate_4022.108       lazyeval_0.2.2          shiny_1.7.5.1           htmltools_0.5.7        
[153] sctransform_0.4.1       rappdirs_0.3.3          glue_1.6.2              spam_2.10-0             RCurl_1.98-1.13         rprojroot_2.0.4         jpeg_0.1-10             gridExtra_2.3          
[161] igraph_1.5.1            R6_2.5.1                tidyr_1.3.0             forcats_1.0.0           labeling_0.4.3          GenomicFeatures_1.52.2  cluster_2.1.4           ipred_0.9-14           
[169] DelayedArray_0.26.7     tidyselect_1.2.0        xml2_1.3.5              car_3.1-2               AnnotationDbi_1.62.2    future_1.33.0           ModelMetrics_1.2.2.2    munsell_0.5.0          
[177] KernSmooth_2.23-22      htmlwidgets_1.6.2       aroma.light_3.30.0      hwriter_1.3.2.1         biomaRt_2.56.1          rlang_1.1.2             spatstat.sparse_3.0-3   spatstat.explore_3.2-5 
[185] remotes_2.4.2.1         fansi_1.0.5             hardhat_1.3.0           prodlim_2023.08.28 

I also get the same error when I try to split.by the feature plot in SCpubr.

mhkowalski commented 11 months ago

Hi, thanks for reporting this issue. Could you please try running UpdateSeuratObject on your object and then subsetting?

aLostMedStudent commented 11 months ago

Hi, I have done this and it did not fix the error. Thank you for your suggestion though! On Nov 10, 2023 at 3:58 PM -0500, mhkowalski @.***>, wrote:

Hi, thanks for reporting this issue. Could you please try running UpdateSeuratObject on your object and then subsetting? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

longmanz commented 11 months ago

Hi, Thanks for reporting this. This has been reported multiple times (https://github.com/satijalab/seurat/issues/7983, https://github.com/satijalab/seurat/issues/7993, https://github.com/satijalab/seurat/issues/7999), and is caused by the Matrix package version 1.6-2. Please down-grade your Matrix back to 1.6-1.1 to temporarily avoid this error: remotes::install_version("Matrix", version = "1.6-1.1").

afletch00 commented 11 months ago

I downgraded Matrix and I still cannot subset...

ABauer26 commented 11 months ago

Hello! I've also updated to Seurat v5 under R/4.2.3. I'm reaching a similar subsetting error with the spatial transcriptomics 10X Genomics Visium analysis under the seurat5 spatial vignette. While using the provided mouse brain spatial data and brain object, I run into the error that an object of type 'S4' is not subsettable while trying to execute a GroupCorrelation command. I have tried the referenced solutions above, including the UpdateSeuratObject as well as the Matrix package down-grade to 1.6-1.1. Nothing seems to work, so I thought I would also chime in to see if solutions become available. Cheers ~

frac2738 commented 11 months ago

Downgrading to Matrix 1.6-1 (which is the minimum required by seurat5 ) fixed it.

> 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/libf77blas.so.3.10.3 
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3;  LAPACK version 3.9.0

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

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

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

other attached packages:
 [1] Matrix_1.6-1                dplyr_1.1.3                 HGNChelper_0.8.1            scR_0.9.4                   ggpubr_0.6.0                doParallel_1.0.17          
 [7] iterators_1.0.14            foreach_1.5.2               pROC_1.18.5                 Boruta_8.0.0                ranger_0.15.1               caretEnsemble_2.0.3        
[13] caret_6.0-94                lattice_0.22-5              corrplot_0.92               kableExtra_1.3.4            SCpubr_2.0.2                DESeq2_1.40.2              
[19] RColorBrewer_1.1-3          wesanderson_0.3.7           paletteer_1.5.0             RUVSeq_1.34.0               edgeR_3.42.4                limma_3.56.2               
[25] EDASeq_2.34.0               ShortRead_1.58.0            GenomicAlignments_1.36.0    SummarizedExperiment_1.30.2 MatrixGenerics_1.12.3       matrixStats_1.1.0          
[31] Rsamtools_2.16.0            GenomicRanges_1.52.1        Biostrings_2.68.1           GenomeInfoDb_1.36.4         XVector_0.40.0              IRanges_2.34.1             
[37] S4Vectors_0.38.2            BiocParallel_1.34.2         Biobase_2.60.0              BiocGenerics_0.46.0         factoextra_1.0.7            Seurat_5.0.0               
[43] SeuratObject_5.0.0          sp_2.1-1                    ggrepel_0.9.4               data.table_1.14.8           ggplot2_3.4.4               viridis_0.6.4              
[49] viridisLite_0.4.2           pheatmap_1.0.12            

loaded via a namespace (and not attached):
  [1] spatstat.sparse_3.0-3   bitops_1.0-7            lubridate_1.9.3         httr_1.4.7              webshot_0.5.5           backports_1.4.1         tools_4.3.1             sctransform_0.4.1      
  [9] utf8_1.2.4              R6_2.5.1                lazyeval_0.2.2          uwot_0.1.16             withr_2.5.2             prettyunits_1.2.0       gridExtra_2.3           progressr_0.14.0       
 [17] cli_3.6.1               spatstat.explore_3.2-5  fastDummies_1.7.3       spatstat.data_3.0-3     ggridges_0.5.4          pbapply_1.7-2           systemfonts_1.0.5       svglite_2.1.2          
 [25] R.utils_2.12.2          parallelly_1.36.0       rstudioapi_0.15.0       RSQLite_2.3.3           shape_1.4.6             generics_0.1.3          BiocIO_1.10.0           hwriter_1.3.2.1        
 [33] ica_1.0-3               spatstat.random_3.2-1   car_3.1-2               zip_2.3.0               interp_1.1-4            fansi_1.0.5             abind_1.4-5             R.methodsS3_1.8.2      
 [41] lifecycle_1.0.4         yaml_2.3.7              carData_3.0-5           recipes_1.0.8           BiocFileCache_2.8.0     Rtsne_0.16              grid_4.3.1              blob_1.2.4             
 [49] promises_1.2.1          crayon_1.5.2            miniUI_0.1.1.1          cowplot_1.1.1           GenomicFeatures_1.52.2  KEGGREST_1.40.1         pillar_1.9.0            knitr_1.45             
 [57] rjson_0.2.21            future.apply_1.11.0     codetools_0.2-19        leiden_0.4.3            glue_1.6.2              remotes_2.4.2.1         vctrs_0.6.4             png_0.1-8              
 [65] spam_2.10-0             gtable_0.3.4            rematch2_2.1.2          cachem_1.0.8            gower_1.0.1             aroma.light_3.30.0      xfun_0.41               openxlsx_4.2.5.2       
 [73] prodlim_2023.08.28      S4Arrays_1.0.6          mime_0.12               survival_3.5-7          timeDate_4022.108       hardhat_1.3.0           lava_1.7.3              ellipsis_0.3.2         
 [81] fitdistrplus_1.1-11     ipred_0.9-14            ROCR_1.0-11             nlme_3.1-163            bit64_4.0.5             progress_1.2.2          filelock_1.0.2          RcppAnnoy_0.0.21       
 [89] irlba_2.3.5.1           rpart_4.1.21            KernSmooth_2.23-22      colorspace_2.1-0        DBI_1.1.3               nnet_7.3-19             tidyselect_1.2.0        processx_3.8.2         
 [97] bit_4.0.5               compiler_4.3.1          curl_5.1.0              rvest_1.0.3             xml2_1.3.5              DelayedArray_0.26.7     plotly_4.10.3           rtracklayer_1.60.1     
[105] scales_1.2.1            lmtest_0.9-40           callr_3.7.3             rappdirs_0.3.3          stringr_1.5.0           digest_0.6.33           goftest_1.2-3           spatstat.utils_3.0-4   
[113] rmarkdown_2.25          htmltools_0.5.7         pkgconfig_2.0.3         jpeg_0.1-10             dbplyr_2.4.0            fastmap_1.1.1           GlobalOptions_0.1.2     rlang_1.1.2            
[121] htmlwidgets_1.6.2       shiny_1.7.5.1           zoo_1.8-12              jsonlite_1.8.7          ModelMetrics_1.2.2.2    R.oo_1.25.0             RCurl_1.98-1.13         magrittr_2.0.3         
[129] GenomeInfoDbData_1.2.10 dotCall64_1.1-0         patchwork_1.1.3         munsell_0.5.0           Rcpp_1.0.11             reticulate_1.34.0       stringi_1.7.12          zlibbioc_1.46.0        
[137] MASS_7.3-60             plyr_1.8.9              pkgbuild_1.4.2          listenv_0.9.0           deldir_1.0-9            splines_4.3.1           tensor_1.5              circlize_0.4.15        
[145] hms_1.1.3               locfit_1.5-9.8          ps_1.7.5                igraph_1.5.1            spatstat.geom_3.2-7     ggsignif_0.6.4          RcppHNSW_0.5.0          reshape2_1.4.4         
[153] biomaRt_2.56.1          XML_3.99-0.15           evaluate_0.23           latticeExtra_0.6-30     httpuv_1.6.12           RANN_2.6.1              tidyr_1.3.0             purrr_1.0.2            
[161] polyclip_1.10-6         future_1.33.0           scattermore_1.2         broom_1.0.5             xtable_1.8-4            restfulr_0.0.15         RSpectra_0.16-1         rstatix_0.7.2          
[169] later_1.3.1             class_7.3-22            tibble_3.2.1            memoise_2.0.1           AnnotationDbi_1.62.2    cluster_2.1.4           timechange_0.2.0        globals_0.16.2      
izumidk commented 4 months ago

I'm trying to fix this issue by downgrading to Matrix 1.6-1 however, I am running into the issue that SeuratObject (5.0.2) depends on Matrix 1.6-4 and Seurat V5 depends on SeuratObect 5.0.2. So when I load Seurat with downgraded Matrix package I get this error

Error: package or namespace load failed for ‘SeuratObject’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 namespace ‘Matrix’ 1.6-1 is being loaded, but >= 1.6.4 is required
Error: package ‘SeuratObject’ could not be loaded
eds35016 commented 4 months ago

Is there a solution to this? Matrix >= 1.6.4 is required for SeuratObect 5.0.2

eds35016 commented 4 months ago

Reinstalling irlba after updating Matrix to >= 1.6.4 seems to have fixed the issue. See here.

igrabski commented 3 months ago

Thanks, as @eds35016 suggests, you should now be able to resolve this issue by updating Seurat, SeuratObject, and Matrix.