scplotter to work with Vizgen Mouse Brain Receptor Map data prepared by Giotto¶
See: https://drieslab.github.io/Giotto_website/articles/vizgen_mouse_brain.html
Go back to scplotter documentation: https://pwwang.github.io/scplotter/
InĀ [1]:
library(Giotto)
# Ensure Giotto can access a python env
genv_exists <- suppressMessages(checkGiottoEnvironment())
print(genv_exists)
python_path <- file.path(Sys.getenv("HOME"), "miniconda3", "envs", "giotto_env", "bin", "python")
Sys.setenv(RETICULATE_PYTHON = python_path)
invisible(capture.output(suppressMessages(set_giotto_python_path(python_path = python_path))))
# library(scplotter)
devtools::load_all()
Loading required package: GiottoClass Newer devel version of GiottoClass on GitHub: 0.4.8 Giotto Suite 4.2.1
[1] TRUE
ā¹ Loading scplotter
InĀ [3]:
g <- GiottoData::loadGiottoMini(dataset = "vizgen")
g
1. read Giotto object
2. read Giotto feature information 3. read Giotto spatial information 3.1 read Giotto spatial shape information 3.2 read Giotto spatial centroid information 3.3 read Giotto spatial overlap information 4. read Giotto image information python already initialized in this session active environment : 'giotto_env' python version : 3.10
An object of class giotto >Active spat_unit: z0 >Active feat_type: rna dimensions : 337, 498 (features, cells) [SUBCELLULAR INFO] polygons : z0 z1 aggregate features : rna [AGGREGATE INFO] expression ----------------------- [z0][rna] raw [z1][rna] raw [aggregate][rna] raw normalized scaled pearson spatial locations ---------------- [z0] raw [z1] raw [aggregate] raw spatial networks ----------------- [aggregate] Delaunay_network kNN_network spatial enrichments -------------- [aggregate][rna] cluster_metagene dim reduction -------------------- [aggregate][rna] pca umap tsne nearest neighbor networks -------- [aggregate][rna] sNN.pca attached images ------------------ images : 4 items... Use objHistory() to see steps and params used
InĀ [10]:
options(repr.plot.width = 7, repr.plot.height = 6)
SpatDimPlot(g)
InĀ [18]:
options(repr.plot.width = 14, repr.plot.height = 6)
g@cell_metadata$aggregate$rna$leiden_clus <- factor(g@cell_metadata$aggregate$rna$leiden_clus)
g@cell_metadata$aggregate$rna$louvain_clus <- factor(g@cell_metadata$aggregate$rna$louvain_clus)
p1 <- SpatDimPlot(g, group_by = "leiden_clus", spat_unit = "aggregate")
p2 <- SpatDimPlot(g, group_by = "louvain_clus", spat_unit = "aggregate", palette = "Reds")
p1 + p2
InĀ [22]:
options(repr.plot.width = 14, repr.plot.height = 6)
p1 <- SpatDimPlot(g, image = "dapi_z0", group_by = "leiden_clus", spat_unit = "aggregate")
p2 <- SpatFeaturePlot(g, image = "dapi_z0", features = "nr_feats", spat_unit = "aggregate")
p1 + p2
InĀ [27]:
options(repr.plot.width = 7, repr.plot.height = 6)
p1 <- SpatFeaturePlot(g, features = "Slc47a1", spat_unit = "aggregate",
size = 3)
p1
InĀ [Ā ]:
options(repr.plot.width = 14, repr.plot.height = 6)
p1 <- SpatDimPlot(g, features = c("Oxgr1", "Htr1a", "Gjc3", "Axl", "Gfap", "Olig1", "Epha7"),
shapes_feat_type = "z0", shapes = TRUE, image = "black", shapes_fill_by = "white",
shapes_alpha = 1)
p2 <- SpatDimPlot(g, features = c("Oxgr1", "Htr1a", "Gjc3", "Axl", "Gfap", "Olig1", "Epha7"),
shapes_feat_type = "z0", shapes = TRUE, image = "black", shapes_fill_by = "white",
# put shpaes on top of points
shapes_alpha = 1, layers = c("image", "points", "shapes"))
p1 + p2
ā¹ Loading scplotter
InĀ [57]:
# Zoom in further and visualize with image
vizgen_subcellular_zoom <- subsetGiottoLocs(
g, poly_info = "z0",
x_min = 6600, x_max = 6800, y_min = -5000, y_max = -4800)
options(repr.plot.width = 14, repr.plot.height = 6)
p1 <- SpatDimPlot(vizgen_subcellular_zoom, image = TRUE,
features = c("Oxgr1", "Htr1a", "Gjc3", "Axl", "Gfap", "Olig1", "Epha7"),
shapes_feat_type = "z0", shapes = TRUE)
p2 <- SpatDimPlot(g, image = TRUE, ext = c(6600, 6800, -5000, -4800), # use ext to zoom in
features = c("Oxgr1", "Htr1a", "Gjc3", "Axl", "Gfap", "Olig1", "Epha7"),
shapes_feat_type = "z0", shapes = TRUE)
p1 + p2
InĀ [11]:
x <- sessionInfo()
x <- capture.output(print(x))
# hide the BLAS/LAPACK paths
x <- x[!startsWith(x, "BLAS/LAPACK:")]
cat(paste(x, collapse = "\n"))
R version 4.4.3 (2025-02-28) Platform: x86_64-conda-linux-gnu Running under: Red Hat Enterprise Linux 8.10 (Ootpa) Matrix products: default locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C time zone: America/Chicago tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] scplotter_0.4.0 Giotto_4.2.1 GiottoClass_0.4.7 loaded via a namespace (and not attached): [1] fs_1.6.6 matrixStats_1.5.0 [3] spatstat.sparse_3.1-0 bitops_1.0-9 [5] sf_1.0-20 devtools_2.4.5 [7] httr_1.4.7 RColorBrewer_1.1-3 [9] repr_1.1.7 profvis_0.4.0 [11] tools_4.4.3 sctransform_0.4.2 [13] backports_1.5.0 R6_2.6.1 [15] uwot_0.2.3 lazyeval_0.2.2 [17] urlchecker_1.0.1 withr_3.0.2 [19] sp_2.2-0 gridExtra_2.3 [21] GiottoUtils_0.2.5 progressr_0.15.1 [23] quantreg_6.00 cli_3.6.5 [25] Biobase_2.62.0 spatstat.explore_3.4-3 [27] fastDummies_1.7.5 iNEXT_3.0.1 [29] Seurat_5.3.0 spatstat.data_3.1-6 [31] proxy_0.4-27 ggridges_0.5.6 [33] pbapply_1.7-2 pbdZMQ_0.3-14 [35] stringdist_0.9.15 parallelly_1.45.0 [37] sessioninfo_1.2.3 VGAM_1.1-13 [39] rstudioapi_0.17.1 generics_0.1.4 [41] shape_1.4.6.1 gtools_3.9.5 [43] ica_1.0-3 spatstat.random_3.4-1 [45] dplyr_1.1.4 Matrix_1.7-3 [47] S4Vectors_0.40.2 abind_1.4-5 [49] terra_1.8-42 lifecycle_1.0.4 [51] SummarizedExperiment_1.32.0 SparseArray_1.2.4 [53] Rtsne_0.17 grid_4.4.3 [55] promises_1.3.2 crayon_1.5.3 [57] miniUI_0.1.2 lattice_0.22-7 [59] cowplot_1.1.3 pillar_1.10.2 [61] GenomicRanges_1.54.1 rjson_0.2.23 [63] future.apply_1.20.0 codetools_0.2-20 [65] glue_1.8.0 spatstat.univar_3.1-3 [67] data.table_1.17.4 remotes_2.5.0 [69] vctrs_0.6.5 png_0.1-8 [71] spam_2.11-1 gtable_0.3.6 [73] assertthat_0.2.1 cachem_1.1.0 [75] S4Arrays_1.2.1 mime_0.13 [77] tidygraph_1.3.0 survival_3.8-3 [79] SingleCellExperiment_1.24.0 units_0.8-5 [81] GiottoData_0.2.16 ellipsis_0.3.2 [83] scRepertoire_2.2.1 fitdistrplus_1.2-2 [85] ROCR_1.0-11 nlme_3.1-168 [87] usethis_3.1.0 RcppAnnoy_0.0.22 [89] evd_2.3-7.1 GenomeInfoDb_1.38.8 [91] rprojroot_2.0.4 irlba_2.3.5.1 [93] KernSmooth_2.23-26 DBI_1.2.3 [95] plotthis_0.7.0 colorspace_2.1-1 [97] BiocGenerics_0.48.1 tidyselect_1.2.1 [99] compiler_4.4.3 SparseM_1.84-2 [101] xml2_1.3.8 desc_1.4.3 [103] ggdendro_0.2.0 DelayedArray_0.28.0 [105] plotly_4.10.4 checkmate_2.3.2 [107] scales_1.4.0 classInt_0.4-11 [109] lmtest_0.9-40 rappdirs_0.3.3 [111] stringr_1.5.1 digest_0.6.37 [113] goftest_1.2-3 spatstat.utils_3.1-4 [115] XVector_0.42.0 htmltools_0.5.8.1 [117] GiottoVisuals_0.2.12 pkgconfig_2.0.3 [119] base64enc_0.1-3 MatrixGenerics_1.14.0 [121] fastmap_1.2.0 rlang_1.1.6 [123] GlobalOptions_0.1.2 htmlwidgets_1.6.4 [125] shiny_1.10.0 farver_2.1.2 [127] zoo_1.8-14 jsonlite_2.0.0 [129] RCurl_1.98-1.17 magrittr_2.0.3 [131] GenomeInfoDbData_1.2.11 dotCall64_1.2 [133] patchwork_1.3.0 IRkernel_1.3.2 [135] Rcpp_1.0.14 evmix_2.12 [137] ggnewscale_0.5.1 viridis_0.6.5 [139] reticulate_1.42.0 truncdist_1.0-2 [141] stringi_1.8.7 ggalluvial_0.12.5 [143] ggraph_2.2.1 zlibbioc_1.48.2 [145] MASS_7.3-64 plyr_1.8.9 [147] pkgbuild_1.4.8 parallel_4.4.3 [149] listenv_0.9.1 ggrepel_0.9.6 [151] forcats_1.0.0 deldir_2.0-4 [153] graphlayouts_1.2.2 IRdisplay_1.1 [155] splines_4.4.3 gridtext_0.1.5 [157] tensor_1.5 circlize_0.4.16 [159] colorRamp2_0.1.0 igraph_2.0.3 [161] uuid_1.2-1 spatstat.geom_3.4-1 [163] cubature_2.1.4 RcppHNSW_0.6.0 [165] reshape2_1.4.4 stats4_4.4.3 [167] pkgload_1.4.0 evaluate_1.0.3 [169] SeuratObject_5.1.0 tweenr_2.0.3 [171] httpuv_1.6.15 MatrixModels_0.5-4 [173] RANN_2.6.2 tidyr_1.3.1 [175] purrr_1.0.4 polyclip_1.10-7 [177] future_1.58.0 scattermore_1.2 [179] ggplot2_3.5.2 ggforce_0.4.2 [181] xtable_1.8-4 e1071_1.7-16 [183] RSpectra_0.16-2 later_1.4.2 [185] class_7.3-23 viridisLite_0.4.2 [187] gsl_2.1-8 tibble_3.2.1 [189] memoise_2.0.1 IRanges_2.36.0 [191] cluster_2.1.8.1 globals_0.18.0