Show the code
library(ggplot2)
library(RColorBrewer)
library(ExperimentHub)
library(SpatialExperiment)
library(STexampleData)
This website is still under active development - all content subject to change
December 3, 2024
# extract cell metadata
i <- seq_len(9)
cd <- data.frame(df[, i], row.names = 1)
# set sample identifiers
id <- grep("Bregma", names(cd))
names(cd)[id] <- "sample_id"
# rename spatial coordinates
xy <- grep("Centroid", names(cd))
xy <- names(cd)[xy] <- c("x", "y")
# simplify annotations
cd$cluster_id <- cd$Cell_class
for (. in c("Endothelial", "OD Mature", "OD Immature"))
cd$cluster_id[grep(., cd$cluster_id)] <- .
# extract & sparsify assay data
y <- data.frame(df[, -i], row.names = df[, 1])
y <- as(t(as.matrix(y)), "dgCMatrix")
# construct SPE
(spe <- SpatialExperiment(
assays = list(exprs = y),
spatialCoordsNames = xy,
colData = cd))
class: SpatialExperiment
dim: 161 73655
metadata(0):
assays(1): exprs
rownames(161): Ace2 Adora2a ... Ucn3 Vgf
rowData names(0):
colnames(73655): 6749ccb4-2ed1-4029-968f-820a287f43c8
6cac74bd-4ea7-4701-8701-42563cc65eb8 ...
6b666f81-7b73-4100-9e02-b5381b39f0f3
fdcddd97-7701-462a-b48f-979111245bd5
colData names(7): Animal_ID Animal_sex ... Neuron_cluster_ID cluster_id
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):
spatialCoords names(2) : x y
imgData names(0):
gg <- data.frame(spatialCoords(spe), colData(spe))
pal <- brewer.pal(length(unique(gg$cluster_id)), "Paired")
ggplot(gg, aes(x, y, col = cluster_id)) +
facet_wrap(~ sample_id, scales = "free") +
geom_point(size = 0.1) + scale_color_manual(values = pal) +
guides(col = guide_legend(override.aes = list(size = 2))) +
theme_void() + theme(legend.key.size = unit(0.5, "lines"))
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.7.2
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Europe/Zurich
tzcode source: internal
attached base packages:
[1] stats4 stats graphics grDevices datasets utils methods
[8] base
other attached packages:
[1] MerfishData_1.2.0 EBImage_4.42.0
[3] STexampleData_1.8.0 SpatialExperiment_1.10.0
[5] SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.2
[7] Biobase_2.60.0 GenomicRanges_1.52.1
[9] GenomeInfoDb_1.36.4 IRanges_2.34.1
[11] S4Vectors_0.38.2 MatrixGenerics_1.12.3
[13] matrixStats_1.5.0 ExperimentHub_2.8.1
[15] AnnotationHub_3.8.0 BiocFileCache_2.8.0
[17] dbplyr_2.3.4 BiocGenerics_0.46.0
[19] RColorBrewer_1.1-3 ggplot2_3.5.1
loaded via a namespace (and not attached):
[1] DBI_1.2.3 bitops_1.0-9
[3] rlang_1.1.4 magrittr_2.0.3
[5] compiler_4.3.1 RSQLite_2.3.9
[7] DelayedMatrixStats_1.22.6 fftwtools_0.9-11
[9] png_0.1-8 vctrs_0.6.5
[11] pkgconfig_2.0.3 crayon_1.5.3
[13] fastmap_1.2.0 magick_2.8.5
[15] XVector_0.40.0 labeling_0.4.3
[17] scuttle_1.10.3 promises_1.3.2
[19] rmarkdown_2.29 purrr_1.0.2
[21] bit_4.5.0.1 xfun_0.50
[23] zlibbioc_1.46.0 cachem_1.1.0
[25] beachmat_2.16.0 jsonlite_1.8.9
[27] blob_1.2.4 later_1.4.1
[29] rhdf5filters_1.12.1 DelayedArray_0.26.7
[31] Rhdf5lib_1.22.1 BiocParallel_1.34.2
[33] interactiveDisplayBase_1.38.0 jpeg_0.1-10
[35] tiff_0.1-12 parallel_4.3.1
[37] R6_2.5.1 limma_3.56.2
[39] Rcpp_1.0.13-1 knitr_1.49
[41] R.utils_2.12.3 httpuv_1.6.15
[43] Matrix_1.5-4.1 tidyselect_1.2.1
[45] rstudioapi_0.15.0 abind_1.4-8
[47] yaml_2.3.10 codetools_0.2-19
[49] curl_6.1.0 lattice_0.22-6
[51] tibble_3.2.1 shiny_1.10.0
[53] withr_3.0.2 KEGGREST_1.40.1
[55] evaluate_1.0.1 Biostrings_2.68.1
[57] pillar_1.10.1 BiocManager_1.30.25
[59] filelock_1.0.3 renv_1.0.11
[61] generics_0.1.3 RCurl_1.98-1.16
[63] BiocVersion_3.17.1 sparseMatrixStats_1.12.2
[65] munsell_0.5.1 scales_1.3.0
[67] xtable_1.8-4 glue_1.8.0
[69] tools_4.3.1 locfit_1.5-9.10
[71] rhdf5_2.44.0 grid_4.3.1
[73] DropletUtils_1.20.0 AnnotationDbi_1.62.2
[75] edgeR_3.42.4 colorspace_2.1-1
[77] GenomeInfoDbData_1.2.10 HDF5Array_1.28.1
[79] cli_3.6.3 rappdirs_0.3.3
[81] S4Arrays_1.0.6 dplyr_1.1.4
[83] gtable_0.3.6 R.methodsS3_1.8.2
[85] digest_0.6.37 dqrng_0.4.1
[87] farver_2.1.2 rjson_0.2.23
[89] htmlwidgets_1.6.4 memoise_2.0.1
[91] htmltools_0.5.8.1 R.oo_1.27.0
[93] lifecycle_1.0.4 httr_1.4.7
[95] mime_0.12 bit64_4.5.2
©2024 The pasta
authors. Content is published under Creative Commons CC-BY-4.0 License for the text and GPL-3 License for any code.