drieslab / Giotto

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

Transformation between Seurat and Giotto object #224

Open howtofindme opened 2 years ago

howtofindme commented 2 years ago

dear RubD,

Thank you for your excellent job! I Have a visium Seurat object. How can I Transform it to Giotto visum object in a quickly way ?

hoping to hear from you , best wishes

szheng29 commented 2 years ago

Hi,

We have a function called seuratToGiotto() in the suite branch, which enables transforming a Seurat object to Giotto.

joe-jhou2 commented 2 years ago

Hi when I use seuratToGiotto() for seurat object, it returns an error "in seuratToGiotto(se.subset) : object 'test' not found". No clue what it is. Can you provide some insights? Thanks

EmmaKelley commented 2 years ago

Hi,

Which version of suite are you using? You may have to update if you are not using the current version, 2.0.0.998.

If that does not work could you provide the a screen shot with what happens when you run seuratToGiotto?

joe-jhou2 commented 2 years ago

It's the latest version

sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Big Sur 10.16

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.0/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.8.3 STutility_0.1.0 ggplot2_3.3.6 SeuratObject_4.0.4 Seurat_4.1.0 NNLM_0.4.4
[8] Giotto_2.0.0.998

loaded via a namespace (and not attached): [1] utf8_1.2.2 reticulate_1.24 tidyselect_1.1.2 htmlwidgets_1.5.4 BiocParallel_1.24.1 grid_4.0.3
[7] Rtsne_0.16 munsell_0.5.0 codetools_0.2-18 ica_1.0-2 units_0.8-0 future_1.25.0
[13] miniUI_0.1.1.1 withr_2.5.0 spatstat.random_2.2-0 colorspace_2.0-3 knitr_1.39 uuid_1.1-0
[19] stats4_4.0.3 ROCR_1.0-11 wk_0.6.0 tensor_1.5 Rttf2pt1_1.3.10 listenv_0.8.0
[25] MatrixGenerics_1.2.1 labeling_0.4.2 polyclip_1.10-0 bit64_4.0.5 farver_2.1.0 pheatmap_1.0.12
[31] rprojroot_2.0.3 parallelly_1.31.1 vctrs_0.4.1 generics_0.1.2 xfun_0.30 R6_2.5.1
[37] doParallel_1.0.17 rsvd_1.0.5 Morpho_2.9 hdf5r_1.3.5 ggiraph_0.8.2 RcppZiggurat_0.1.6
[43] DelayedArray_0.16.3 spatstat.utils_2.3-0 assertthat_0.2.1 promises_1.2.0.1 scales_1.2.0 imager_0.42.13
[49] gtable_0.3.0 beachmat_2.6.4 globals_0.15.0 bmp_0.3 goftest_1.2-3 rlang_1.0.2
[55] zeallot_0.1.0 akima_0.6-3.4 systemfonts_1.0.4 splines_4.0.3 extrafontdb_1.0 lazyeval_0.2.2
[61] spatstat.geom_2.4-0 s2_1.0.7 rgl_0.108.3 reshape2_1.4.4 abind_1.4-5 Rfast_2.0.6
[67] httpuv_1.6.5 extrafont_0.18 tools_4.0.3 spData_2.0.1 ellipsis_0.3.2 spatstat.core_2.4-2
[73] raster_3.5-15 RColorBrewer_1.1-3 BiocGenerics_0.36.1 proxy_0.4-26 Rvcg_0.21 ggridges_0.5.3
[79] plyr_1.8.7 classInt_0.4-3 purrr_0.3.4 rpart_4.1.16 dbscan_1.1-10 deldir_1.0-6
[85] pbapply_1.5-0 viridis_0.6.2 cowplot_1.1.1 S4Vectors_0.28.1 zoo_1.8-10 ggrepel_0.9.1
[91] cluster_2.1.3 colorRamps_2.3.1 here_1.0.1 tinytex_0.38 magrittr_2.0.3 RSpectra_0.16-1
[97] data.table_1.14.2 magick_2.7.3 scattermore_0.8 readbitmap_0.1.5 lmtest_0.9-40 RANN_2.6.1
[103] fitdistrplus_1.1-8 matrixStats_0.62.0 patchwork_1.1.1 shinyjs_2.1.0 mime_0.12 xtable_1.8-4
[109] jpeg_0.1-9 IRanges_2.24.1 gridExtra_2.3 compiler_4.0.3 tibble_3.1.7 KernSmooth_2.23-20
[115] crayon_1.5.1 htmltools_0.5.2 mgcv_1.8-40 later_1.3.0 spdep_1.2-4 tiff_0.1-11
[121] tidyr_1.2.0 DBI_1.1.2 MASS_7.3-57 sf_1.0-7 boot_1.3-28 Matrix_1.4-1
[127] cli_3.3.0 quadprog_1.5-8 parallel_4.0.3 igraph_1.3.1 pkgconfig_2.0.3 sp_1.4-7
[133] terra_1.5-21 plotly_4.10.0 spatstat.sparse_2.1-1 foreach_1.5.2 stringr_1.4.0 bezier_1.1.2
[139] digest_0.6.29 sctransform_0.3.3 RcppAnnoy_0.0.19 spatstat.data_2.2-0 leiden_0.3.10 uwot_0.1.11
[145] shiny_1.7.1 lifecycle_1.0.1 nlme_3.1-157 jsonlite_1.8.0 viridisLite_0.4.0 fansi_1.0.3
[151] pillar_1.7.0 lattice_0.20-45 fastmap_1.1.0 httr_1.4.3 survival_3.3-1 glue_1.6.2
[157] remotes_2.4.2 FNN_1.1.3 png_0.1-7 iterators_1.0.14 bit_4.0.4 class_7.3-20
[163] stringi_1.7.6 BiocSingular_1.6.0 dplyr_1.0.9 irlba_2.3.5 e1071_1.7-9 future.apply_1.9.0

joe-jhou2 commented 2 years ago

That error is gone when reboot the R. But another error shows " Error: Cannot find 'pca' in this Seurat object". I retrieve your code, yes, only "pca" data extract for Dimension Reduction slot. My data was processed by harmony and NMF instead of PCA. Even I revise your code to accommodate my case, but the downstream analysis cannot pass through. Simplify my question, I'd like to try your spatial deconvolution algorithm on my Seurat object which has been processed by harmony and NMF only. Any suggestion to implement that ? Thanks.

EternalEnvy10 commented 2 years ago

sessionInfo()

Hi,

Which version of suite are you using? You may have to update if you are not using the current version, 2.0.0.998.

If that does not work could you provide the a screen shot with what happens when you run seuratToGiotto?

How do I upgrade packages? I find that using update.packages() does not work.

EmmaKelley commented 2 years ago

Suite is our development branch and has not been officially released, as such is frequently updated. In order to make sure you are using the most up-to-date version, it is best practice to re-install Giotto suite regularly:

remotes::install_github("RubD/Giotto@suite")

EmmaKelley commented 2 years ago

The SeurattoGiotto issue that opened this thread should be fixed now as the function is now compatible with Seurat objects with any type of dimension reduction.

EternalEnvy10 commented 2 years ago

Suite is our development branch and has not been officially released, as such is frequently updated. In order to make sure you are using the most up-to-date version, it is best practice to re-install Giotto suite regularly:

remotes::install_github("RubD/Giotto@suite")

Thank you for your reply! I have now converted the Seurat object into a Giotto object. I want to perform a spatial patterns analysis based on the clusters that Seurat has divided. I refer to the mouse_visium_brain demo. So I run the process from part8:spatial grid:

image

The error message is as follows:

image

Did I miss an important process that led to an error? Looking forward to your reply:)

Best, Zhaonian