satijalab / seurat

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

UpdateSeuratObject() function fails on newest version of Seurat. #8019

Closed sciwitch closed 3 months ago

sciwitch commented 11 months ago

UpdateSeuratObject() function fails on newest version of Seurat.

Below code used to still work on Seurat 4.4 version.

Tested with TabulaMuris data set (available from here: https://explore.data.humancellatlas.org/projects/e0009214-c0a0-4a7b-96e2-d6a83e966ce0/project-matrices).

`load("TabulaMuris/facs_Large_Intestine_seurat_tiss.Robj") tiss <- UpdateSeuratObject( tiss )

Updating from v2.X to v3.X Validating object structure Updating object slots Ensuring keys are in the proper structure Updating matrix keys for DimReduc ‘pca’ Updating matrix keys for DimReduc ‘tsne’ Ensuring keys are in the proper structure Ensuring feature names don't have underscores or pipes Updating slots in RNA Updating slots in pca Updating slots in tsne Setting tsne DimReduc to global Validating object structure for Assay ‘RNA’ Validating object structure for DimReduc ‘pca’ Error in validObject(object = object[[i]]) : invalid class “DimReduc” object: 'global' must be a 1-length logical In addition: Warning messages: 1: Not validating Assay objects 2: Not validating Assay objects 3: Not validating DimReduc objects 4: Not validating DimReduc objects 5: Not validating DimReduc objects 6: Not validating DimReduc objects 7: Not validating Seurat objects 8: Not validating Seurat objects `

sessionInfo()

` R version 4.3.2 (2023-10-31) 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/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3; LAPACK version 3.9.0

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

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

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] deldir_1.0-9 pbapply_1.7-2 gridExtra_2.3 rlang_1.1.2 magrittr_2.0.3
[6] RcppAnnoy_0.0.21 matrixStats_1.1.0 ggridges_0.5.4 compiler_4.3.2 spatstat.geom_3.2-7
[11] png_0.1-8 vctrs_0.6.4 reshape2_1.4.4 stringr_1.5.0 pkgconfig_2.0.3
[16] fastmap_1.1.1 ellipsis_0.3.2 utf8_1.2.4 promises_1.2.1 purrr_1.0.2
[21] jsonlite_1.8.7 goftest_1.2-3 later_1.3.1 spatstat.utils_3.0-4 irlba_2.3.5.1
[26] parallel_4.3.2 cluster_2.1.4 R6_2.5.1 ica_1.0-3 stringi_1.8.1
[31] RColorBrewer_1.1-3 spatstat.data_3.0-3 reticulate_1.34.0 parallelly_1.36.0 lmtest_0.9-40
[36] scattermore_1.2 Rcpp_1.0.11 tensor_1.5 future.apply_1.11.0 zoo_1.8-12
[41] sctransform_0.4.1 httpuv_1.6.12 Matrix_1.6-3 splines_4.3.2 igraph_1.5.1
[46] tidyselect_1.2.0 rstudioapi_0.15.0 abind_1.4-5 spatstat.random_3.2-1 codetools_0.2-19
[51] miniUI_0.1.1.1 spatstat.explore_3.2-5 listenv_0.9.0 lattice_0.22-5 tibble_3.2.1
[56] plyr_1.8.9 shiny_1.7.5.1 ROCR_1.0-11 Rtsne_0.16 future_1.33.0
[61] fastDummies_1.7.3 survival_3.5-7 polyclip_1.10-6 fitdistrplus_1.1-11 pillar_1.9.0
[66] KernSmooth_2.23-22 plotly_4.10.3 generics_0.1.3 RcppHNSW_0.5.0 ggplot2_3.4.4
[71] munsell_0.5.0 scales_1.2.1 globals_0.16.2 xtable_1.8-4 glue_1.6.2
[76] lazyeval_0.2.2 tools_4.3.2 data.table_1.14.8 RSpectra_0.16-1 RANN_2.6.1
[81] leiden_0.4.3 dotCall64_1.1-0 cowplot_1.1.1 grid_4.3.2 tidyr_1.3.0
[86] colorspace_2.1-0 nlme_3.1-163 patchwork_1.1.3 cli_3.6.1 spatstat.sparse_3.0-3 [91] spam_2.10-0 fansi_1.0.5 viridisLite_0.4.2 dplyr_1.1.3 uwot_0.1.16
[96] gtable_0.3.4 digest_0.6.33 progressr_0.14.0 ggrepel_0.9.4 htmlwidgets_1.6.2
[101] htmltools_0.5.7 lifecycle_1.0.4 httr_1.4.7 mime_0.12 MASS_7.3-60 `

chbnnn commented 10 months ago

encountered the same problem too

superjmiscool commented 10 months ago

me too

monisha1202 commented 10 months ago

Any updates on the issue?

ddiez commented 10 months ago

Same problem with old data from tabula muris like:

https://figshare.com/ndownloader/files/13090580

Datasets are Robj so need to be loaded into R with load.

humengying0907 commented 10 months ago

same problem

nebetbastet commented 9 months ago

Hello, I have the same problem. Did someone find a solution? Thanks !

strawberry098 commented 8 months ago

Is there a resolution?

ddiez commented 8 months ago

A solution was submitted with this https://github.com/satijalab/seurat-object/pull/182 PR to SeuratObject. Not sure when will be merged and the fix available. We will have to wait.

g-pinel commented 8 months ago

Until the bug is fixed, you can download the v4.4 package from this repository releases page and install it from file in R, then run UpdateSeuratObject() and then update back to v5. I can confirm this worked for me with Tabula Muris data.

strawberry098 commented 7 months ago

@g-pinel Can you provide the link to where the Seurat v4.4 package can be downloaded? I tried downloading via the below code, but have tons of issues regarding dependencies.

remotes::install_version("SeuratObject", "4.1.4", repos = c("https://satijalab.r-universe.dev", getOption("repos"))) remotes::install_version("Seurat", "4.4.0", repos = c("https://satijalab.r-universe.dev", getOption("repos")))

g-pinel commented 7 months ago

@g-pinel Can you provide the link to where the Seurat v4.4 package can be downloaded? I tried downloading via the below code, but have tons of issues regarding dependencies.

remotes::install_version("SeuratObject", "4.1.4", repos = c("https://satijalab.r-universe.dev", getOption("repos"))) remotes::install_version("Seurat", "4.4.0", repos = c("https://satijalab.r-universe.dev", getOption("repos")))

Here it is: https://github.com/satijalab/seurat/releases/tag/v4.4.0 Go to the "packages" tab in the bottom right area of the RStudio interface and then install from the local .tar.gz or .zip file that you downloaded

strawberry098 commented 7 months ago

Thanks for the prompt reply. However, I'm still getting dependencies errors:

ERROR: dependencies ‘igraph’, ‘leiden’, ‘miniUI’, ‘reticulate’, ‘sctransform’, ‘shiny’, ‘spatstat.explore’, ‘spatstat.geom’, ‘uwot’ are not available for package ‘Seurat’

UPDATE: I confirm that the install works in RStudio.

dlabuz commented 7 months ago

I still can't get UpdateSeuratObject to work even after installing seurat v4.4 and seuratobject v4.1.4.

Tried Seurat v3.0.2 as well and get the error:

> Vkas <- UpdateSeuratObject("Vkas")
Error: We are unable to convert Seurat objects less than version 2.X to version 3.X
Please use devtools::install_version to install Seurat v2.3.4 and update your object to a 2.X object
> Vkas@version
[1] ‘2.3.4’
> class(Vkas)
[1] "seurat"
attr(,"package")
[1] "Seurat"
> 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=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Denver
tzcode source: system (glibc)

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

other attached packages:
[1] Seurat_3.0.2

loaded via a namespace (and not attached):
  [1] tidyselect_1.2.1    viridisLite_0.4.2   dplyr_1.1.4         R.utils_2.12.3      fastmap_1.1.1       lazyeval_0.2.2     
  [7] TH.data_1.1-2       RANN_2.6.1          mathjaxr_1.6-0      rsvd_1.0.5          digest_0.6.35       lifecycle_1.0.4    
 [13] cluster_2.1.4       survival_3.5-8      ROCR_1.0-11         magrittr_2.0.3      compiler_4.3.1      rlang_1.1.3        
 [19] tools_4.3.1         igraph_2.0.3        plotrix_3.8-4       utf8_1.2.4          data.table_1.15.2   sn_2.1.1           
 [25] fitdistrplus_1.1-11 htmlwidgets_1.6.4   mnormt_2.1.1        reticulate_1.35.0   plyr_1.8.9          RColorBrewer_1.1-3 
 [31] multcomp_1.4-25     KernSmooth_2.23-22  Rtsne_0.17          purrr_1.0.2         numDeriv_2016.8-1.1 BiocGenerics_0.46.0
 [37] R.oo_1.26.0         grid_4.3.1          stats4_4.3.1        fansi_1.0.6         multtest_2.56.0     colorspace_2.1-0   
 [43] future_1.33.1       ggplot2_3.5.0       globals_0.16.3      scales_1.3.0        MASS_7.3-60         ggridges_0.5.6     
 [49] cli_3.6.2           mvtnorm_1.2-4       generics_0.1.3      sctransform_0.4.1   rstudioapi_0.15.0   ica_1.0-3          
 [55] future.apply_1.11.1 reshape2_1.4.4      httr_1.4.7          metap_1.9           pbapply_1.7-2       ape_5.7-1          
 [61] stringr_1.5.1       splines_4.3.1       parallel_4.3.1      matrixStats_1.2.0   vctrs_0.6.5         Matrix_1.6-5       
 [67] sandwich_3.1-0      jsonlite_1.8.8      ggrepel_0.9.5       irlba_2.3.5.1       listenv_0.9.1       plotly_4.10.4      
 [73] tidyr_1.3.1         glue_1.7.0          parallelly_1.37.1   codetools_0.2-19    cowplot_1.1.3       tsne_0.1-3.1       
 [79] stringi_1.8.3       gtable_0.3.4        lmtest_0.9-40       munsell_0.5.0       tibble_3.2.1        pillar_1.9.0       
 [85] htmltools_0.5.7     R6_2.5.1            Rdpack_2.6          lattice_0.21-8      Biobase_2.60.0      png_0.1-8          
 [91] rbibutils_2.2.16    R.methodsS3_1.8.2   qqconf_1.3.2        TFisher_0.2.0       mutoss_0.1-13       Rcpp_1.0.12        
 [97] gridExtra_2.3       nlme_3.1-164        SDMTools_1.1-221    zoo_1.8-12          pkgconfig_2.0.3    

Update: I was able to convert the seurat object using my macbook and then transferring it over to my workstation. I am still unsure what the difference is between the two machines as everything was identical as far as seurat is concerned.

kierap commented 6 months ago

Having this same problem with files from the dataset? would trying to add in whatever flag updateseuratobject is looking for break the dataset?

heimannch commented 6 months ago

I was facing this issue and noticed that the fix https://github.com/satijalab/seurat-object/pull/182 PR was merged to the develop branch https://github.com/satijalab/seurat-object/tree/develop. I installed this version and was able to run UpdateSeuratObject()

xdsgdsb commented 5 months ago

After numerous attempts, I finally succeeded. Even with Seurat version 5.0 and SeuratObject 5.0.1, UpdateSeuratObject didn't work. It was only with Seurat version 4.4.0 and SeuratObject 5.0.1 that it ran successfully.

DarioS commented 3 months ago

Same for me. I am trying to use a published data set GSE188737 and Seuat version 5.1.0.

UpdateSeuratObject(hnscc_seu)
Validating object structure
Updating object slots
    ...        ...
Validating object structure for Assay ‘RNA’
Validating object structure for Assay ‘integrated’
Error in validObject(object = object[[i]]) : 
  invalid class “Assay” object: 'scale.data' must have the same cells as 'data'
ddiez commented 3 months ago

@DarioS Note that your error is different from the one reported by the OP, which was fixed in the latest version of SeuratObject. Although I am not sure about the reason for this error, I could workaround it by doing:

> hnscc_seu@assays$integrated@scale.data <- matrix(ncol=0, nrow=0)
> hnscc_seu <- UpdateSeuratObject(hnscc_seu)
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Updating matrix keys for DimReduc ‘pca’
Updating matrix keys for DimReduc ‘umap’
Warning: Assay RNA changing from Assay to Assay
Warning: Assay integrated changing from Assay to Assay
Warning: DimReduc pca changing from DimReduc to DimReduc
Warning: DimReduc umap changing from DimReduc to DimReduc
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Updating slots in integrated
Updating slots in pca
Updating slots in umap
Setting umap DimReduc to global
No assay information could be found for FindIntegrationAnchors
No assay information could be found for IntegrateData
Setting assay used for ScaleData.integrated to integrated
Setting assay used for RunPCA.integrated to integrated
Setting assay used for JackStraw.integrated.pca to integrated
No assay information could be found for ScoreJackStraw
Setting assay used for FindNeighbors.integrated.pca to integrated
Setting assay used for RunUMAP.integrated.pca to integrated
No assay information could be found for FindClusters
Validating object structure for Assay ‘RNA’
Validating object structure for Assay ‘integrated’
Validating object structure for DimReduc ‘pca’
Validating object structure for DimReduc ‘umap’
Object representation is consistent with the most current Seurat version
An object of class Seurat
25148 features across 53459 samples within 2 assays
Active assay: RNA (23148 features, 0 variable features)
 2 layers present: counts, data
 1 other assay present: integrated
 2 dimensional reductions calculated: pca, umap
Warning messages:
1: Adding a command log without an assay associated with it
2: Adding a command log without an assay associated with it
3: Adding a command log without an assay associated with it
4: Adding a command log without an assay associated with it
> hnscc_seu
An object of class Seurat
25148 features across 53459 samples within 2 assays
Active assay: RNA (23148 features, 0 variable features)
 2 layers present: counts, data
 1 other assay present: integrated
 2 dimensional reductions calculated: pca, umap

which loses the information in scale.data for the integrated assay and might not be what you want.

igrabski commented 3 months ago

Hi, UpdateSeuratObject() should work with the current versions of Seurat, SeuratObject, and Matrix. If your issues persist or if you are having different problems, please feel free to open a new issue.

shaln commented 1 month ago

Hi @igrabski, I'm re-opening this issue as I've been having the same error as above with the current versions of Seurat v5.1.0, SeuratObject v5.0.2 and Matrix v1.6-5. The error persisted even after installing the development version of Seurat and SeuratObject. It was only after switching to Seurat v4.4.0 and SeuratObject v4.1.4 that I was able to successfully run the UpdateSeuratObject function without any errors.

> data <- UpdateSeuratObject(data)
Validating object structure
Updating object slots
Ensuring keys are in the proper structure
Updating matrix keys for DimReduc ‘pca’
Updating matrix keys for DimReduc ‘tsne’
Updating matrix keys for DimReduc ‘phate2d’
Updating matrix keys for DimReduc ‘phate3d’
Warning: Assay RNA changing from Assay to Assay
Warning: DimReduc pca changing from DimReduc to DimReduc
Warning: DimReduc tsne changing from DimReduc to DimReduc
Warning: DimReduc phate2d changing from DimReduc to DimReduc
Warning: DimReduc phate3d changing from DimReduc to DimReduc
Ensuring keys are in the proper structure
Ensuring feature names don't have underscores or pipes
Updating slots in RNA
Updating slots in pca
Updating slots in tsne
Setting tsne DimReduc to global
Updating slots in phate2d
Updating slots in phate3d
Validating object structure for Assay ‘RNA’
Validating object structure for DimReduc ‘pca’
**Error in validObject(object = object[[i]]) : 
  invalid class “DimReduc” object: 'global' must be a 1-length logical
In addition: Warning message:
Key ‘PHATE_’ taken, using ‘phate2d_’ instead** 
> sessionInfo()
R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default

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

time zone: Europe/London
tzcode source: internal

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

other attached packages:
 [1] CytoTRACE2_1.0.0       stringr_1.5.1          Rfast_2.1.0            RcppParallel_5.1.8     RcppZiggurat_0.1.6    
 [6] Rcpp_1.0.12            RANN_2.6.1             plyr_1.8.9             Matrix_1.6-5           magrittr_2.0.3        
[11] HiClimR_2.2.1          doParallel_1.0.17      iterators_1.0.14       foreach_1.5.2          data.table_1.15.4     
[16] Seurat_5.1.0           SeuratObject_5.0.2     sp_2.1-4               pheatmap_1.0.12        tidyr_1.3.1           
[21] reshape2_1.4.4         org.Hs.eg.db_3.18.0    AnnotationDbi_1.64.1   IRanges_2.36.0         S4Vectors_0.40.2      
[26] Biobase_2.62.0         BiocGenerics_0.48.1    clusterProfiler_4.10.0 ggplot2_3.5.1          dplyr_1.1.4           

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22        splines_4.3.3           later_1.3.2             bitops_1.0-8            ggplotify_0.1.2        
  [6] tibble_3.2.1            polyclip_1.10-7         fastDummies_1.7.4       lifecycle_1.0.4         globals_0.16.3         
 [11] lattice_0.22-5          MASS_7.3-60.0.1         plotly_4.10.4           rmarkdown_2.27          yaml_2.3.10            
 [16] httpuv_1.6.15           sctransform_0.4.1       spam_2.10-0             spatstat.sparse_3.1-0   reticulate_1.38.0      
 [21] cowplot_1.1.3           pbapply_1.7-2           DBI_1.2.3               RColorBrewer_1.1-3      abind_1.4-5            
 [26] zlibbioc_1.48.0         Rtsne_0.17              purrr_1.0.2             ggraph_2.2.1            RCurl_1.98-1.16        
 [31] yulab.utils_0.1.4       tweenr_2.0.3            GenomeInfoDbData_1.2.11 enrichplot_1.22.0       ggrepel_0.9.5          
 [36] irlba_2.3.5.1           spatstat.utils_3.0-5    listenv_0.9.1           tidytree_0.4.6          goftest_1.2-3          
 [41] RSpectra_0.16-2         spatstat.random_3.3-1   fitdistrplus_1.2-1      parallelly_1.38.0       ncdf4_1.22             
 [46] leiden_0.4.3.1          codetools_0.2-19        DOSE_3.28.2             ggforce_0.4.2           tidyselect_1.2.1       
 [51] aplot_0.2.3             farver_2.1.2            viridis_0.6.5           matrixStats_1.3.0       spatstat.explore_3.3-1 
 [56] jsonlite_1.8.8          tidygraph_1.3.1         progressr_0.14.0        ggridges_0.5.6          survival_3.5-8         
 [61] tools_4.3.3             treeio_1.26.0           ica_1.0-3               glue_1.7.0              gridExtra_2.3          
 [66] xfun_0.46               qvalue_2.34.0           GenomeInfoDb_1.38.8     withr_3.0.1             fastmap_1.2.0          
 [71] fansi_1.0.6             digest_0.6.34           R6_2.5.1                mime_0.12               gridGraphics_0.5-1     
 [76] colorspace_2.1-1        scattermore_1.2         GO.db_3.18.0            tensor_1.5              spatstat.data_3.1-2    
 [81] RSQLite_2.3.7           utf8_1.2.4              generics_0.1.3          graphlayouts_1.1.1      httr_1.4.7             
 [86] htmlwidgets_1.6.4       scatterpie_0.2.3        uwot_0.2.2              pkgconfig_2.0.3         gtable_0.3.5           
 [91] blob_1.2.4              lmtest_0.9-40           XVector_0.42.0          shadowtext_0.1.4        htmltools_0.5.8.1      
 [96] dotCall64_1.1-1         fgsea_1.28.0            scales_1.3.0            png_0.1-8               spatstat.univar_3.0-0  
[101] ggfun_0.1.5             knitr_1.48              rstudioapi_0.16.0       nlme_3.1-164            cachem_1.1.0           
[106] zoo_1.8-12              KernSmooth_2.23-22      miniUI_0.1.1.1          HDO.db_0.99.1           pillar_1.9.0           
[111] grid_4.3.3              vctrs_0.6.5             promises_1.3.0          xtable_1.8-4            cluster_2.1.6          
[116] evaluate_0.24.0         cli_3.6.2               compiler_4.3.3          rlang_1.1.3             crayon_1.5.3           
[121] future.apply_1.11.2     fs_1.6.4                stringi_1.8.4           deldir_2.0-4            viridisLite_0.4.2      
[126] BiocParallel_1.36.0     munsell_0.5.1           Biostrings_2.70.2       lazyeval_0.2.2          spatstat.geom_3.3-2    
[131] GOSemSim_2.28.1         RcppHNSW_0.6.0          patchwork_1.2.0         bit64_4.0.5             future_1.34.0          
[136] KEGGREST_1.42.0         shiny_1.9.1             ROCR_1.0-11             igraph_2.0.3            memoise_2.0.1          
[141] ggtree_3.10.1           fastmatch_1.1-4         bit_4.0.5               ape_5.8                 gson_0.1.0 
igrabski commented 1 month ago

Hi, I'm not able to replicate this error on some of my objects -- can you show more information about your data object? In particular, can you show how it was created, and can you show the output if you run data?

DarioS commented 1 month ago

Simply view GSE188737, download GSE188737_hnscc_seu.RData.gz at bottom of page and then try to update it.