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 the mouse retina from @macosko2015highly. Counts for endogenous genes and spike-in transcripts are available from the Gene Expression Omnibus using the accession number GSE63472. We download and cache them using the r Biocpkg("BiocFileCache") package.

library(BiocFileCache)
bfc <- BiocFileCache("raw_data", ask = FALSE)
base.url <- file.path("ftp://ftp.ncbi.nlm.nih.gov/geo/series",
    "GSE63nnn/GSE63472/suppl")
count.file <- bfcrpath(bfc, file.path(base.url,
    "GSE63472_P14Retina_merged_digital_expression.txt.gz"))

We load them into memory.

library(scater)
counts <- readSparseCounts(count.file)
dim(counts)

Downloading the per-cell metadata

We also download a file containing the metadata for each cell.

meta.file <- bfcrpath(bfc, file.path("http://mccarrolllab.com",
    "wp-content/uploads/2015/05/retina_clusteridentities.txt"))
coldata <- read.delim(meta.file, stringsAsFactors=FALSE, header=FALSE)
colnames(coldata) <- c("cell.id", "cluster")

library(S4Vectors)
coldata <- as(coldata, "DataFrame")
coldata

We match the metadata to the columns.

m <- match(colnames(counts), coldata$cell.id)
coldata <- coldata[m,]
coldata$cell.id <- colnames(counts)
summary(is.na(m))

Saving to file

We now save all of the components to file for upload to r Biocpkg("ExperimentHub"). These will be used to construct a SingleCellExperiment on the client side when the dataset is requested.

path <- file.path("scRNAseq", "macosko-retina", "2.0.0")
dir.create(path, showWarnings=FALSE, recursive=TRUE)
saveRDS(counts, file=file.path(path, "counts.rds"))
saveRDS(coldata, file=file.path(path, "coldata.rds"))

Session information

sessionInfo()

References



drisso/scRNAseq documentation built on Feb. 16, 2021, 1:18 a.m.