---
title: Processing the Grun HSC dataset
author: Aaron Lun
date: 18 May 2019
output:
  BiocStyle::html_document:
    titlecaps: false
    toc_float: true
bibliography: ../ref.bib
---

```{r style, echo=FALSE, results='hide', message=FALSE}
library(BiocStyle)
knitr::opts_chunk$set(error=FALSE, message=FALSE, warning=FALSE)
```

# Downloading the data

We obtain a single-cell RNA sequencing dataset of the mouse haematopoietic stem cells from @grun2016denovo.
Counts for endogenous genes are available from the Gene Expression Omnibus
using the accession number [GSE76983](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE76983).
We download and cache them using the `r Biocpkg("BiocFileCache")` package.

```{r}
library(BiocFileCache)
bfc <- BiocFileCache("raw_data", ask = FALSE)
count.file <- bfcrpath(bfc, file.path("ftp://ftp.ncbi.nlm.nih.gov/geo/series",
    "GSE76nnn/GSE76983/suppl/GSE76983_expdata_BMJhscC.csv.gz"))
```

We read this into memory as a sparse matrix.

```{r}
library(scater)
counts <- readSparseCounts(count.file)
dim(counts)
```

# Saving to file 

We save the relevant components to file for upload to `r Biocpkg("ExperimentHub")`.

```{r}
path <- file.path("scRNAseq", "grun-hsc", "2.0.0")
dir.create(path, showWarnings=FALSE, recursive=TRUE)
saveRDS(counts, file=file.path(path, "counts.rds"))
```

# Session information

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

# References
