satijalab / seurat

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

Cannot load data from SeuratData: Error in as.vector(x) #8204

Closed lebelm closed 3 months ago

lebelm commented 10 months ago

Hello,

I wanted to reproduce the vignette "Introduction to scRNA-seq integration" (https://satijalab.org/seurat/articles/integration_introduction) and I ran into an issue when trying to load the dataset.

I ran: `install.packages("remotes") remotes::install_github("satijalab/seurat-data")

library(Seurat) library(SeuratData) library(patchwork) InstallData("ifnb")

ifnb <- LoadData("ifnb") `

And I got this ouput for the last line:

Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Avis : Assay RNA changing from Assay to Assay
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Validating object structure for Assay ‘RNA’
Object representation is consistent with the most current Seurat version
Error in as.vector(x) : no method for coercing this S4 class to a vector

The error seems like a generic type, and might be due to my environment but I have no idea where to start searching. I tried with other datasets such as "pbmcsca" but got the same issue.

Do you have an idea where the issue might be from ?

Thank you

My session info:

R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

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

time zone: Europe/Paris tzcode source: internal

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

other attached packages: [1] pbmcsca.SeuratData_3.0.0 ifnb.SeuratData_3.1.0 SeuratData_0.2.2.9001 ggplot2_3.4.4
[5] BiocParallel_1.36.0 scran_1.30.0 scuttle_1.12.0 SingleCellExperiment_1.24.0 [9] SummarizedExperiment_1.32.0 Biobase_2.62.0 GenomicRanges_1.54.1 GenomeInfoDb_1.38.2
[13] IRanges_2.36.0 S4Vectors_0.40.2 BiocGenerics_0.48.1 MatrixGenerics_1.14.0
[17] matrixStats_1.2.0 zellkonverter_1.12.1 patchwork_1.1.3 Seurat_5.0.1
[21] SeuratObject_5.0.1 sp_2.1-2 dplyr_1.1.4

loaded via a namespace (and not attached): [1] RcppAnnoy_0.0.21 splines_4.3.2 later_1.3.2 bitops_1.0-7
[5] filelock_1.0.3 tibble_3.2.1 polyclip_1.10-6 basilisk.utils_1.14.1
[9] fastDummies_1.7.3 lifecycle_1.0.4 edgeR_4.0.3 rprojroot_2.0.4
[13] globals_0.16.2 lattice_0.21-9 MASS_7.3-60 magrittr_2.0.3
[17] limma_3.58.1 plotly_4.10.3 rmarkdown_2.25 remotes_2.4.2.1
[21] yaml_2.3.8 metapod_1.10.0 httpuv_1.6.13 sctransform_0.4.1
[25] spam_2.10-0 spatstat.sparse_3.0-3 reticulate_1.34.0 cowplot_1.1.2
[29] pbapply_1.7-2 RColorBrewer_1.1-3 abind_1.4-5 zlibbioc_1.48.0
[33] Rtsne_0.17 purrr_1.0.2 RCurl_1.98-1.13 rappdirs_0.3.3
[37] GenomeInfoDbData_1.2.11 ggrepel_0.9.4 irlba_2.3.5.1 listenv_0.9.0
[41] spatstat.utils_3.0-4 goftest_1.2-3 RSpectra_0.16-1 dqrng_0.3.2
[45] spatstat.random_3.2-2 fitdistrplus_1.1-11 parallelly_1.36.0 DelayedMatrixStats_1.24.0 [49] leiden_0.4.3.1 codetools_0.2-19 DelayedArray_0.28.0 tidyselect_1.2.0
[53] farver_2.1.1 ScaledMatrix_1.10.0 spatstat.explore_3.2-5 jsonlite_1.8.8
[57] BiocNeighbors_1.20.0 ellipsis_0.3.2 progressr_0.14.0 ggridges_0.5.5
[61] survival_3.5-7 tools_4.3.2 ica_1.0-3 Rcpp_1.0.11
[65] glue_1.6.2 gridExtra_2.3 SparseArray_1.2.2 xfun_0.41
[69] here_1.0.1 withr_2.5.2 fastmap_1.1.1 basilisk_1.14.1
[73] bluster_1.12.0 fansi_1.0.6 digest_0.6.33 rsvd_1.0.5
[77] R6_2.5.1 mime_0.12 colorspace_2.1-0 scattermore_1.2
[81] tensor_1.5 spatstat.data_3.0-3 utf8_1.2.4 tidyr_1.3.0
[85] generics_0.1.3 data.table_1.14.10 httr_1.4.7 htmlwidgets_1.6.4
[89] S4Arrays_1.2.0 uwot_0.1.16 pkgconfig_2.0.3 gtable_0.3.4
[93] lmtest_0.9-40 XVector_0.42.0 htmltools_0.5.7 dotCall64_1.1-1
[97] scales_1.3.0 png_0.1-8 knitr_1.45 reshape2_1.4.4
[101] curl_5.2.0 nlme_3.1-163 zoo_1.8-12 stringr_1.5.1
[105] KernSmooth_2.23-22 vipor_0.4.7 parallel_4.3.2 miniUI_0.1.1.1
[109] ggrastr_1.0.2 pillar_1.9.0 grid_4.3.2 vctrs_0.6.5
[113] RANN_2.6.1 promises_1.2.1 BiocSingular_1.18.0 beachmat_2.18.0
[117] xtable_1.8-4 cluster_2.1.4 beeswarm_0.4.0 evaluate_0.23
[121] locfit_1.5-9.8 cli_3.6.2 compiler_4.3.2 rlang_1.1.2
[125] crayon_1.5.2 future.apply_1.11.0 labeling_0.4.3 ggbeeswarm_0.7.2
[129] plyr_1.8.9 stringi_1.8.3 viridisLite_0.4.2 deldir_2.0-2
[133] munsell_0.5.0 lazyeval_0.2.2 spatstat.geom_3.2-7 Matrix_1.6-4
[137] dir.expiry_1.10.0 RcppHNSW_0.5.0 sparseMatrixStats_1.14.0 future_1.33.0
[141] statmod_1.5.0 shiny_1.8.0 ROCR_1.0-11 igraph_1.6.0

zskylarli commented 10 months ago

Hi - I've encountered this error before, but restarting my R session after installing SeuratData solved the issue. Have you tried using a fresh session?

ritsuya-niwayama-servier commented 9 months ago

Was it solved by restarting? I am getting the same problem and restarting did not help. Thank you!

ritsuya-niwayama-servier commented 9 months ago

As written in https://satijalab.org/seurat/articles/install_v5, I reinstalled TFBSTools and then restarted R. Then it was solved for me. The webpage says we could use if it is a problem of Matrix while the error message here does not show if it is related to Matrix or not, but the reinstallation is possibly also a solution for the problem here. Thank you!

ianyfchang commented 7 months ago

I fixed the problem by following steps:

  1. lazyLoad("/path_to/R/x86_64-pc-linux-gnu-library/4.3/ifnb.SeuratData/data/Rdata")
  2. ifnb_obj <- UpdateSeuratObject(ifnb)
lauratwomey commented 6 months ago

Hi, I had the same issue and solved it with data("ifnb") UpdateSeuratObject(ifnb)

> sessionInfo()
R version 4.2.3 (2023-03-15 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22631)

Matrix products: default

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

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

other attached packages:
 [1] pbmc3k.SeuratData_3.1.4     ifnb.SeuratData_3.0.0       SeuratData_0.2.2.9001       DESeq2_1.38.3              
 [5] SummarizedExperiment_1.28.0 Biobase_2.58.0              MatrixGenerics_1.10.0       matrixStats_1.2.0          
 [9] GenomicRanges_1.50.2        GenomeInfoDb_1.34.9         IRanges_2.32.0              S4Vectors_0.36.2           
[13] BiocGenerics_0.44.0         Seurat_5.0.3                SeuratObject_5.0.1          sp_2.1-3                   
[17] RColorBrewer_1.1-3          lubridate_1.9.3             forcats_1.0.0               stringr_1.5.1              
[21] dplyr_1.1.4                 purrr_1.0.2                 readr_2.1.5                 tidyr_1.3.1                
[25] tibble_3.2.1                ggplot2_3.5.0               tidyverse_2.0.0            

loaded via a namespace (and not attached):
  [1] utf8_1.2.4                    spatstat.explore_3.2-7        reticulate_1.35.0             tidyselect_1.2.1             
  [5] RSQLite_2.3.6                 AnnotationDbi_1.60.2          htmlwidgets_1.6.4             grid_4.2.3                   
  [9] BiocParallel_1.32.6           Rtsne_0.17                    munsell_0.5.1                 ScaledMatrix_1.6.0           
 [13] codetools_0.2-20              ica_1.0-3                     future_1.33.2                 miniUI_0.1.1.1               
 [17] withr_3.0.0                   spatstat.random_3.2-3         colorspace_2.1-0              progressr_0.14.0             
 [21] filelock_1.0.3                rstudioapi_0.16.0             ROCR_1.0-11                   ggsignif_0.6.4               
 [25] tensor_1.5                    listenv_0.9.1                 GenomeInfoDbData_1.2.9        polyclip_1.10-6              
 [29] bit64_4.0.5                   parallelly_1.37.1             vctrs_0.6.5                   generics_0.1.3               
 [33] timechange_0.3.0              BiocFileCache_2.6.1           R6_2.5.1                      rsvd_1.0.5                   
 [37] locfit_1.5-9.9                bitops_1.0-7                  spatstat.utils_3.0-4          cachem_1.0.8                 
 [41] DelayedArray_0.24.0           promises_1.3.0                scales_1.3.0                  gtable_0.3.4                 
 [45] beachmat_2.14.2               globals_0.16.3                goftest_1.2-3                 spam_2.10-0                  
 [49] rlang_1.1.3                   splines_4.2.3                 rstatix_0.7.2                 lazyeval_0.2.2               
 [53] spatstat.geom_3.2-9           broom_1.0.5                   BiocManager_1.30.22           yaml_2.3.8                   
 [57] reshape2_1.4.4                abind_1.4-5                   backports_1.4.1               httpuv_1.6.15                
 [61] tools_4.2.3                   ggridges_0.5.6                Rcpp_1.0.12                   plyr_1.8.9                   
 [65] sparseMatrixStats_1.10.0      zlibbioc_1.44.0               RCurl_1.98-1.14               ggpubr_0.6.0                 
 [69] deldir_2.0-4                  pbapply_1.7-2                 cowplot_1.1.3                 zoo_1.8-12                   
 [73] ggrepel_0.9.5                 cluster_2.1.6                 magrittr_2.0.3                data.table_1.15.4            
 [77] RSpectra_0.16-1               scattermore_1.2               lmtest_0.9-40                 RANN_2.6.1                   
 [81] fitdistrplus_1.1-11           hms_1.1.3                     patchwork_1.2.0               mime_0.12                    
 [85] xtable_1.8-4                  XML_3.99-0.16.1               fastDummies_1.7.3             gridExtra_2.3                
 [89] compiler_4.2.3                KernSmooth_2.23-22            crayon_1.5.2                  htmltools_0.5.8.1            
 [93] tzdb_0.4.0                    later_1.3.2                   geneplotter_1.76.0            DBI_1.2.2                    
 [97] ExperimentHub_2.6.0           dbplyr_2.5.0                  MASS_7.3-60.0.1               rappdirs_0.3.3               
[101] Matrix_1.6-5                  car_3.1-2                     cli_3.6.2                     parallel_4.2.3               
[105] dotCall64_1.1-1               igraph_2.0.3                  pkgconfig_2.0.3               plotly_4.10.4                
[109] spatstat.sparse_3.0-3         annotate_1.76.0               XVector_0.38.0                digest_0.6.35                
[113] sctransform_0.4.1             RcppAnnoy_0.0.22              SingleR_2.0.0                 spatstat.data_3.0-4          
[117] Biostrings_2.66.0             leiden_0.4.3.1                uwot_0.1.16                   DelayedMatrixStats_1.20.0    
[121] curl_5.2.1                    shiny_1.8.1.1                 lifecycle_1.0.4               nlme_3.1-164                 
[125] jsonlite_1.8.8                carData_3.0-5                 viridisLite_0.4.2             fansi_1.0.6                  
[129] pillar_1.9.0                  lattice_0.22-6                KEGGREST_1.38.0               fastmap_1.1.1                
[133] httr_1.4.7                    survival_3.5-8                interactiveDisplayBase_1.36.0 glue_1.7.0                   
[137] celldex_1.8.0                 png_0.1-8                     BiocVersion_3.16.0            bit_4.0.5                    
[141] stringi_1.8.3                 blob_1.2.4                    RcppHNSW_0.6.0                BiocSingular_1.14.0          
[145] AnnotationHub_3.6.0           memoise_2.0.1                 renv_1.0.5                    irlba_2.3.5.1                
[149] future.apply_1.11.2          
Gesmira commented 3 months ago

Hi, Looks like the issue has been resolved in the comments. Closing now, but please feel free to reopen if the issue persists. Thanks!

goepp commented 4 weeks ago

To add another potential solution:

The problem

I had the same issue when loading SeuratData::LoadData("stxBrain", type = "anterior1"). I tried the above and I still got the error:

Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in Spatial
Updating slots in anterior1
Validating object structure for Assay5 ‘Spatial’
Validating object structure for VisiumV2 ‘anterior1’
Object representation is consistent with the most current Seurat version
Error in as.vector(x) : no method for coercing this S4 class to a vector

The solution

I realized that loading the packages scran, SpatialExperiment, and SpatialFeatureExperiment was creating the problem. Now running

library(Seurat)
library(SeuratData)
# library(scran) DO NOT RUN
# library(SpatialExperiment) DO NOT RUN
# library(SpatialFeatureExperiment) DO NOT RUN

brain <- SeuratData::LoadData("stxBrain", type = "anterior1")

works.

Session info

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.6.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-arm64/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: Europe/Berlin
tzcode source: internal

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

other attached packages:
[1] stxBrain.SeuratData_0.1.2 pbmcsca.SeuratData_3.0.0  ifnb.SeuratData_3.1.0     SeuratData_0.2.2.9001     Seurat_5.1.0              SeuratObject_5.0.2       
[7] sp_2.1-4                 

loaded via a namespace (and not attached):
  [1] deldir_2.0-4           pbapply_1.7-2          gridExtra_2.3          rlang_1.1.4            magrittr_2.0.3         RcppAnnoy_0.0.22       matrixStats_1.4.1     
  [8] ggridges_0.5.6         compiler_4.3.2         spatstat.geom_3.3-2    png_0.1-8              vctrs_0.6.5            reshape2_1.4.4         stringr_1.5.1         
 [15] crayon_1.5.3           pkgconfig_2.0.3        fastmap_1.2.0          utf8_1.2.4             promises_1.3.0         purrr_1.0.2            jsonlite_1.8.8        
 [22] goftest_1.2-3          later_1.3.2            spatstat.utils_3.1-0   irlba_2.3.5.1          parallel_4.3.2         cluster_2.1.6          R6_2.5.1              
 [29] ica_1.0-3              stringi_1.8.4          RColorBrewer_1.1-3     spatstat.data_3.1-2    reticulate_1.39.0      parallelly_1.38.0      spatstat.univar_3.0-1 
 [36] lmtest_0.9-40          scattermore_1.2        Rcpp_1.0.13            tensor_1.5             future.apply_1.11.2    zoo_1.8-12             sctransform_0.4.1     
 [43] httpuv_1.6.15          Matrix_1.6-5           splines_4.3.2          igraph_2.0.3           tidyselect_1.2.1       rstudioapi_0.16.0      abind_1.4-8           
 [50] spatstat.random_3.3-1  codetools_0.2-20       miniUI_0.1.1.1         spatstat.explore_3.3-2 listenv_0.9.1          lattice_0.22-6         tibble_3.2.1          
 [57] plyr_1.8.9             shiny_1.9.1            ROCR_1.0-11            Rtsne_0.17             future_1.34.0          fastDummies_1.7.4      survival_3.7-0        
 [64] polyclip_1.10-7        fitdistrplus_1.2-1     pillar_1.9.0           KernSmooth_2.23-24     plotly_4.10.4          generics_0.1.3         RcppHNSW_0.6.0        
 [71] ggplot2_3.5.1          munsell_0.5.1          scales_1.3.0           globals_0.16.3         xtable_1.8-4           glue_1.7.0             lazyeval_0.2.2        
 [78] tools_4.3.2            data.table_1.16.0      RSpectra_0.16-2        RANN_2.6.2             leiden_0.4.3.1         dotCall64_1.1-1        cowplot_1.1.3         
 [85] grid_4.3.2             tidyr_1.3.1            colorspace_2.1-1       nlme_3.1-166           patchwork_1.3.0        cli_3.6.3              rappdirs_0.3.3        
 [92] spatstat.sparse_3.1-0  spam_2.10-0            fansi_1.0.6            viridisLite_0.4.2      dplyr_1.1.4            uwot_0.1.16            gtable_0.3.5          
 [99] digest_0.6.37          progressr_0.14.0       ggrepel_0.9.6          htmlwidgets_1.6.4      farver_2.1.2           htmltools_0.5.8.1      lifecycle_1.0.4       
[106] httr_1.4.7             mime_0.12              MASS_7.3-60.0.1