satijalab / seurat

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

error updating v3 object to v5 object in seurat #7263

Closed afcmalone closed 1 year ago

afcmalone commented 1 year ago

I have a problem similar to 'Problem updating from old seurat object to newer version #5639'

I am trying to update my v3 seurat object to a v5 object. library(Seurat) #[v5] v5<-UpdateSeuratObject(biopsy.integrated) Validating object structure Updating object slots Ensuring keys are in the proper structure Warning: Assay RNA changing from Assay to Assay Warning: Assay integrated changing from Assay to Assay Warning: Graph integrated_nn changing from Graph to Graph Error: Cannot add graphs with unordered cells

Why am i getting this error? the original biopsy.integrated object was built with seurat V3.1.1

Thanks

yuhanH commented 1 year ago

hi @afcmalone

Could you double check if the graph has the cell names and the cell names have the same order with your object? for example,

Cells(pbmc_small@graphs$RNA_snn) == colnames(pbmc_small)
afcmalone commented 1 year ago

still getting an error

Cells(biopsy.integrated@graphs$RNA_snn) == colnames(biopsy.integrated) Error in slot(object = object, name = s) : no slot of name "images" for this object of class "Seurat"

on checking it looks like there is no 'RNA_snn' in graphs slot, only 'integrated_nn' or 'integrated_snn'

Might this be the issue?

sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Big Sur 11.3.1

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

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

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

other attached packages: [1] harmony_0.1.0 Rcpp_1.0.10
[3] stringr_1.5.0 patchwork_1.1.2
[5] dplyr_1.1.2 ggridges_0.5.4
[7] RColorBrewer_1.1-3 ggplot2_3.4.2
[9] Seurat_4.9.9.9042 SeuratObject_4.9.9.9084 [11] sp_1.6-0

loaded via a namespace (and not attached): [1] spam_2.9-1 plyr_1.8.8 igraph_1.4.2
[4] lazyeval_0.2.2 splines_4.1.2 RcppHNSW_0.4.1
[7] BiocParallel_1.28.3 listenv_0.9.0 scattermore_0.8
[10] usethis_2.1.5 digest_0.6.31 htmltools_0.5.5
[13] tiff_0.1-11 fansi_1.0.4 magrittr_2.0.3
[16] memoise_2.0.1 tensor_1.5 cluster_2.1.3
[19] ROCR_1.0-11 remotes_2.4.2 limma_3.50.3
[22] globals_0.16.2 matrixStats_0.63.0 R.utils_2.11.0
[25] spatstat.sparse_3.0-1 prettyunits_1.1.1 jpeg_0.1-9
[28] colorspace_2.1-0 signal_0.7-7 ggrepel_0.9.3
[31] crayon_1.5.2 callr_3.7.0 RCurl_1.98-1.6
[34] jsonlite_1.8.4 progressr_0.13.0 biglm_0.9-2.1
[37] spatstat.data_3.0-1 survival_3.3-1 zoo_1.8-12
[40] glue_1.6.2 polyclip_1.10-4 gtable_0.3.3
[43] leiden_0.4.3 pkgbuild_1.3.1 future.apply_1.10.0
[46] BiocGenerics_0.40.0 abind_1.4-5 scales_1.2.1
[49] pheatmap_1.0.12 DBI_1.1.2 spatstat.random_3.1-4 [52] miniUI_0.1.1.1 viridisLite_0.4.1 xtable_1.8-4
[55] reticulate_1.28 mclust_6.0.0 dotCall64_1.0-2
[58] stats4_4.1.2 htmlwidgets_1.6.2 httr_1.4.5
[61] ellipsis_0.3.2 ica_1.0-3 R.methodsS3_1.8.1
[64] pkgconfig_2.0.3 farver_2.1.1 uwot_0.1.14
[67] deldir_1.0-6 locfit_1.5-9.5 utf8_1.2.3
[70] tidyselect_1.2.0 labeling_0.4.2 rlang_1.1.1
[73] reshape2_1.4.4 later_1.3.0 munsell_0.5.0
[76] tools_4.1.2 cachem_1.0.8 cli_3.6.1
[79] generics_0.1.3 devtools_2.4.3 fastmap_1.1.1
[82] fftwtools_0.9-11 goftest_1.2-3 processx_3.5.3
[85] fs_1.6.2 fitdistrplus_1.1-11 purrr_1.0.1
[88] RANN_2.6.1 pbapply_1.7-0 future_1.32.0
[91] nlme_3.1-157 mime_0.12 R.oo_1.24.0
[94] ggrastr_1.0.1 brio_1.1.3 compiler_4.1.2
[97] rstudioapi_0.13 beeswarm_0.4.0 plotly_4.10.1
[100] png_0.1-8 testthat_3.1.3 spatstat.utils_3.0-2
[103] tibble_3.2.1 stringi_1.7.12 ps_1.7.0
[106] matter_1.20.0 desc_1.4.1 RSpectra_0.16-1
[109] lattice_0.20-45 ProtGenerics_1.26.0 Matrix_1.5-1
[112] vctrs_0.6.2 pillar_1.9.0 lifecycle_1.0.3
[115] spatstat.geom_3.1-0 lmtest_0.9-40 RcppAnnoy_0.0.20
[118] data.table_1.14.8 cowplot_1.1.1 bitops_1.0-7
[121] irlba_2.3.5.1 httpuv_1.6.9 R6_2.5.1
[124] promises_1.2.0.1 KernSmooth_2.23-20 gridExtra_2.3
[127] vipor_0.4.5 parallelly_1.35.0 sessioninfo_1.2.2
[130] codetools_0.2-18 Cardinal_2.12.0 pkgload_1.2.4
[133] fastDummies_1.6.3 MASS_7.3-57 rprojroot_2.0.3
[136] withr_2.5.0 presto_1.0.0 sctransform_0.3.5
[139] S4Vectors_0.32.4 parallel_4.1.2 EBImage_4.36.0
[142] grid_4.1.2 tidyr_1.3.0 Rtsne_0.16
[145] spatstat.explore_3.1-0 Biobase_2.54.0 shiny_1.7.4
[148] ggbeeswarm_0.7.1

yuhanH commented 1 year ago

em... could run object <- UpdateSlots(object = object) first?

afcmalone commented 1 year ago

still the same error:

biopsy.integrated <- UpdateSlots(object = biopsy.integrated) Cells(biopsy.integrated@graphs$RNA_snn) == colnames(biopsy.integrated) logical(0) v5<-UpdateSeuratObject(biopsy.integrated) Validating object structure Updating object slots Ensuring keys are in the proper structure Warning: Assay RNA changing from Assay to Assay Warning: Assay integrated changing from Assay to Assay Warning: Graph integrated_nn changing from Graph to Graph Error: Cannot add graphs with unordered cells

yuhanH commented 1 year ago

hi @afcmalone This line just need to check if the graph in your object has the same cells with the object. Cells(biopsy.integrated@graphs$RNA_snn) == colnames(biopsy.integrated) Please use the proper graph name to replace RNA_snn. for example

all( Cells(biopsy.integrated@graphs$integrated_snn) == colnames(biopsy.integrated))
all( Cells(biopsy.integrated@graphs$integrated_nn) == colnames(biopsy.integrated))
afcmalone commented 1 year ago

all( Cells(biopsy.integrated@graphs$integrated_snn) == colnames(biopsy.integrated)) [1] FALSE all( Cells(biopsy.integrated@graphs$integrated_nn) == colnames(biopsy.integrated)) [1] FALSE

yuhanH commented 1 year ago

hi @afcmalone It means that the cells in your graph is different from cells in the object. Two ways you can do to fix this updating bug.

  1. just delete these graph: biopsy.integrated[['integrated_nn']] <- NULL, biopsy.integrated[['integrated_snn']] <- NULL
  2. reorder the cells in the graph:
    pbmc_small[['RNA_snn']] <- as.Graph(pbmc_small[['RNA_snn']][colnames(pbmc_small), colnames(pbmc_small)])
saphir746 commented 7 months ago

This sequence worked for me to solve that problem in my dataset

`

Data <- UpdateSlots(object = Data)

colnames(Data)<-Cells(Data[['integrated_snn']])

all(Cells(Data@graphs$integrated_snn)==colnames(Data))
[1] TRUE

Data <- Seurat::UpdateSeuratObject(object = Data)

`