satijalab / seurat

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

CosMx Nanostring dataset ImageDimPlot, plot cluster spatial distibution for every FOV seperatly #9279

Open Mohamed-Moustafa-tech opened 2 months ago

Mohamed-Moustafa-tech commented 2 months ago

I am trying to use Seurat to analyse a Nanostring CosMx dataset. I followed the seurat tutorial at this link: https://satijalab.org/seurat/articles/seurat5_spatial_vignette_2#human-lung-nanostring-cosmx-spatial-molecular-imager

I have 4 samples each with 6 FOVs (images) summing up to 24 images. I follow the procedures of the tutorial, but when I use the following code:

library(Seurat)
library(ggplot2)
library(tidyverse)

#Load the CosmX dataset
nano.obj <- LoadNanostring(data.dir = "Run5471_S1", fov = "Run5471S1",
                          assay = "Nanostring")
### 2. Preprocessing and unsupervised analysis
nano.obj <- SCTransform(nano.obj, assay = "Nanostring", 
                        clip.range = c(-10, 10), verbose = FALSE)
nano.obj <- RunPCA(nano.obj, npcs = 50)
nano.obj <- RunUMAP(nano.obj, dims = 1:50)
nano.obj <- FindNeighbors(nano.obj, reduction = "pca", dims = 1:50)
nano.obj <- FindClusters(nano.obj, resolution = 0.3)

ImageDimPlot(nano.obj, cols = "glasbey", axes = TRUE)

I get the cluster spatial distribution in the 24 images, representing FOVs aggregated into 4 groups in one big figure. How do I plot spatial cluster distributions in every FOV separately, so I can interpret them? Attached is the image dim plot output.

ImageDimPlot

Also, this is the folder structure of my Dataset: Run5471_S1 |- CellComposite |- CellLabels |- CellOverlay |- CompartmentLabels |- RawMorphologyIMages |- Run5471_S1_exprMat_file.csv |- Run5471_S1_fov_positions_file.csv |- Run5471_S1_metadata_file.csv |- Run5471_S1_tx_file.csv |-Run5471_S1-polygons.csv

Could you please help resolve this issue?

sessionInfo() 
R version 4.4.1 (2024-06-14 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 10 x64 (build 19045)  Matrix products: default   

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

time zone: Europe/Berlin 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.1      dplyr_1.1.4         [5] purrr_1.0.2        readr_2.1.5        tidyr_1.3.1        tibble_3.2.1        [9] tidyverse_2.0.0    ggplot2_3.5.1      Seurat_5.1.0       SeuratObject_5.0.2 [13] sp_2.1-4           

loaded via a namespace (and not attached):   [1] deldir_2.0-4           pbapply_1.7-2          gridExtra_2.3            [4] remotes_2.5.0          rlang_1.1.4            magrittr_2.0.3           [7] RcppAnnoy_0.0.22       matrixStats_1.3.0      ggridges_0.5.6          [10] compiler_4.4.1         spatstat.geom_3.3-2    png_0.1-8               [13] vctrs_0.6.5            reshape2_1.4.4         pkgconfig_2.0.3         [16] fastmap_1.2.0          utf8_1.2.4             promises_1.3.0          [19] tzdb_0.4.0             jsonlite_1.8.8         goftest_1.2-3           [22] later_1.3.2            spatstat.utils_3.1-0   irlba_2.3.5.1           [25] parallel_4.4.1         cluster_2.1.6          R6_2.5.1                [28] ica_1.0-3              stringi_1.8.4          RColorBrewer_1.1-3      [31] spatstat.data_3.1-2    reticulate_1.38.0      parallelly_1.38.0       [34] spatstat.univar_3.0-0  lmtest_0.9-40          scattermore_1.2         [37] Rcpp_1.0.13            tensor_1.5             future.apply_1.11.2     [40] zoo_1.8-12             sctransform_0.4.1      timechange_0.3.0        [43] httpuv_1.6.15          Matrix_1.7-0           splines_4.4.1           [46] igraph_2.0.3           tidyselect_1.2.1       rstudioapi_0.16.0       [49] abind_1.4-5            spatstat.random_3.3-1  codetools_0.2-20        [52] miniUI_0.1.1.1         spatstat.explore_3.3-1 listenv_0.9.1           [55] lattice_0.22-6         plyr_1.8.9             withr_3.0.1             [58] shiny_1.9.1            ROCR_1.0-11            Rtsne_0.17              [61] future_1.34.0          fastDummies_1.7.4      survival_3.6-4          [64] polyclip_1.10-7        fitdistrplus_1.2-1     pillar_1.9.0            [67] KernSmooth_2.23-24     plotly_4.10.4          generics_0.1.3          [70] RcppHNSW_0.6.0         hms_1.1.3              munsell_0.5.1           [73] scales_1.3.0           globals_0.16.3         xtable_1.8-4            [76] glue_1.7.0             lazyeval_0.2.2         tools_4.4.1             [79] data.table_1.15.4      RSpectra_0.16-2        RANN_2.6.1              [82] leiden_0.4.3.1         dotCall64_1.1-1        cowplot_1.1.3           [85] grid_4.4.1             colorspace_2.1-1       nlme_3.1-164            [88] patchwork_1.2.0        cli_3.6.3              spatstat.sparse_3.1-0   [91] spam_2.10-0            fansi_1.0.6            viridisLite_0.4.2       [94] uwot_0.2.2             gtable_0.3.5           digest_0.6.37           [97] progressr_0.14.0       ggrepel_0.9.5          htmlwidgets_1.6.4      [100] htmltools_0.5.8.1      lifecycle_1.0.4        httr_1.4.7             [103] mime_0.12              MASS_7.3-60.2
--
zskylarli commented 1 month ago

Hi - have you tried specifying your FOV of interest for plotting under the fov argument, as shown in the vignette:

ImageDimPlot(nano.obj, fov = "lung5.rep1", axes = TRUE, cols = "glasbey")