scplotter to work with SlideSeq data prepared by Seurat¶
Go back to scplotter documentation: https://pwwang.github.io/scplotter/
InĀ [1]:
options(future.globals.maxSize = 512 * 1024^3) # 512 GB
suppressPackageStartupMessages({
library(Seurat)
})
# Load the scplotter package
# library(scplotter)
devtools::load_all()
# devtools::load_all("../../../plotthis")
# see also the vignette for scplotter to work with CosMx data prepared by Giotto
data.dir <- "data/CosMx_Quarter_Brain/Quarter_Brain"
obj <- LoadNanostring(data.dir = data.dir, fov = 'fov')
obj
ā¹ Loading scplotter
An object of class Seurat 960 features across 38987 samples within 1 assay Active assay: Nanostring (960 features, 0 variable features) 1 layer present: counts 1 spatial field of view present: fov
InĀ [75]:
options(repr.plot.width = 8, repr.plot.height = 4.5)
SpatDimPlot(obj, points_size = 0.5)
InĀ [121]:
# add fake annotations
obj$celltype <- sample(LETTERS[1:10], size = ncol(obj), replace = TRUE)
obj$celltype <- factor(obj$celltype, levels = LETTERS[1:10])
Idents(obj) <- "celltype"
options(repr.plot.width = 8, repr.plot.height = 4.5)
SpatDimPlot(obj, image = "black", group_by = "celltype", points_size = 0.5,
theme = "theme_this")
InĀ [77]:
options(repr.plot.width = 8, repr.plot.height = 4.5)
subobj <- subset(obj, celltype %in% c("A", "B", "C"))
SpatFeaturePlot(subobj, image = "black", group_by = "celltype", points_size = 0.5)
Warning message: āNot validating FOV objectsā Warning message: āNot validating Centroids objectsā Warning message: āNot validating Centroids objectsā Warning message: āNot validating FOV objectsā Warning message: āNot validating Centroids objectsā Warning message: āNot validating FOV objectsā Warning message: āNot validating FOV objectsā Warning message: āNot validating FOV objectsā Warning message: āNot validating Seurat objectsā
InĀ [84]:
options(repr.plot.width = 8, repr.plot.height = 9)
p1 <- SpatFeaturePlot(obj, image = "black", features = "Chrna4", layer = "counts", points_size = 0.5)
p2 <- SpatDimPlot(obj, image = "black", features = c('Chrna4', 'Slc6a1', 'Cd109', 'Ldha', 'Aldoc'),
points_size = 0.25, nmols = 10000)
p1 / p2
InĀ [129]:
options(repr.plot.width = 12, repr.plot.height = 5)
# Note that Crop() swapped x and y
crop <- Crop(obj[["fov"]], y = c(130000, 135000), x = c(0, 5000))
obj[["zoom1"]] <- crop
DefaultBoundary(obj[["zoom1"]]) <- "segmentation"
# devtools::load_all()
# Use cropped fov
p1 <- SpatDimPlot(obj, fov = "zoom1", points = FALSE, shapes_fill_by = "celltype",
shapes_border_size = 0.1, theme = "theme_this")
# Or just pass the desired extent
# Note that the extent is in the right x and y order
p2 <- SpatDimPlot(obj, fov = "fov", points = FALSE, shapes_fill_by = "celltype",
shapes = "segmentation", # pass the boundary name, since centroids are the default
shapes_border_size = 0.1, ext = c(130000, 135000, 0, 5000), theme = "theme_this")
p1 + p2
Warning message: āKey āNanostring_ā taken, using āzoom1_ā insteadā Warning message: āAdding image with unordered cellsā ā¹ Loading scplotter
InĀ [Ā ]:
options(repr.plot.width = 6, repr.plot.height = 5)
SpatDimPlot(
obj, fov = "zoom1", image = "black",
features = c('Chrna4', 'Slc6a1', 'Cd109', 'Ldha', 'Aldoc'),
points_size = 0.25, nmols = 10000
)
InĀ [2]:
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.3.3 (2024-02-29) Platform: x86_64-conda-linux-gnu (64-bit) 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 Seurat_5.3.0 SeuratObject_5.0.2 sp_2.1-4 loaded via a namespace (and not attached): [1] cubature_2.1.1 RcppAnnoy_0.0.22 [3] splines_4.3.3 later_1.3.2 [5] pbdZMQ_0.3-11 bitops_1.0-7 [7] tibble_3.2.1 polyclip_1.10-6 [9] fastDummies_1.7.3 lifecycle_1.0.4 [11] rprojroot_2.0.4 globals_0.16.3 [13] lattice_0.22-6 MASS_7.3-60.0.1 [15] magrittr_2.0.3 plotly_4.10.4 [17] remotes_2.5.0 httpuv_1.6.15 [19] sctransform_0.4.1 spam_2.11-0 [21] sessioninfo_1.2.2 pkgbuild_1.4.4 [23] spatstat.sparse_3.1-0 reticulate_1.38.0 [25] cowplot_1.1.3 pbapply_1.7-2 [27] RColorBrewer_1.1-3 abind_1.4-5 [29] pkgload_1.3.4 zlibbioc_1.48.0 [31] Rtsne_0.17 GenomicRanges_1.54.1 [33] purrr_1.0.2 ggraph_2.2.1 [35] BiocGenerics_0.48.1 RCurl_1.98-1.13 [37] tweenr_2.0.3 evmix_2.12 [39] circlize_0.4.16 GenomeInfoDbData_1.2.11 [41] IRanges_2.36.0 S4Vectors_0.40.2 [43] ggrepel_0.9.6 irlba_2.3.5.1 [45] listenv_0.9.1 spatstat.utils_3.1-1 [47] iNEXT_3.0.1 MatrixModels_0.5-3 [49] goftest_1.2-3 RSpectra_0.16-1 [51] scRepertoire_2.2.1 spatstat.random_3.2-3 [53] fitdistrplus_1.1-11 parallelly_1.38.0 [55] codetools_0.2-20 DelayedArray_0.28.0 [57] xml2_1.3.6 ggforce_0.4.2 [59] shape_1.4.6.1 tidyselect_1.2.1 [61] farver_2.1.2 viridis_0.6.5 [63] matrixStats_1.1.0 stats4_4.3.3 [65] base64enc_0.1-3 spatstat.explore_3.2-6 [67] jsonlite_1.8.8 tidygraph_1.3.0 [69] ellipsis_0.3.2 progressr_0.14.0 [71] ggalluvial_0.12.5 ggridges_0.5.6 [73] survival_3.7-0 ggnewscale_0.5.0 [75] tools_4.3.3 stringdist_0.9.12 [77] ica_1.0-3 Rcpp_1.0.13 [79] glue_1.8.0 gridExtra_2.3 [81] SparseArray_1.2.2 MatrixGenerics_1.14.0 [83] usethis_2.2.3 GenomeInfoDb_1.38.1 [85] IRdisplay_1.1 dplyr_1.1.4 [87] withr_3.0.1 fastmap_1.2.0 [89] fansi_1.0.6 SparseM_1.84 [91] digest_0.6.37 R6_2.5.1 [93] mime_0.12 colorspace_2.1-1 [95] scattermore_1.2 tensor_1.5 [97] spatstat.data_3.1-2 utf8_1.2.4 [99] tidyr_1.3.1 generics_0.1.3 [101] data.table_1.15.4 graphlayouts_1.1.0 [103] httr_1.4.7 htmlwidgets_1.6.4 [105] S4Arrays_1.2.0 uwot_0.1.16 [107] pkgconfig_2.0.3 gtable_0.3.5 [109] lmtest_0.9-40 SingleCellExperiment_1.24.0 [111] XVector_0.42.0 htmltools_0.5.8.1 [113] profvis_0.3.8 dotCall64_1.2 [115] scales_1.3.0 Biobase_2.62.0 [117] png_0.1-8 ggdendro_0.2.0 [119] rstudioapi_0.16.0 rjson_0.2.21 [121] reshape2_1.4.4 uuid_1.2-0 [123] nlme_3.1-165 GlobalOptions_0.1.2 [125] repr_1.1.7 cachem_1.1.0 [127] zoo_1.8-12 stringr_1.5.1 [129] KernSmooth_2.23-24 parallel_4.3.3 [131] miniUI_0.1.1.1 desc_1.4.3 [133] pillar_1.9.0 grid_4.3.3 [135] vctrs_0.6.5 RANN_2.6.1 [137] urlchecker_1.0.1 VGAM_1.1-12 [139] promises_1.3.0 xtable_1.8-4 [141] cluster_2.1.6 evaluate_0.24.0 [143] truncdist_1.0-2 cli_3.6.3 [145] compiler_4.3.3 rlang_1.1.4 [147] crayon_1.5.3 future.apply_1.11.2 [149] forcats_1.0.0 plyr_1.8.9 [151] fs_1.6.4 stringi_1.8.7 [153] viridisLite_0.4.2 deldir_2.0-4 [155] assertthat_0.2.1 gsl_2.1-8 [157] munsell_0.5.1 lazyeval_0.2.2 [159] devtools_2.4.5 spatstat.geom_3.2-9 [161] quantreg_5.98 Matrix_1.6-5 [163] IRkernel_1.3.2 RcppHNSW_0.6.0 [165] patchwork_1.3.0 future_1.34.0 [167] ggplot2_3.5.1 shiny_1.8.1.1 [169] plotthis_0.7.0 SummarizedExperiment_1.32.0 [171] evd_2.3-7.1 ROCR_1.0-11 [173] gridtext_0.1.5 igraph_1.5.1 [175] memoise_2.0.1