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 brain from @chen2017singlecell. Counts for endogenous genes are available from the Gene Expression Omnibus using the accession number GSE87544. 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",
    "GSE87nnn/GSE87544/suppl")
count.file <- bfcrpath(bfc, file.path(base.url,
    "GSE87544_Merged_17samples_14437cells_count.txt.gz"))

Reading them in as a sparse matrix.

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

Downloading the metadata

We also download the cluster identities.

cluster.file <- bfcrpath(bfc, file.path(base.url,
    "GSE87544_1443737Cells.SVM.cluster.identity.renamed.csv.gz"))
coldata <- read.csv(cluster.file, stringsAsFactors=FALSE, row.names=1)
coldata <- as(coldata, "DataFrame")
coldata

We check that the columns are in the same order.

m <- match(colnames(counts), rownames(coldata))
coldata <- coldata[m,]
stopifnot(identical(colnames(counts), rownames(coldata)))

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", "chen-brain", "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.