drieslab / Giotto

Spatial omics analysis toolbox
https://drieslab.github.io/Giotto_website/
Other
260 stars 98 forks source link

seuratToGiotto - conversion error #766

Open perineuronal opened 1 year ago

perineuronal commented 1 year ago

Hi there,

I'm currently working with Xenium data which I have processed and annotated in Seurat. I'd like to move to Giotto for further analyses and have been encountering issues using the seuratToGiotto() function and haven't been able to.

I am looking for help in managing to convert a seurat object to a giotto object. I have tried this with a single dataset seurat object and a seurat object containing multiple datasets (because this is what I ultimately would like to use for the analyses, so importing this would be most efficient).

Is there any help of advice available for this, please?

After importing my seurat object (one non-merged dataset), I've used:

seuratToGiotto(
  sobject = seur,
  spatial_assay = "Xenium",
  dim_reduction = c("pca", "umap"),
  subcellular_assay = "Xenium")

and I get the error:

Error in seuratToGiotto(sobject = seur, spatial_assay = "Xenium", dim_reduction = c("pca",  : 
  no slot of name "data" for this object of class "Assay5"

If I switch to using SCT assay, which is not Assay5, then I encounter the below error:

seuratToGiotto(
  sobject = seur,
  spatial_assay = "SCT",
  dim_reduction = c("pca", "umap"),
  subcellular_assay = "SCT")

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'rownames': recursive indexing failed at level 2

I have also tried this with a merged (multiple samples in one object) with the same issue, as this is ultimately the type of seurat object I would want to use.

Has anyone used this function with success, with either single or multi dataset objects? If so, could you tell me where I may be going wrong in my script?

Here are session details and seurat object structure details:

sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

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: America/Vancouver
tzcode source: internal

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

other attached packages:
 [1] lubridate_1.9.3         forcats_1.0.0           stringr_1.5.0           dplyr_1.1.2             purrr_1.0.1             readr_2.1.4            
 [7] tidyr_1.3.0             tibble_3.2.1            ggplot2_3.4.3           Matrix_1.5-4.1          Seurat_4.9.9.9058       Giotto_3.3.1           
[13] SeuratObject_4.9.9.9091 sp_2.0-0               

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-3   fs_1.6.2              
  [7] vctrs_0.6.3            ROCR_1.0-11            memoise_2.0.1          spatstat.explore_3.2-1 terra_1.7-46           htmltools_0.5.5       
 [13] usethis_2.2.2          sctransform_0.3.5      parallelly_1.36.0      KernSmooth_2.23-21     htmlwidgets_1.6.2      ica_1.0-3             
 [19] plyr_1.8.8             plotly_4.10.2          zoo_1.8-12             cachem_1.0.8           igraph_1.5.0           mime_0.12             
 [25] lifecycle_1.0.3        pkgconfig_2.0.3        R6_2.5.1               fastmap_1.1.1          fitdistrplus_1.1-11    future_1.33.0         
 [31] shiny_1.7.5            digest_0.6.33          colorspace_2.1-0       patchwork_1.1.3        ps_1.7.5               tensor_1.5            
 [37] RSpectra_0.16-1        irlba_2.3.5.1          pkgload_1.3.2.1        progressr_0.14.0       timechange_0.2.0       fansi_1.0.4           
 [43] spatstat.sparse_3.0-2  httr_1.4.7             polyclip_1.10-4        abind_1.4-5            compiler_4.3.1         remotes_2.4.2.1       
 [49] withr_2.5.1            fastDummies_1.7.3      pkgbuild_1.4.2         MASS_7.3-60            rappdirs_0.3.3         sessioninfo_1.2.2     
 [55] tools_4.3.1            lmtest_0.9-40          httpuv_1.6.11          future.apply_1.11.0    goftest_1.2-3          glue_1.6.2            
 [61] callr_3.7.3            nlme_3.1-162           promises_1.2.0.1       grid_4.3.1             Rtsne_0.16             cluster_2.1.4         
 [67] reshape2_1.4.4         generics_0.1.3         gtable_0.3.4           spatstat.data_3.0-1    tzdb_0.4.0             hms_1.1.3             
 [73] data.table_1.14.8      utf8_1.2.3             spatstat.geom_3.2-2    RcppAnnoy_0.0.21       ggrepel_0.9.3          RANN_2.6.1            
 [79] pillar_1.9.0           spam_2.9-1             RcppHNSW_0.4.1         later_1.3.1            splines_4.3.1          lattice_0.21-8        
 [85] survival_3.5-5         deldir_1.0-9           tidyselect_1.2.0       miniUI_0.1.1.1         pbapply_1.7-2          gridExtra_2.3         
 [91] scattermore_1.2        devtools_2.4.5         matrixStats_1.0.0      stringi_1.7.12         lazyeval_0.2.2         codetools_0.2-19      
 [97] cli_3.6.1              uwot_0.1.16            xtable_1.8-4           reticulate_1.30        munsell_0.5.0          processx_3.8.2        
[103] Rcpp_1.0.11            globals_0.16.2         spatstat.random_3.1-5  png_0.1-8              parallel_4.3.1         ellipsis_0.3.2        
[109] prettyunits_1.1.1      dotCall64_1.0-2        profvis_0.3.8          urlchecker_1.0.1       listenv_0.9.0          viridisLite_0.4.2     
[115] scales_1.2.1           ggridges_0.5.4         leiden_0.4.3           crayon_1.5.2           rlang_1.1.1            cowplot_1.1.1 
Formal class 'Seurat' [package "SeuratObject"] with 13 slots
  ..@ assays      :List of 5
  .. ..$ Xenium         :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. ..$ BlankCodeword  :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. ..$ ControlCodeword:Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. ..$ ControlProbe   :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. ..$ SCT            :Formal class 'SCTAssay' [package "Seurat"] with 9 slots
  ..@ meta.data   :'data.frame':    7039 obs. of  22 variables:
  .. ..$ orig.ident              : Factor w/ 1 level "SeuratProject": 1 1 1 1 1 1 1 1 1 1 ...
  .. ..$ nCount_Xenium           : num [1:7039] 145 209 347 242 218 235 273 198 270 233 ...
  .. ..$ nFeature_Xenium         : int [1:7039] 54 81 87 73 61 91 86 67 81 84 ...
  .. ..$ nCount_BlankCodeword    : num [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_BlankCodeword  : int [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nCount_ControlCodeword  : num [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_ControlCodeword: int [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nCount_ControlProbe     : num [1:7039] 1 0 1 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_ControlProbe   : int [1:7039] 1 0 1 0 0 0 0 0 0 0 ...
  .. ..$ nCount_SCT              : num [1:7039] 216 216 250 238 223 235 246 216 249 233 ...
  .. ..$ nFeature_SCT            : int [1:7039] 54 81 87 73 61 91 86 67 81 84 ...
  .. ..$ SCT_snn_res.0.4         : Factor w/ 14 levels "0","1","2","3",..: 6 6 1 6 1 6 6 1 6 6 ...
  .. ..$ SCT_snn_res.0.8         : Factor w/ 19 levels "0","1","2","3",..: 13 13 1 13 1 13 13 1 13 13 ...
  .. ..$ SCT_snn_res.1.2         : Factor w/ 23 levels "0","1","2","3",..: 15 15 1 15 1 15 15 7 15 15 ...
  .. ..$ SCT_snn_res.1.6         : Factor w/ 25 levels "0","1","2","3",..: 16 16 8 16 19 16 16 6 16 16 ...
  .. ..$ SCT_snn_res.2           : Factor w/ 30 levels "0","1","2","3",..: 23 23 5 23 19 23 23 19 23 23 ...
  .. ..$ SCT_snn_res.2.4         : Factor w/ 31 levels "0","1","2","3",..: 24 24 4 24 22 24 24 3 24 24 ...
  .. ..$ SCT_snn_res.2.8         : Factor w/ 35 levels "0","1","2","3",..: 24 24 3 24 21 24 24 16 24 24 ...
  .. ..$ SCT_snn_res.3.2         : Factor w/ 36 levels "0","1","2","3",..: 13 13 3 13 17 13 13 14 13 13 ...
  .. ..$ SCT_snn_res.3.6         : Factor w/ 38 levels "0","1","2","3",..: 23 23 3 23 19 23 23 19 23 23 ...
  .. ..$ SCT_snn_res.4           : Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  .. ..$ seurat_clusters         : Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  ..@ active.assay: chr "SCT"
  ..@ active.ident: Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  .. ..- attr(*, "names")= chr [1:7039] "aapbbpmh-1" "aapbgbhg-1" "aapclgnh-1" "aapdijdc-1" ...
  ..@ graphs      :List of 2
  .. ..$ SCT_nn :Formal class 'Graph' [package "SeuratObject"] with 7 slots
  .. ..$ SCT_snn:Formal class 'Graph' [package "SeuratObject"] with 7 slots
  ..@ neighbors   : list()
  ..@ reductions  :List of 2
  .. ..$ pca :Formal class 'DimReduc' [package "SeuratObject"] with 9 slots
  .. ..$ umap:Formal class 'DimReduc' [package "SeuratObject"] with 9 slots
  ..@ images      :List of 1
  .. ..$ fov:Formal class 'FOV' [package "SeuratObject"] with 4 slots
  ..@ project.name: chr "SeuratProject"
  ..@ misc        : list()
  ..@ version     :Classes 'package_version', 'numeric_version'  hidden list of 1
  .. ..$ : int [1:4] 4 9 9 9091
  ..@ commands    :List of 5
  .. ..$ SCTransform.Xenium   :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. ..$ RunPCA.SCT           :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. ..$ RunUMAP.SCT.pca      :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. ..$ FindNeighbors.SCT.pca:Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. ..$ FindClusters         :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  ..@ tools       : list()
> str(seur, max.level = 4)
Formal class 'Seurat' [package "SeuratObject"] with 13 slots
  ..@ assays      :List of 5
  .. ..$ Xenium         :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. ..$ BlankCodeword  :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. ..$ ControlCodeword:Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. ..$ ControlProbe   :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. ..$ SCT            :Formal class 'SCTAssay' [package "Seurat"] with 9 slots
  ..@ meta.data   :'data.frame':    7039 obs. of  22 variables:
  .. ..$ orig.ident              : Factor w/ 1 level "SeuratProject": 1 1 1 1 1 1 1 1 1 1 ...
  .. ..$ nCount_Xenium           : num [1:7039] 145 209 347 242 218 235 273 198 270 233 ...
  .. ..$ nFeature_Xenium         : int [1:7039] 54 81 87 73 61 91 86 67 81 84 ...
  .. ..$ nCount_BlankCodeword    : num [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_BlankCodeword  : int [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nCount_ControlCodeword  : num [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_ControlCodeword: int [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nCount_ControlProbe     : num [1:7039] 1 0 1 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_ControlProbe   : int [1:7039] 1 0 1 0 0 0 0 0 0 0 ...
  .. ..$ nCount_SCT              : num [1:7039] 216 216 250 238 223 235 246 216 249 233 ...
  .. ..$ nFeature_SCT            : int [1:7039] 54 81 87 73 61 91 86 67 81 84 ...
  .. ..$ SCT_snn_res.0.4         : Factor w/ 14 levels "0","1","2","3",..: 6 6 1 6 1 6 6 1 6 6 ...
  .. ..$ SCT_snn_res.0.8         : Factor w/ 19 levels "0","1","2","3",..: 13 13 1 13 1 13 13 1 13 13 ...
  .. ..$ SCT_snn_res.1.2         : Factor w/ 23 levels "0","1","2","3",..: 15 15 1 15 1 15 15 7 15 15 ...
  .. ..$ SCT_snn_res.1.6         : Factor w/ 25 levels "0","1","2","3",..: 16 16 8 16 19 16 16 6 16 16 ...
  .. ..$ SCT_snn_res.2           : Factor w/ 30 levels "0","1","2","3",..: 23 23 5 23 19 23 23 19 23 23 ...
  .. ..$ SCT_snn_res.2.4         : Factor w/ 31 levels "0","1","2","3",..: 24 24 4 24 22 24 24 3 24 24 ...
  .. ..$ SCT_snn_res.2.8         : Factor w/ 35 levels "0","1","2","3",..: 24 24 3 24 21 24 24 16 24 24 ...
  .. ..$ SCT_snn_res.3.2         : Factor w/ 36 levels "0","1","2","3",..: 13 13 3 13 17 13 13 14 13 13 ...
  .. ..$ SCT_snn_res.3.6         : Factor w/ 38 levels "0","1","2","3",..: 23 23 3 23 19 23 23 19 23 23 ...
  .. ..$ SCT_snn_res.4           : Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  .. ..$ seurat_clusters         : Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  ..@ active.assay: chr "SCT"
  ..@ active.ident: Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  .. ..- attr(*, "names")= chr [1:7039] "aapbbpmh-1" "aapbgbhg-1" "aapclgnh-1" "aapdijdc-1" ...
  ..@ graphs      :List of 2
  .. ..$ SCT_nn :Formal class 'Graph' [package "SeuratObject"] with 7 slots
  .. ..$ SCT_snn:Formal class 'Graph' [package "SeuratObject"] with 7 slots
  ..@ neighbors   : list()
  ..@ reductions  :List of 2
  .. ..$ pca :Formal class 'DimReduc' [package "SeuratObject"] with 9 slots
  .. ..$ umap:Formal class 'DimReduc' [package "SeuratObject"] with 9 slots
  ..@ images      :List of 1
  .. ..$ fov:Formal class 'FOV' [package "SeuratObject"] with 4 slots
  ..@ project.name: chr "SeuratProject"
  ..@ misc        : list()
  ..@ version     :Classes 'package_version', 'numeric_version'  hidden list of 1
  .. ..$ : int [1:4] 4 9 9 9091
  ..@ commands    :List of 5
  .. ..$ SCTransform.Xenium   :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. ..$ RunPCA.SCT           :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. ..$ RunUMAP.SCT.pca      :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. ..$ FindNeighbors.SCT.pca:Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. ..$ FindClusters         :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  ..@ tools       : list()
> str(seur, max.level = 5)
Formal class 'Seurat' [package "SeuratObject"] with 13 slots
  ..@ assays      :List of 5
  .. ..$ Xenium         :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. .. .. ..@ counts       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ data         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ scale.data   : num[0 , 0 ] 
  .. .. .. ..@ assay.orig   : chr(0) 
  .. .. .. ..@ var.features : chr(0) 
  .. .. .. ..@ meta.features:'data.frame':  348 obs. of  0 variables
  .. .. .. ..@ misc         : Named list()
  .. .. .. ..@ key          : chr "xenium_"
  .. ..$ BlankCodeword  :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. .. .. ..@ counts       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ data         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ scale.data   : num[0 , 0 ] 
  .. .. .. ..@ assay.orig   : NULL
  .. .. .. ..@ var.features : chr(0) 
  .. .. .. ..@ meta.features:'data.frame':  125 obs. of  0 variables
  .. .. .. ..@ misc         : Named list()
  .. .. .. ..@ key          : chr "blankcodeword_"
  .. ..$ ControlCodeword:Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. .. .. ..@ counts       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ data         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ scale.data   : num[0 , 0 ] 
  .. .. .. ..@ assay.orig   : NULL
  .. .. .. ..@ var.features : chr(0) 
  .. .. .. ..@ meta.features:'data.frame':  41 obs. of  0 variables
  .. .. .. ..@ misc         : Named list()
  .. .. .. ..@ key          : chr "controlcodeword_"
  .. ..$ ControlProbe   :Formal class 'Assay' [package "SeuratObject"] with 8 slots
  .. .. .. ..@ counts       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ data         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ scale.data   : num[0 , 0 ] 
  .. .. .. ..@ assay.orig   : NULL
  .. .. .. ..@ var.features : chr(0) 
  .. .. .. ..@ meta.features:'data.frame':  27 obs. of  0 variables
  .. .. .. ..@ misc         : Named list()
  .. .. .. ..@ key          : chr "controlprobe_"
  .. ..$ SCT            :Formal class 'SCTAssay' [package "Seurat"] with 9 slots
  .. .. .. ..@ SCTModel.list:List of 1
  .. .. .. ..@ counts       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ data         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. ..@ scale.data   : num [1:348, 1:7039] -0.8376 -0.2123 -0.0114 2.1161 -0.4082 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..@ assay.orig   : chr "Xenium"
  .. .. .. ..@ var.features : chr [1:348] "Mbp" "Foxj1" "Mog" "Ly6a" ...
  .. .. .. ..@ meta.features:'data.frame':  348 obs. of  0 variables
  .. .. .. ..@ misc         : Named list()
  .. .. .. ..@ key          : chr "sct_"
  ..@ meta.data   :'data.frame':    7039 obs. of  22 variables:
  .. ..$ orig.ident              : Factor w/ 1 level "SeuratProject": 1 1 1 1 1 1 1 1 1 1 ...
  .. ..$ nCount_Xenium           : num [1:7039] 145 209 347 242 218 235 273 198 270 233 ...
  .. ..$ nFeature_Xenium         : int [1:7039] 54 81 87 73 61 91 86 67 81 84 ...
  .. ..$ nCount_BlankCodeword    : num [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_BlankCodeword  : int [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nCount_ControlCodeword  : num [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_ControlCodeword: int [1:7039] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ nCount_ControlProbe     : num [1:7039] 1 0 1 0 0 0 0 0 0 0 ...
  .. ..$ nFeature_ControlProbe   : int [1:7039] 1 0 1 0 0 0 0 0 0 0 ...
  .. ..$ nCount_SCT              : num [1:7039] 216 216 250 238 223 235 246 216 249 233 ...
  .. ..$ nFeature_SCT            : int [1:7039] 54 81 87 73 61 91 86 67 81 84 ...
  .. ..$ SCT_snn_res.0.4         : Factor w/ 14 levels "0","1","2","3",..: 6 6 1 6 1 6 6 1 6 6 ...
  .. ..$ SCT_snn_res.0.8         : Factor w/ 19 levels "0","1","2","3",..: 13 13 1 13 1 13 13 1 13 13 ...
  .. ..$ SCT_snn_res.1.2         : Factor w/ 23 levels "0","1","2","3",..: 15 15 1 15 1 15 15 7 15 15 ...
  .. ..$ SCT_snn_res.1.6         : Factor w/ 25 levels "0","1","2","3",..: 16 16 8 16 19 16 16 6 16 16 ...
  .. ..$ SCT_snn_res.2           : Factor w/ 30 levels "0","1","2","3",..: 23 23 5 23 19 23 23 19 23 23 ...
  .. ..$ SCT_snn_res.2.4         : Factor w/ 31 levels "0","1","2","3",..: 24 24 4 24 22 24 24 3 24 24 ...
  .. ..$ SCT_snn_res.2.8         : Factor w/ 35 levels "0","1","2","3",..: 24 24 3 24 21 24 24 16 24 24 ...
  .. ..$ SCT_snn_res.3.2         : Factor w/ 36 levels "0","1","2","3",..: 13 13 3 13 17 13 13 14 13 13 ...
  .. ..$ SCT_snn_res.3.6         : Factor w/ 38 levels "0","1","2","3",..: 23 23 3 23 19 23 23 19 23 23 ...
  .. ..$ SCT_snn_res.4           : Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  .. ..$ seurat_clusters         : Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  ..@ active.assay: chr "SCT"
  ..@ active.ident: Factor w/ 41 levels "0","1","2","3",..: 33 28 3 28 40 28 33 13 28 28 ...
  .. ..- attr(*, "names")= chr [1:7039] "aapbbpmh-1" "aapbgbhg-1" "aapclgnh-1" "aapdijdc-1" ...
  ..@ graphs      :List of 2
  .. ..$ SCT_nn :Formal class 'Graph' [package "SeuratObject"] with 7 slots
  .. .. .. ..@ assay.used: chr "SCT"
  .. .. .. ..@ i         : int [1:140780] 0 6 18 406 502 506 511 531 535 549 ...
  .. .. .. ..@ p         : int [1:7040] 0 26 42 70 85 96 118 136 137 150 ...
  .. .. .. ..@ Dim       : int [1:2] 7039 7039
  .. .. .. ..@ Dimnames  :List of 2
  .. .. .. ..@ x         : num [1:140780] 1 1 1 1 1 1 1 1 1 1 ...
  .. .. .. ..@ factors   : list()
  .. ..$ SCT_snn:Formal class 'Graph' [package "SeuratObject"] with 7 slots
  .. .. .. ..@ assay.used: chr "SCT"
  .. .. .. ..@ i         : int [1:537291] 0 6 18 406 410 502 506 511 512 526 ...
  .. .. .. ..@ p         : int [1:7040] 0 42 109 200 243 295 343 381 429 479 ...
  .. .. .. ..@ Dim       : int [1:2] 7039 7039
  .. .. .. ..@ Dimnames  :List of 2
  .. .. .. ..@ x         : num [1:537291] 1 0.739 0.333 0.111 0.212 ...
  .. .. .. ..@ factors   : list()
  ..@ neighbors   : list()
  ..@ reductions  :List of 2
  .. ..$ pca :Formal class 'DimReduc' [package "SeuratObject"] with 9 slots
  .. .. .. ..@ cell.embeddings           : num [1:7039, 1:50] 0.737 -0.595 -12.807 2.997 -13.668 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..@ feature.loadings          : num [1:348, 1:50] 0.079206 0.010581 -0.000406 0.008536 0.011842 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..@ feature.loadings.projected: num[0 , 0 ] 
  .. .. .. ..@ assay.used                : chr "SCT"
  .. .. .. ..@ global                    : logi FALSE
  .. .. .. ..@ stdev                     : num [1:50] 7.16 5.97 5.26 4.62 4.4 ...
  .. .. .. ..@ jackstraw                 :Formal class 'JackStrawData' [package "SeuratObject"] with 4 slots
  .. .. .. ..@ misc                      :List of 1
  .. .. .. ..@ key                       : chr "PC_"
  .. ..$ umap:Formal class 'DimReduc' [package "SeuratObject"] with 9 slots
  .. .. .. ..@ cell.embeddings           : num [1:7039, 1:2] 4.36 5.09 7.48 5.16 8.56 ...
  .. .. .. .. ..- attr(*, "scaled:center")= num [1:2] -0.322 -0.749
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..@ feature.loadings          : num[0 , 0 ] 
  .. .. .. ..@ feature.loadings.projected: num[0 , 0 ] 
  .. .. .. ..@ assay.used                : chr "SCT"
  .. .. .. ..@ global                    : logi TRUE
  .. .. .. ..@ stdev                     : num(0) 
  .. .. .. ..@ jackstraw                 :Formal class 'JackStrawData' [package "SeuratObject"] with 4 slots
  .. .. .. ..@ misc                      : list()
  .. .. .. ..@ key                       : chr "umap_"
  ..@ images      :List of 1
  .. ..$ fov:Formal class 'FOV' [package "SeuratObject"] with 4 slots
  .. .. .. ..@ molecules :List of 1
  .. .. .. ..@ boundaries:List of 2
  .. .. .. ..@ assay     : chr "Xenium"
  .. .. .. ..@ key       : chr "Xenium_"
  ..@ project.name: chr "SeuratProject"
  ..@ misc        : list()
  ..@ version     :Classes 'package_version', 'numeric_version'  hidden list of 1
  .. ..$ : int [1:4] 4 9 9 9091
  ..@ commands    :List of 5
  .. ..$ SCTransform.Xenium   :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "SCTransform.Xenium"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2023-08-24 19:54:54"
  .. .. .. ..@ assay.used : chr "Xenium"
  .. .. .. ..@ call.string: chr "SCTransform(xenium.sub, assay = \"Xenium\")"
  .. .. .. ..@ params     :List of 14
  .. ..$ RunPCA.SCT           :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "RunPCA.SCT"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2023-08-24 19:55:06"
  .. .. .. ..@ assay.used : chr "SCT"
  .. .. .. ..@ call.string: chr "RunPCA(xenium.sub, npcs = 50, features = rownames(xenium.sub))"
  .. .. .. ..@ params     :List of 11
  .. ..$ RunUMAP.SCT.pca      :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "RunUMAP.SCT.pca"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2023-08-24 19:56:45"
  .. .. .. ..@ assay.used : chr "SCT"
  .. .. .. ..@ call.string: chr "RunUMAP(xenium.sub, dims = 1:33)"
  .. .. .. ..@ params     :List of 25
  .. ..$ FindNeighbors.SCT.pca:Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "FindNeighbors.SCT.pca"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2023-08-24 19:56:48"
  .. .. .. ..@ assay.used : chr "SCT"
  .. .. .. ..@ call.string: chr "FindNeighbors(xenium.sub, reduction = \"pca\", dims = 1:33)"
  .. .. .. ..@ params     :List of 16
  .. ..$ FindClusters         :Formal class 'SeuratCommand' [package "SeuratObject"] with 5 slots
  .. .. .. ..@ name       : chr "FindClusters"
  .. .. .. ..@ time.stamp : POSIXct[1:1], format: "2023-08-24 19:56:59"
  .. .. .. ..@ assay.used : chr "SCT"
  .. .. .. ..@ call.string: chr [1:2] "FindClusters(xenium.sub, resolution = c(0.4, 0.8, 1.2, " "    1.6, 2, 2.4, 2.8, 3.2, 3.6, 4))"
  .. .. .. ..@ params     :List of 11
  ..@ tools       : list()
RubD commented 1 year ago

Hi @perineuronal we're working on the giotto and seurat incompatibility issue and we hope to resolve this in the next days/week(s).

perineuronal commented 1 year ago

Hi @RubD - thank you so much for such a prompt response, this is great to know! Giotto is such a useful package so I look forward to moving forward with the analyses when the incompatibility issue is fixed - I will keep my eyes peeled.

RubD commented 1 year ago

@iqraAmin do you think the Giotto <-> Seurat converters work again?

perineuronal commented 12 months ago

Hey @RubD and @iqraAmin - thanks for following up with this! I just thought I'd update to say that I tried out the seur -> giotto converter again and still had errors. Perhaps I am doing something wrong, but I tried converting using the "Xenium" assay and produced the below error:

I'm on v3.3.1 of Giotto now. Thanks for all of the help!

> seuratToGiotto(
+   seur_xen,
+   spatial_assay = "Xenium",
+   dim_reduction = c("pca", "umap"),
+   subcellular_assay = "Xenium"
+ )
Error in `GetAssayData()`:
! GetAssayData doesn't work for multiple layers in v5 assay.
Run `rlang::last_trace()` to see where the error occurred.

And then tried using the "integrated" assay, since the dataset is merged and drew the following error:


> seuratToGiotto( seur_xen,
   spatial_assay = "integrated", 
  dim_reduction = c("pca", "umap"), 
 subcellular_assay = "integrated" ) 

Error in exp[, c(intersect(spat_coord$cell_ID, colnames(exp)))] :    
invalid or not-yet-implemented 'Matrix' subsetting
--

 ```
hchoiHiLung commented 8 months ago

I also encountered issues on Xenium Seurat to Giotto conversion. I am now using Seurat v5 and Giotto v4.0.2. I did not get an error and got a Giotto object but as I am converting a Xenium Seurat objects with 5 fovs, representing 5 different tissue sections, the seuratToGiottoV5 function seems to only convert the first tissue section and the resulting Giotto object only contains cells from the first section/fov.

This is the code and message I got.


> int.giotto<-seuratToGiottoV5(int.smallSeurat,spatial_assay = "Xenium",dim_reduction = c("RPCAint","RPCAintPaCMAP"),subcellular_assay = "Xenium")

Selecting col "molecule" as feat_ID column
  Selecting cols "x" and "y" as x and y respectively
  Selecting col "molecule" as feat_ID column
  Selecting cols "x" and "y" as x and y respectively
  Selecting col "molecule" as feat_ID column
  Selecting cols "x" and "y" as x and y respectively
  Selecting col "molecule" as feat_ID column
  Selecting cols "x" and "y" as x and y respectively
  Selecting col "molecule" as feat_ID column
  Selecting cols "x" and "y" as x and y respectively

no external python path was provided, but a giotto python environment was found
 and will be used
Consider to install these (optional) packages to run all possible Giotto
 commands for spatial analyses: scran tiff trendsceek multinet RTriangle
 FactoMineR
Giotto does not automatically install all these packages as they are not
 absolutely required and this reduces the number of dependencies
Warning messages:
1: In .check_giotto_python_modules(my_python_path = instructions(.Object,  :
  module: leidenalg was not found with python path: C:/Users/~/AppData/Local/r-miniconda\envs\giotto_env\python.exe

2: In FUN(X[[i]], ...) : 
List item [1]: Not possible to read dimObj.
 Returning without modifications
3: In FUN(X[[i]], ...) : 
List item [2]: Not possible to read dimObj.
 Returning without modifications
4: In .check_giotto_python_modules(my_python_path = instructions(.Object,  :
  module: leidenalg was not found with python path: C:/Users/~/AppData/Local/r-miniconda\envs\giotto_env\python.exe

5: In FUN(X[[i]], ...) :
  data_type: cells spat_unit: cell feat_type: rna dim_type: RPCAint name: RPCAint
 Dimension reduction coord names are not all found in gobject IDs
6: In FUN(X[[i]], ...) :
  data_type: cells spat_unit: cell feat_type: rna dim_type: RPCAintPaCMAP name:
 RPCAintPaCMAP
 Dimension reduction coord names are not all found in gobject IDs
7: In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names,  :
  Item 1 has 146 rows but longest item has 2200; recycled with remainder.
8: In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names,  :
  Item 1 has 302 rows but longest item has 2200; recycled with remainder.

The seuratToGiottoV5 function also seems to be very memory-consuming. My 32-core 256 GB RAM 1 GB GPU computer crashed when I tried converting the Xenium Seurat object containing 500k cells. When I downsampled it to a few thousand cells, it ran.

Is there any workaround for this? Although the Xenium Seurat object contains all the dimension reductions like PaCMAP and RPCA integration which are not available/compatible with Giotto, I am considering loading and creating a Giotto object from scratch manually because it seems to me the spatial / neighborhood analyses don't absolutely need those dimension reductions. I can see there is an example showing how to merge datasets of different Visium sections together but just as a suggestion (probably low priority), a vignette on merging Xenium data of different sections is also appreciated.

mvereten commented 8 months ago

Are there any news on seuratToGiotto()? I have just tried it, and I get the same error referring to recursive indexing. Would be fab to have this up and running!

cjhong commented 7 months ago

The problem seems related to "feat_metadata <- subject[[]]".