scplotter to work with seqFISH data prepared by Giotto¶
See: https://drieslab.github.io/Giotto_website/articles/mini_seqfish.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]:
seqfish_mini <- GiottoData::loadGiottoMini("seqfish")
seqfish_mini
1. read Giotto object 2. read Giotto feature information 3. read Giotto spatial 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: cell >Active feat_type: rna dimensions : 1774, 118 (features, cells) [SUBCELLULAR INFO] [AGGREGATE INFO] expression ----------------------- [cell][rna] raw spatial locations ---------------- [cell] raw Use objHistory() to see steps and params used
InĀ [3]:
seqfish_mini <- filterGiotto(gobject = seqfish_mini,
expression_threshold = 0.5,
feat_det_in_min_cells = 20,
min_det_feats_per_cell = 0)
seqfish_mini <- normalizeGiotto(gobject = seqfish_mini,
scalefactor = 6000,
verbose = TRUE)
seqfish_mini <- addStatistics(gobject = seqfish_mini)
seqfish_mini <- adjustGiottoMatrix(gobject = seqfish_mini,
expression_values = "normalized",
covariate_columns = c("nr_feats", "total_expr"))
seqfish_mini <- calculateHVF(gobject = seqfish_mini)
seqfish_mini <- runPCA(gobject = seqfish_mini)
seqfish_mini <- runUMAP(seqfish_mini,
dimensions_to_use = 1:5,
n_threads = 2)
seqfish_mini <- runtSNE(seqfish_mini,
dimensions_to_use = 1:5)
seqfish_mini <- createNearestNetwork(gobject = seqfish_mini,
dimensions_to_use = 1:5,
k = 5)
seqfish_mini <- doLeidenCluster(gobject = seqfish_mini,
resolution = 0.4,
n_iterations = 1000)
clusters_cell_types <- c("cell A", "cell B", "cell C", "cell D",
"cell E", "cell F", "cell G", "cell H")
names(clusters_cell_types) <- 1:8
seqfish_mini <- annotateGiotto(gobject = seqfish_mini,
annotation_vector = clusters_cell_types,
cluster_column = "leiden_clus",
name = "cell_types")
seqfish_mini <- createSpatialNetwork(gobject = seqfish_mini,
minimum_k = 2,
maximum_distance_delaunay = 400)
seqfish_mini <- createSpatialNetwork(gobject = seqfish_mini,
minimum_k = 2,
method = "kNN",
k = 10)
km_spatialfeats <- binSpect(seqfish_mini)
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: 0 out of 118 Number of feats removed: 435 out of 1774
first scale feats and then cells Setting expression [cell][rna] normalized Setting expression [cell][rna] scaled calculating statistics for "normalized" expression Setting expression [cell][rna] custom "hvf" column was found in the feats metadata information and will be used to select highly variable features Warning message in .run_pca_biocsingular(x = t_flex(expr_values), center = center, : āncp >= minimum dimension of x, will be set to minimum dimension of x - 1ā Warning message in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth = TRUE, : āYou're computing too large a percentage of total singular values, use a standard svd instead.ā Warning message in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth = TRUE, : ādid not converge--results might be invalid!; try increasing work or maxitā Setting dimension reduction [cell][rna] pca Setting dimension reduction [cell][rna] umap Setting dimension reduction [cell][rna] tsne Setting spatial network [cell] Delaunay_network Setting spatial network [cell] kNN_network This is the single parameter version of binSpect 1. matrix binarization complete 2. spatial enrichment test completed 3. (optional) average expression of high expressing cells calculated 4. (optional) number of high expressing cells calculated
InĀ [15]:
options(repr.plot.width = 14, repr.plot.height = 6)
seqfish_mini@cell_metadata$cell$rna$leiden_clus <- factor(
seqfish_mini@cell_metadata$cell$rna$leiden_clus
)
p1 <- SpatDimPlot(seqfish_mini,
size = 5,
group_by = "leiden_clus")
p2 <- SpatDimPlot(seqfish_mini,
size = 5,
group_by = "cell_types")
p1 + p2
InĀ [27]:
options(repr.plot.width = 12, repr.plot.height = 6)
p1 <- SpatDimPlot(seqfish_mini,
size = 2,
graph = "Delaunay_network",
edge_color = "blue",
edge_size = 1,
edge_alpha = 0.5,
group_by = "leiden_clus")
p2 <- SpatDimPlot(seqfish_mini,
size = 2,
graph = "kNN_network",
edge_color = "blue",
edge_size = 1,
edge_alpha = 0.5,
group_by = "leiden_clus")
p1 + p2
InĀ [34]:
options(repr.plot.width = 10, repr.plot.height = 10)
SpatFeaturePlot(
seqfish_mini,
layer = "scaled",
shape = 21,
size = 3.5,
border_color = "lightgrey",
features = km_spatialfeats[1:4]$feats
)
InĀ [4]:
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] devtools_2.4.5 httr_1.4.7 [7] RColorBrewer_1.1-3 repr_1.1.7 [9] profvis_0.4.0 tools_4.4.3 [11] sctransform_0.4.2 backports_1.5.0 [13] R6_2.6.1 uwot_0.2.3 [15] lazyeval_0.2.2 urlchecker_1.0.1 [17] withr_3.0.2 sp_2.2-0 [19] gridExtra_2.3 GiottoUtils_0.2.5 [21] progressr_0.15.1 quantreg_6.00 [23] cli_3.6.5 Biobase_2.62.0 [25] spatstat.explore_3.4-3 fastDummies_1.7.5 [27] iNEXT_3.0.1 Seurat_5.3.0 [29] spatstat.data_3.1-6 ggridges_0.5.6 [31] pbapply_1.7-2 pbdZMQ_0.3-14 [33] dbscan_1.2.2 R.utils_2.13.0 [35] stringdist_0.9.15 parallelly_1.45.0 [37] sessioninfo_1.2.3 limma_3.62.2 [39] VGAM_1.1-13 rstudioapi_0.17.1 [41] FNN_1.1.4.1 generics_0.1.4 [43] shape_1.4.6.1 gtools_3.9.5 [45] ica_1.0-3 spatstat.random_3.4-1 [47] dplyr_1.1.4 Matrix_1.7-3 [49] S4Vectors_0.40.2 abind_1.4-5 [51] R.methodsS3_1.8.2 terra_1.8-42 [53] lifecycle_1.0.4 SummarizedExperiment_1.32.0 [55] SparseArray_1.2.4 Rtsne_0.17 [57] grid_4.4.3 promises_1.3.2 [59] crayon_1.5.3 miniUI_0.1.2 [61] lattice_0.22-7 beachmat_2.18.1 [63] cowplot_1.1.3 pillar_1.10.2 [65] GenomicRanges_1.54.1 rjson_0.2.23 [67] future.apply_1.20.0 codetools_0.2-20 [69] glue_1.8.0 spatstat.univar_3.1-3 [71] data.table_1.17.4 remotes_2.5.0 [73] vctrs_0.6.5 png_0.1-8 [75] spam_2.11-1 gtable_0.3.6 [77] assertthat_0.2.1 cachem_1.1.0 [79] S4Arrays_1.2.1 mime_0.13 [81] tidygraph_1.3.0 survival_3.8-3 [83] SingleCellExperiment_1.24.0 statmod_1.5.0 [85] GiottoData_0.2.16 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 plotthis_0.7.0 [99] colorspace_2.1-1 BiocGenerics_0.48.1 [101] tidyselect_1.2.1 compiler_4.4.3 [103] SparseM_1.84-2 xml2_1.3.8 [105] desc_1.4.3 ggdendro_0.2.0 [107] DelayedArray_0.28.0 plotly_4.10.4 [109] checkmate_2.3.2 scales_1.4.0 [111] lmtest_0.9-40 rappdirs_0.3.3 [113] stringr_1.5.1 digest_0.6.37 [115] goftest_1.2-3 spatstat.utils_3.1-4 [117] XVector_0.42.0 htmltools_0.5.8.1 [119] GiottoVisuals_0.2.12 pkgconfig_2.0.3 [121] base64enc_0.1-3 MatrixGenerics_1.14.0 [123] fastmap_1.2.0 rlang_1.1.6 [125] GlobalOptions_0.1.2 htmlwidgets_1.6.4 [127] shiny_1.10.0 farver_2.1.2 [129] zoo_1.8-14 jsonlite_2.0.0 [131] BiocParallel_1.36.0 R.oo_1.27.1 [133] BiocSingular_1.18.0 RCurl_1.98-1.17 [135] magrittr_2.0.3 GenomeInfoDbData_1.2.11 [137] dotCall64_1.2 patchwork_1.3.0 [139] IRkernel_1.3.2 Rcpp_1.0.14 [141] evmix_2.12 ggnewscale_0.5.1 [143] viridis_0.6.5 reticulate_1.42.0 [145] truncdist_1.0-2 stringi_1.8.7 [147] ggalluvial_0.12.5 ggraph_2.2.1 [149] zlibbioc_1.48.2 MASS_7.3-64 [151] plyr_1.8.9 pkgbuild_1.4.8 [153] parallel_4.4.3 listenv_0.9.1 [155] ggrepel_0.9.6 forcats_1.0.0 [157] deldir_2.0-4 graphlayouts_1.2.2 [159] IRdisplay_1.1 splines_4.4.3 [161] gridtext_0.1.5 tensor_1.5 [163] circlize_0.4.16 colorRamp2_0.1.0 [165] igraph_2.0.3 uuid_1.2-1 [167] spatstat.geom_3.4-1 cubature_2.1.4 [169] RcppHNSW_0.6.0 ScaledMatrix_1.10.0 [171] reshape2_1.4.4 stats4_4.4.3 [173] pkgload_1.4.0 evaluate_1.0.3 [175] SeuratObject_5.1.0 tweenr_2.0.3 [177] httpuv_1.6.15 MatrixModels_0.5-4 [179] RANN_2.6.2 tidyr_1.3.1 [181] purrr_1.0.4 polyclip_1.10-7 [183] future_1.58.0 scattermore_1.2 [185] ggplot2_3.5.2 ggforce_0.4.2 [187] rsvd_1.0.5 xtable_1.8-4 [189] RSpectra_0.16-2 later_1.4.2 [191] viridisLite_0.4.2 gsl_2.1-8 [193] tibble_3.2.1 memoise_2.0.1 [195] IRanges_2.36.0 cluster_2.1.8.1 [197] globals_0.18.0