scplotter to work with SlideSeq data prepared by Giotto¶
See: https://drieslab.github.io/Giotto_website/articles/slideseq_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Ā [2]:
library(Giotto)
## Set instructions
results_folder <- "data/Giotto_SlideSeq.results"
instructions <- createGiottoInstructions(
save_dir = results_folder,
save_plot = FALSE,
show_plot = TRUE,
return_plot = TRUE,
python_path = python_path
)
## Provide the path to the visium folder
data_path <- "data/Giotto_SlideSeq"
expression_matrix <- get10Xmatrix(file.path(data_path, "2020-12-19_Puck_201112_26.matched.digital_expression"))
spatial_locs <- data.table::fread(file.path(data_path, "2020-12-19_Puck_201112_26.BeadLocationsForR.csv.tar"))
spatial_locs <- spatial_locs[spatial_locs$barcodes %in% colnames(expression_matrix),]
giotto_object <- createGiottoObject(
expression = expression_matrix,
spatial_locs = spatial_locs,
instructions = instructions
)
force(giotto_object)
python already initialized in this session active environment : 'giotto_env' python version : 3.10
An object of class giotto >Active spat_unit: cell >Active feat_type: rna dimensions : 21697, 20618 (features, cells) [SUBCELLULAR INFO] [AGGREGATE INFO] expression ----------------------- [cell][rna] raw spatial locations ---------------- [cell] raw Use objHistory() to see steps and params used
InĀ [3]:
options(repr.plot.width = 12, repr.plot.height = 6)
# devtools::load_all()
p1 <- SpatDimPlot(giotto_object, points_size = 2, points_color_by = "lightblue")
p2 <- SpatDimPlot(giotto_object, points_size = 2, points_color_by = "lightblue",
points_shape = 21, points_border_color = "grey40")
p1 + p2
InĀ [4]:
giotto_object <- filterGiotto(giotto_object,
min_det_feats_per_cell = 10,
feat_det_in_min_cells = 10)
giotto_object <- normalizeGiotto(giotto_object)
giotto_object <- addStatistics(giotto_object)
giotto_object <- runPCA(giotto_object)
giotto_object <- runUMAP(giotto_object,
dimensions_to_use = 1:10)
giotto_object <- createNearestNetwork(giotto_object)
giotto_object <- doLeidenCluster(giotto_object,
resolution = 1)
completed 1: preparation completed 2: subset expression data completed 3: subset spatial locations completed 4: subset cell metadata completed 5: subset feature metadata completed 6: subset spatial network(s) completed 7: subsetted dimension reductions completed 8: subsetted nearest network(s) completed 9: subsetted spatial enrichment results
Feature type: rna Number of cells removed: 275 out of 20618 Number of feats removed: 6204 out of 21697
first scale feats and then cells
Warning message in asMethod(object): āsparse->dense coercion: allocating vector of size 2.3 GiBā Setting expression [cell][rna] normalized Setting expression [cell][rna] scaled calculating statistics for "normalized" expression "hvf" was not found in the gene metadata information. all genes will be used. Setting dimension reduction [cell][rna] pca Setting dimension reduction [cell][rna] umap
InĀ [5]:
options(repr.plot.width = 7, repr.plot.height = 7)
# devtools::load_all()
SpatFeaturePlot(giotto_object, features = "nr_feats", points_shape = 21,
points_palette = "Reds", points_border_color = "grey")
InĀ [9]:
options(repr.plot.width = 7, repr.plot.height = 7)
SpatDimPlot(giotto_object, group_by = "leiden_clus")
InĀ [11]:
options(repr.plot.width = 14, repr.plot.height = 6.5)
p1 <- CellDimPlot(giotto_object, group_by = "leiden_clus", label = TRUE)
p2 <- CellDimPlot(giotto_object, group_by = "leiden_clus", reduction = "umap", label = TRUE)
p1 + p2
InĀ [7]:
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] labeling_0.4.3 Seurat_5.3.0 [31] spatstat.data_3.1-6 proxy_0.4-27 [33] ggridges_0.5.6 pbapply_1.7-2 [35] pbdZMQ_0.3-14 dbscan_1.2.2 [37] R.utils_2.13.0 stringdist_0.9.15 [39] parallelly_1.45.0 sessioninfo_1.2.3 [41] VGAM_1.1-13 rstudioapi_0.17.1 [43] generics_0.1.4 shape_1.4.6.1 [45] gtools_3.9.5 ica_1.0-3 [47] spatstat.random_3.4-1 dplyr_1.1.4 [49] Matrix_1.7-3 S4Vectors_0.40.2 [51] abind_1.4-5 R.methodsS3_1.8.2 [53] terra_1.8-42 lifecycle_1.0.4 [55] SummarizedExperiment_1.32.0 SparseArray_1.2.4 [57] Rtsne_0.17 grid_4.4.3 [59] promises_1.3.2 crayon_1.5.3 [61] miniUI_0.1.2 lattice_0.22-7 [63] beachmat_2.18.1 cowplot_1.1.3 [65] pillar_1.10.2 GenomicRanges_1.54.1 [67] rjson_0.2.23 future.apply_1.20.0 [69] codetools_0.2-20 glue_1.8.0 [71] spatstat.univar_3.1-3 data.table_1.17.4 [73] remotes_2.5.0 vctrs_0.6.5 [75] png_0.1-8 spam_2.11-1 [77] gtable_0.3.6 assertthat_0.2.1 [79] cachem_1.1.0 S4Arrays_1.2.1 [81] mime_0.13 tidygraph_1.3.0 [83] survival_3.8-3 SingleCellExperiment_1.24.0 [85] units_0.8-5 ellipsis_0.3.2 [87] scRepertoire_2.2.1 fitdistrplus_1.2-2 [89] ROCR_1.0-11 nlme_3.1-168 [91] usethis_3.1.0 RcppAnnoy_0.0.22 [93] evd_2.3-7.1 GenomeInfoDb_1.38.8 [95] rprojroot_2.0.4 irlba_2.3.5.1 [97] KernSmooth_2.23-26 DBI_1.2.3 [99] plotthis_0.7.1 colorspace_2.1-1 [101] BiocGenerics_0.48.1 tidyselect_1.2.1 [103] compiler_4.4.3 SparseM_1.84-2 [105] xml2_1.3.8 desc_1.4.3 [107] ggdendro_0.2.0 DelayedArray_0.28.0 [109] plotly_4.10.4 checkmate_2.3.2 [111] scales_1.4.0 classInt_0.4-11 [113] lmtest_0.9-40 rappdirs_0.3.3 [115] stringr_1.5.1 digest_0.6.37 [117] goftest_1.2-3 spatstat.utils_3.1-4 [119] XVector_0.42.0 htmltools_0.5.8.1 [121] GiottoVisuals_0.2.12 pkgconfig_2.0.3 [123] base64enc_0.1-3 MatrixGenerics_1.14.0 [125] fastmap_1.2.0 rlang_1.1.6 [127] GlobalOptions_0.1.2 htmlwidgets_1.6.4 [129] shiny_1.10.0 farver_2.1.2 [131] zoo_1.8-14 jsonlite_2.0.0 [133] BiocParallel_1.36.0 R.oo_1.27.1 [135] BiocSingular_1.18.0 RCurl_1.98-1.17 [137] magrittr_2.0.3 GenomeInfoDbData_1.2.11 [139] dotCall64_1.2 patchwork_1.3.0 [141] IRkernel_1.3.2 Rcpp_1.0.14 [143] evmix_2.12 ggnewscale_0.5.1 [145] viridis_0.6.5 reticulate_1.42.0 [147] truncdist_1.0-2 stringi_1.8.7 [149] ggalluvial_0.12.5 ggraph_2.2.1 [151] zlibbioc_1.48.2 MASS_7.3-64 [153] plyr_1.8.9 pkgbuild_1.4.8 [155] parallel_4.4.3 listenv_0.9.1 [157] ggrepel_0.9.6 forcats_1.0.0 [159] deldir_2.0-4 graphlayouts_1.2.2 [161] IRdisplay_1.1 splines_4.4.3 [163] gridtext_0.1.5 tensor_1.5 [165] circlize_0.4.16 colorRamp2_0.1.0 [167] igraph_2.0.3 uuid_1.2-1 [169] spatstat.geom_3.4-1 cubature_2.1.4 [171] RcppHNSW_0.6.0 ScaledMatrix_1.10.0 [173] reshape2_1.4.4 stats4_4.4.3 [175] pkgload_1.4.0 evaluate_1.0.3 [177] SeuratObject_5.1.0 tweenr_2.0.3 [179] httpuv_1.6.15 MatrixModels_0.5-4 [181] RANN_2.6.2 tidyr_1.3.1 [183] purrr_1.0.4 polyclip_1.10-7 [185] future_1.58.0 scattermore_1.2 [187] ggplot2_3.5.2 ggforce_0.4.2 [189] rsvd_1.0.5 xtable_1.8-4 [191] e1071_1.7-16 RSpectra_0.16-2 [193] later_1.4.2 class_7.3-23 [195] viridisLite_0.4.2 gsl_2.1-8 [197] tibble_3.2.1 memoise_2.0.1 [199] IRanges_2.36.0 cluster_2.1.8.1 [201] globals_0.18.0