To install the package, start R and enter:
if(!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("MerfishData")
After the installation, we proceed by loading the package and additional packages used in the vignette.
library(MerfishData)
library(ExperimentHub)
library(ggpubr)
Moffitt et al., 2018 developed an imaging-based cell type identification and mapping method and combined it with single-cell RNA-sequencing to create a molecularly annotated and spatially resolved cell atlas of the mouse hypothalamic preoptic region.
Def. hypothalamic preoptic region: is a part of the anterior hypothalamus that controls essential social behaviors and homeostatic functions.
Cell segmentation was carried out based on total polyadenylated mRNA and DAPI nuclei costains. Combinatorial smFISH imaging was used for the identification and spatial expression profiling of 161 genes in 1,027,848 cells from 36 mice (16 female, 20 male).
The data was obtained from the datadryad data publication.
This vignette demonstrates how to obtain the MERFISH mouse hypothalamic preoptic region dataset from Moffitt et al., 2018 from Bioconductor’s ExperimentHub.
eh <- ExperimentHub()
AnnotationHub::query(eh, c("MerfishData", "hypothalamus"))
#> ExperimentHub with 2 records
#> # snapshotDate(): 2024-10-24
#> # $dataprovider: Howard Hughes Medical Institute
#> # $species: Mus musculus
#> # $rdataclass: data.frame
#> # additional mcols(): taxonomyid, genome, description,
#> # coordinate_1_based, maintainer, rdatadateadded, preparerclass, tags,
#> # rdatapath, sourceurl, sourcetype
#> # retrieve records with, e.g., 'object[["EH7546"]]'
#>
#> title
#> EH7546 | Mofitt2018_hypothalamus_segmentation
#> EH7553 | Mofitt2018_hypothalamus_molecules
Note: complementary scRNA-seq of ~31,000 cells dissociated and captured from the preoptic region of the hypothalamus from multiple male and female mice is available on GEO (GSE113576).
It is also possible to obtain the data in a SpatialExperiment, which integrates experimental data and cell metadata, and provides designated accessors for the spatial coordinates.
spe <- MouseHypothalamusMoffitt2018()
spe
#> class: SpatialExperiment
#> dim: 135 73642
#> metadata(0):
#> assays(2): exprs molecules
#> rownames(135): Ace2 Adora2a ... Ttn Ttyh2
#> rowData names(0):
#> colnames: NULL
#> colData names(6): cell_id sample_id ... cell_class neuron_cluster_id
#> reducedDimNames(0):
#> mainExpName: smFISH
#> altExpNames(2): Blank seqFISH
#> spatialCoords names(3) : x y z
#> imgData names(0):
Inspect the data components:
assay(spe)[1:5,1:5]
#> [,1] [,2] [,3] [,4] [,5]
#> Ace2 0.000000 0.0000000 0.000000 0.0000000 0.000000
#> Adora2a 1.638275 0.0000000 0.000000 0.0000000 0.000000
#> Aldh1l1 21.299750 1.5788733 2.701349 1.8451161 6.352415
#> Amigo2 0.000000 0.0000000 5.402654 0.9225604 0.000000
#> Ano3 1.638275 0.7894518 0.000000 0.0000000 0.000000
assay(spe, "molecules")["Aldh1l1",1]
#> SplitDataFrameList of length 1
#> $Aldh1l1
#> DataFrame with 13 rows and 3 columns
#> x y z
#> <numeric> <numeric> <numeric>
#> 1 -3213.17 2608.99 1.5
#> 2 -3211.52 2609.89 1.5
#> 3 -3208.59 2607.12 1.5
#> 4 -3216.04 2611.64 3.0
#> 5 -3208.68 2606.96 3.0
#> ... ... ... ...
#> 9 -3215.51 2611.82 6.0
#> 10 -3213.33 2606.30 6.0
#> 11 -3211.82 2606.43 6.0
#> 12 -3215.51 2611.82 7.5
#> 13 -3209.87 2607.32 9.0
colData(spe)
#> DataFrame with 73642 rows and 6 columns
#> cell_id sample_id sex behavior cell_class
#> <character> <character> <character> <character> <character>
#> 1 6749ccb4-2ed1-4029-9.. 1 Female Naive Astrocyte
#> 2 6cac74bd-4ea7-4701-8.. 1 Female Naive Inhibitory
#> 3 9f29bd57-16a5-4b26-b.. 1 Female Naive Inhibitory
#> 4 d7eb4e0b-276e-47e3-a.. 1 Female Naive Inhibitory
#> 5 54434f3a-eba9-4aec-a.. 1 Female Naive Inhibitory
#> ... ... ... ... ... ...
#> 73638 7d6f8abd-4529-44a9-b.. 1 Female Naive OD Mature 2
#> 73639 21d04afa-0699-4c35-8.. 1 Female Naive Ambiguous
#> 73640 9e7e7c84-7dcc-4eef-a.. 1 Female Naive OD Immature 1
#> 73641 6b666f81-7b73-4100-9.. 1 Female Naive OD Mature 2
#> 73642 fdcddd97-7701-462a-b.. 1 Female Naive OD Mature 2
#> neuron_cluster_id
#> <character>
#> 1 NA
#> 2 I-5
#> 3 I-6
#> 4 I-5
#> 5 I-9
#> ... ...
#> 73638 NA
#> 73639 NA
#> 73640 NA
#> 73641 NA
#> 73642 NA
head(spatialCoords(spe))
#> x y z
#> [1,] -893.6953 -906.7108 0.26
#> [2,] -890.0563 -893.4568 0.26
#> [3,] -891.7111 -882.0988 0.26
#> [4,] -885.9867 -759.2063 0.26
#> [5,] -884.8158 -906.4486 0.26
#> [6,] -885.5992 -772.0895 0.26
Def. Bregma: The bregma is the anatomical point on the skull at which the coronal suture is intersected perpendicularly by the sagittal suture. Used here as a reference point for the twelve 1.8- by 1.8-mm imaged slices along the z-axis.
The anterior position of the preoptic region is at Bregma +0.26.
table(spatialCoords(spe)[,"z"])
#>
#> -0.29 -0.24 -0.19 -0.14 -0.09 -0.04 0.01 0.06 0.11 0.16 0.21 0.26
#> 6508 6412 6507 6605 6184 6152 6110 6144 5796 6064 5576 5584
Cell type assignment:
table(spe$cell_class)
#>
#> Ambiguous Astrocyte Endothelial 1 Endothelial 2 Endothelial 3
#> 9269 8393 3799 581 1369
#> Ependymal Excitatory Inhibitory Microglia OD Immature 1
#> 1961 11757 24761 1472 2457
#> OD Immature 2 OD Mature 1 OD Mature 2 OD Mature 3 OD Mature 4
#> 91 952 5736 39 367
#> Pericytes
#> 638
Visualize cell centroids and annotated cell type labels as in Figure 3E of the paper for six different anterior-posterior positions from a single female mouse.
relz <- c(0.26, 0.16, 0.06, -0.04, -0.14, -0.24)
cdat <- data.frame(colData(spe), spatialCoords(spe))
cdat <- subset(cdat, cell_class != "Ambiguous")
cdat$cell_class <- sub(" [1-4]$", "", cdat$cell_class)
cdat <- subset(cdat, z %in% relz)
cdat$z <- as.character(cdat$z)
zum <- paste(0:5 * 100, "um")
names(zum) <- as.character(relz)
cdat$z <- unname(zum[cdat$z])
pal <- get_palette("simpsons", 9)
names(pal) <- c("Endothelial", "Excitatory", "OD Immature", "Astrocyte", "Mural",
"Microglia", "Ependymal", "Inhibitory", "OD Mature")
ggscatter(cdat, x = "x", y = "y", color = "cell_class", facet.by = "z",
shape = 20, size = 1, palette = pal) +
guides(color = guide_legend(override.aes = list(size = 3)))
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
The MERFISH mouse hypothalamus dataset is part of the gallery of publicly available MERFISH datasets.
This gallery consists of dedicated iSEE and Vitessce instances, published on Posit Connect, that enable the interactive exploration of different segmentations, the expression of marker genes, and overlay of cell metadata on a spatial grid or a microscopy image.
sessionInfo()
#> R Under development (unstable) (2024-10-21 r87258)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.1 LTS
#>
#> Matrix products: default
#> BLAS: /home/biocbuild/bbs-3.21-bioc/R/lib/libRblas.so
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_GB 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/New_York
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats4 stats graphics grDevices utils datasets methods
#> [8] base
#>
#> other attached packages:
#> [1] ggpubr_0.6.0 rhdf5_2.51.0
#> [3] terra_1.7-83 scater_1.35.0
#> [5] scuttle_1.17.0 ggplot2_3.5.1
#> [7] ExperimentHub_2.15.0 AnnotationHub_3.15.0
#> [9] BiocFileCache_2.15.0 dbplyr_2.5.0
#> [11] MerfishData_1.9.0 SpatialExperiment_1.17.0
#> [13] SingleCellExperiment_1.29.0 SummarizedExperiment_1.37.0
#> [15] Biobase_2.67.0 GenomicRanges_1.59.0
#> [17] GenomeInfoDb_1.43.0 IRanges_2.41.0
#> [19] S4Vectors_0.45.0 BiocGenerics_0.53.1
#> [21] generics_0.1.3 MatrixGenerics_1.19.0
#> [23] matrixStats_1.4.1 EBImage_4.49.0
#> [25] BiocStyle_2.35.0
#>
#> loaded via a namespace (and not attached):
#> [1] jsonlite_1.8.9 magrittr_2.0.3 ggbeeswarm_0.7.2
#> [4] magick_2.8.5 farver_2.1.2 rmarkdown_2.29
#> [7] zlibbioc_1.53.0 vctrs_0.6.5 memoise_2.0.1
#> [10] RCurl_1.98-1.16 rstatix_0.7.2 htmltools_0.5.8.1
#> [13] S4Arrays_1.7.1 curl_5.2.3 BiocNeighbors_2.1.0
#> [16] broom_1.0.7 Rhdf5lib_1.29.0 Formula_1.2-5
#> [19] SparseArray_1.7.0 sass_0.4.9 bslib_0.8.0
#> [22] htmlwidgets_1.6.4 cachem_1.1.0 mime_0.12
#> [25] lifecycle_1.0.4 pkgconfig_2.0.3 rsvd_1.0.5
#> [28] Matrix_1.7-1 R6_2.5.1 fastmap_1.2.0
#> [31] GenomeInfoDbData_1.2.13 digest_0.6.37 colorspace_2.1-1
#> [34] AnnotationDbi_1.69.0 irlba_2.3.5.1 RSQLite_2.3.7
#> [37] beachmat_2.23.0 filelock_1.0.3 labeling_0.4.3
#> [40] fansi_1.0.6 httr_1.4.7 abind_1.4-8
#> [43] compiler_4.5.0 bit64_4.5.2 withr_3.0.2
#> [46] backports_1.5.0 tiff_0.1-12 BiocParallel_1.41.0
#> [49] carData_3.0-5 viridis_0.6.5 DBI_1.2.3
#> [52] highr_0.11 HDF5Array_1.35.1 ggsignif_0.6.4
#> [55] rappdirs_0.3.3 DelayedArray_0.33.1 rjson_0.2.23
#> [58] ggsci_3.2.0 tools_4.5.0 vipor_0.4.7
#> [61] beeswarm_0.4.0 glue_1.8.0 rhdf5filters_1.19.0
#> [64] grid_4.5.0 gtable_0.3.6 tidyr_1.3.1
#> [67] BiocSingular_1.23.0 ScaledMatrix_1.15.0 car_3.1-3
#> [70] utf8_1.2.4 XVector_0.47.0 ggrepel_0.9.6
#> [73] BiocVersion_3.21.1 pillar_1.9.0 BumpyMatrix_1.15.0
#> [76] dplyr_1.1.4 lattice_0.22-6 bit_4.5.0
#> [79] tidyselect_1.2.1 locfit_1.5-9.10 Biostrings_2.75.0
#> [82] knitr_1.48 gridExtra_2.3 bookdown_0.41
#> [85] scattermore_1.2 xfun_0.49 UCSC.utils_1.3.0
#> [88] fftwtools_0.9-11 yaml_2.3.10 evaluate_1.0.1
#> [91] codetools_0.2-20 tibble_3.2.1 BiocManager_1.30.25
#> [94] cli_3.6.3 munsell_0.5.1 jquerylib_0.1.4
#> [97] Rcpp_1.0.13-1 png_0.1-8 parallel_4.5.0
#> [100] blob_1.2.4 jpeg_0.1-10 bitops_1.0-9
#> [103] viridisLite_0.4.2 scales_1.3.0 purrr_1.0.2
#> [106] crayon_1.5.3 rlang_1.1.4 cowplot_1.1.3
#> [109] KEGGREST_1.47.0