---
title: "Introduction to humanHippocampus2024"
author: 
  - name: Christine Hou
    affiliation:
    - Department of Biostatistics, Johns Hopkins University
    email: chris2018hou@gmail.com
output: 
  BiocStyle::html_document:
    self_contained: yes
    toc: true
    toc_float: true
    toc_depth: 2
    code_folding: show
date: "`r doc_date()`"
package: "`r pkg_ver('humanHippocampus2024')`"
vignette: >
  %\VignetteIndexEntry{humanHippocampus2024 Tutorial}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}  
---

```{r, include = FALSE}
knitr::opts_chunk$set(
    collapse = TRUE,
    comment = "#>"
)
```

### Introduction

Welcome to the `humanHippocampus2024` package! In this vignettes, we are going
to show how to access the spatially-resolved transcriptomics (SRT) and
single-nucleus RNA-sequencing (snRNA-seq) data from adjacent tissue sections of
the anterior human hippocampus across ten adult neurotypical donors generated
by Lieber Institute for Brain Development (LIBD) researchers and collaborators.

### Motivation

The main purpose to create R/Bioconductor package was to access the SRT and
snRNA-seq data from `spatial_HPC` project via an open-source and public
interface such that the data can be referenced or analyzed in other projects
conveniently.

### Study Design

<figure>
<img src="../man/figures/study_design.png" align="center" width="800px"/>
</figure>

Experimental design to generate paired single-nucleus RNA-sequencing
(snRNA-seq) and spatially-resolved transcriptomics (SRT) data in the human
hippocampus. (A) Postmortem human tissue blocks from the anterior hippocampus
were dissected from 10 adult neurotypical brain donors. Tissue blocks were
scored and cryosectioned for snRNA-seq assays (red), and placement on Visium
slides (Visium H&E, black; Visium Spatial Proteogenomics (SPG), yellow). (B)
10$\mu$m tissue sections from all ten donors were placed onto 2-5 capture areas
to include the extent of the HPC(n=36 total capture areas), for measurement
with the 10x Genomics Visium H&E platform. (C) 10$\mu$m tissue sections from
two donors were placed onto 4 capture areas (n=8 total capture areas) for
measurement with the 10x Genomics Visium-SPG platform. (D) Tissue sections (2-4
100$\mu$m cryosections per assay) from all ten donors were collected from the
same tissue blocks for measurement with the 10x Genomics 3’ gene expression
platform. For each donor, we sorted on both and PI+NeuN+ (n=26 total snRNA-seq
libraries). (This figure was created with
[Biorender](https://www.biorender.com/))

#### Data Access

All data, including raw FASTQ files and SpaceRanger/CellRanger processed data
outputs, can be accessed via Gene Expression Omnibus (GEO) under accessions
[GSE264692](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE264692) (SRT)
and [GSE264624](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE264624)
(snRNA-seq).

All R scripts created to perform analyses can be found
[here](https://github.com/LieberInstitute/spatial_hpc).

#### Contact

We value public questions, as they allow other users to learn from the answers.
If you have any questions, please ask them at
[LieberInstitute/spatial_hpc/issues](https://github.com/LieberInstitute/spatia
l_hpc/issues) 
and refrain from emailing us. Thank you again for your interest in our work!

### Package Tutorial

#### Installation

`humanHippocampus2024` is an R package available via
[Bioconductor](http://bioconductor.org/) repository for packages. GitHub
repository can be found
[here](https://github.com/christinehou11/humanHippocampus2024).

Bioconductor version of 3.20 on R version of 4.4 is required.

```{r install, eval=FALSE}
if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("humanHippocampus2024")

## Check that you have a valid Bioconductor installation
BiocManager::valid()
```

### *humanHippocampus2024* datasets

#### Load the packages

```{r prep,message=FALSE, warning=FALSE}
library(SummarizedExperiment)
library(SpatialExperiment)
library(humanHippocampus2024)
```

#### Download datasets

```{r connect}
## Connect to ExperimentHub
library(ExperimentHub)
ehub <- ExperimentHub()

## Load the datasets of the package
myfiles <- query(ehub, "humanHippocampus2024")

## Resulting humanHippocampus2024 datasets from ExperimentHub query
myfiles
```

#### SRT dataset

SRT data in SpatialExperiment (spe) class was generated using 10x Genomics
Visium (https://www.10xgenomics.com/products/spatial-gene-expression) 
(n=36 capture areas) and 10x Genomics Visium Spatial Proteogenomics (SPG)
(https://www.10xgenomics.com/products/spatial-gene-and-protein-expression)
(n=8 capture areas).

```{r spe}
######################
#     spe data 
######################

# Downloading spatially-resolved transcriptomics data
# EH9605 | spe 
spatial_hpc_spe <- myfiles[["EH9605"]]

# This is a SpatialExperiment object
spatial_hpc_spe

# Check sample info
head(colData(spatial_hpc_spe), 3)

# Check gene info
head(rowData(spatial_hpc_spe), 3)

# Access the original counts
assays(spatial_hpc_spe)$counts[1:3, 1:3]

# Access the log-normalized counts
assays(spatial_hpc_spe)$logcounts[1:3, 1:3]

# Access the reduced dimension methods
reducedDimNames(spatial_hpc_spe)

# Access the spatial coordinates
spatialCoordsNames(spatial_hpc_spe)

rm(spatial_hpc_spe)
```

#### snRNA-seq dataset

snRNA-seq data in SingleCellExperiment (sce) class was generated using 
10x Genomics Chromium
(https://www.10xgenomics.com/products/single-cell-gene-expression) 
(n=26 total snRNA-seq libraries).

```{r sce}
######################
#     sce data 
######################

# Downloading single-nucleus RNA sequencing data
# EH9606 | sce
spatial_hpc_snrna_seq <- myfiles[["EH9606"]]

# This is a SingleCellExperiment object
spatial_hpc_snrna_seq

# Check sample info
head(colData(spatial_hpc_snrna_seq),3)

# Check gene info
head(rowData(spatial_hpc_snrna_seq), 3)

# Access the original counts
assays(spatial_hpc_snrna_seq)$counts[1:3, 1:3]

# Access the log-normalized counts
assays(spatial_hpc_snrna_seq)$logcounts[1:3, 1:3]

# Access the reduced dimension methods
reducedDimNames(spatial_hpc_snrna_seq)
```

### Citation

```{r citation}
citation("humanHippocampus2024")
```

### Reproducibility

```{r bib, echo=FALSE}
library("RefManageR")

bib <- c(
    R = citation(),
    AnnotationHubData = citation("AnnotationHubData")[1],
    ExperimentHub = citation("ExperimentHub")[1],
    BiocStyle = citation("BiocStyle")[1],
    knitr = citation("knitr")[1],
    RefManageR = citation("RefManageR")[1],
    rmarkdown = citation("rmarkdown")[1],
    sessioninfo = citation("sessioninfo")[1],
    testthat = citation("testthat")[1]
)
```

This package was developed using `r BiocStyle::Biocpkg("biocthis")`

Date the vignette was generated.

```{r time, echo=FALSE}
Sys.time()
```

`R` session information

```{r 'sessionInfo', echo=FALSE}
# Session info
library(sessioninfo)
options(width = 120)
session_info()
```

### Bibliography

This vignette was generated using 
`r Biocpkg("BiocStyle")` `r Citep(bib[["BiocStyle"]])` with
`r CRANpkg("knitr")` `r Citep(bib[["knitr"]])` and 
`r CRANpkg("rmarkdown")` `r Citep(bib[["rmarkdown"]])` running behind the
scenes.

Citations made with `r CRANpkg("RefManageR")` `r Citep(bib[["RefManageR"]])`.

```{r, results = "asis", echo = FALSE, warning = FALSE, message = FALSE}
## Print bibliography
PrintBibliography(bib, .opts = list(hyperlink = "to.doc", style = "html"))
```
