---
title: "STexampleData package overview"
author: 
  - name: Lukas M. Weber
    affiliation: "Johns Hopkins Bloomberg School of Public Health, Baltimore, MD, USA"
package: STexampleData
output: 
  BiocStyle::html_document
vignette: >
  %\VignetteIndexEntry{STexampleData package overview}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


# Introduction

The `STexampleData` package provides access to a collection of spatially resolved transcriptomics datasets, which have been formatted into the [SpatialExperiment](https://bioconductor.org/packages/SpatialExperiment) Bioconductor object class.

These datasets have been collected from various publicly available sources, and cover several technological platforms. We provide them in the form of `SpatialExperiment` objects to make them easier to access, so that we and others can use them for examples, demonstrations, tutorials, and other purposes.

The `SpatialExperiment` class is an extension of `SingleCellExperiment`, adapted for the properties of spatially resolved transcriptomics data. For more details, see the `SpatialExperiment` documentation.

Note that objects in Bioconductor version 3.13 have names ending with `_3_13`, and have been kept for backward compatibility. The latest versions of the objects are available in Bioconductor version 3.14 onwards.


# Installation

To install the `STexampleData` package from Bioconductor:

```{r, eval=FALSE}
install.packages("BiocManager")
BiocManager::install("STexampleData")
```


# Datasets

The package contains the following datasets:

- `Visium_humanDLPFC` (10x Genomics Visium): A single sample (sample 151673) of human brain dorsolateral prefrontal cortex (DLPFC) in the human brain, measured using the 10x Genomics Visium platform. This is a subset of the full dataset containing 12 samples from 3 neurotypical donors, published by [Maynard and Collado-Torres et al. (2021)](https://www.nature.com/articles/s41593-020-00787-0). The full dataset is available from the [spatialLIBD](http://bioconductor.org/packages/spatialLIBD) Bioconductor package.

- `Visium_mouseCoronal` (10x Genomics Visium): A single coronal section from the mouse brain, spanning one hemisphere. This dataset was previously released by 10x Genomics on their [website](https://support.10xgenomics.com/spatial-gene-expression/datasets/1.1.0/V1_Adult_Mouse_Brain).

- `seqFISH_mouseEmbryo` (seqFISH): A subset of cells (embryo 1, z-slice 2) from a previously published dataset investigating mouse embryogenesis by [Lohoff and Ghazanfar et al. (2020)](https://www.biorxiv.org/content/10.1101/2020.11.20.391896v1), generated using the seqFISH platform. The full dataset is [available online](https://marionilab.cruk.cam.ac.uk/SpatialMouseAtlas/).


# Load data

The following examples show how to load the example datasets as `SpatialExperiment` objects in an R session.


## Access ExperimentHub

```{r, message=FALSE}
library(ExperimentHub)
```

```{r}
# create ExperimentHub instance
eh <- ExperimentHub()

# query STexampleData datasets
myfiles <- query(eh, "STexampleData")
myfiles

# metadata
md <- as.data.frame(mcols(myfiles))
```


## Visium_humanDLPFC

```{r, message=FALSE}
library(STexampleData)
library(SpatialExperiment)
```

```{r}
# load object
spe <- Visium_humanDLPFC_3_13()
# alternatively: using ExperimentHub query
# spe <- myfiles[[1]]
# alternatively: using ExperimentHub ID
# spe <- myfiles[["EH5443"]]

# check object
spe
dim(spe)
assayNames(spe)
rowData(spe)
colData(spe)
spatialData(spe)
head(spatialCoords(spe))
imgData(spe)
```


## Visium_mouseCoronal

```{r, message=FALSE}
# load object
spe <- Visium_mouseCoronal_3_13()
# alternatively: using ExperimentHub query
# spe <- myfiles[[2]]
# alternatively: using ExperimentHub ID
# spe <- myfiles[["EH5444"]]

# check object
spe
```


## seqFISH_mouseEmbryo

```{r, message=FALSE}
# load object
spe <- seqFISH_mouseEmbryo_3_13()
# alternatively: using ExperimentHub query
# spe <- myfiles[[3]]
# alternatively: using ExperimentHub ID
# spe <- myfiles[["EH5445"]]

# check object
spe
```


# Generating objects from raw data files

For reference, we include code scripts to generate the `SpatialExperiment` objects from the raw data files.

These scripts are saved in `/inst/scripts/` in the source code of the `STexampleData` package. The scripts include references and links to the raw data files from the original sources for each dataset.


# Session information

```{r}
sessionInfo()
```


