---
title: "Tabula Muris data"
author: "Charlotte Soneson"
package: TabulaMurisData
output: 
    BiocStyle::html_document
vignette: >
    %\VignetteIndexEntry{Tabula Muris data}
    %\VignetteEngine{knitr::rmarkdown}
    %\VignetteEncoding{UTF-8}
---

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

# Load Tabula Muris data

The `TabulaMurisData` data package provides access to the 10x and SmartSeq2
single-cell RNA-seq data sets from 
[the Tabula Muris Consortium](http://tabula-muris.ds.czbiohub.org/). 
The contents of the package can be seen by querying the ExperimentHub for the
package name.

```{r}
suppressPackageStartupMessages({
    library(ExperimentHub)
    library(SingleCellExperiment)
    library(TabulaMurisData)
})

eh <- ExperimentHub()
query(eh, "TabulaMurisData")
```

The individual data sets can be accessed using either their ExperimentHub
accession number, or the convenience functions provided in this package. For
example, for the 10x data:

```{r}
droplet <- eh[["EH1617"]]
droplet
droplet <- TabulaMurisDroplet()
droplet
```

# Explore data with `iSEE`

Each data set is provided in the form of a `SingleCellExperiment` object. To
gain further insights into the contents of the data sets, they can be explored
using, e.g., the `r Biocpkg("iSEE")` package. For the purposes of this vignette,
we first subsample a small subset of the cells in the 10x data set, to reduce
the run time.

```{r}
set.seed(1234)
se <- droplet[, sample(seq_len(ncol(droplet)), 250, replace = FALSE)]
se
```

Next, we calculate size factors and normalize the data using the 
`r Biocpkg("scran")`, `r Biocpkg("scrapper")` and `r Biocpkg("scater")` 
packages, and  perform dimension reduction using PCA and t-SNE.

```{r}
se <- scran::computeSumFactors(se)
se <- scrapper::normalizeRnaCounts.se(se)
se <- scater::runPCA(se)
se <- scater::runTSNE(se)
```

Finally, we call `iSEE` with the subsampled `SingleCellExperiment` object. This
opens up an instance of `iSEE` containing the provided data set.

```{r, eval=FALSE}
if (require(iSEE)) {
    iSEE(se)
}
```

# Session info

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

