---
title: Processing the Grun pancreas dataset
author: Aaron Lun
date: 28 June 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 count data

We obtain a single-cell RNA sequencing dataset of human pancreas from @grun2016denovo.
A count matrix for endogenous genes and spike-ins is provided from the Gene Expression Omnibus 
using accession code [GSE81076](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE81076).
We download it using `r Biocpkg("BiocFileCache")` to cache the results:

```{r}
library(BiocFileCache)
bfc <- BiocFileCache("raw_data", ask=FALSE)
grun.fname <- bfcrpath(bfc, file.path("ftp://ftp.ncbi.nlm.nih.gov/geo/series",
    "GSE81nnn/GSE81076/suppl/GSE81076%5FD2%5F3%5F7%5F10%5F17%2Etxt%2Egz"))
```

We read the table into memory as a sparse matrix.

```{r}
library(scater)
counts <- readSparseCounts(grun.fname, quote="\"")
dim(counts)
```

# Saving to file

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

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

# Session information

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

# References
