library(BiocStyle) knitr::opts_chunk$set(error=FALSE, message=FALSE, warning=FALSE)
We obtain a single-cell RNA sequencing dataset of the human cotex from @nowakowski2017spatiotemporal.
TPMs for endogenous genes are available from the the UCSC cell browser at http://cells.ucsc.edu/?ds=cortex-dev.
We download and cache them using the r Biocpkg("BiocFileCache")
package.
library(BiocFileCache) bfc <- BiocFileCache("raw_data", ask = FALSE) exprs.path <- bfcrpath(bfc, "http://cells.ucsc.edu/cortex-dev/exprMatrix.tsv.gz") library(scuttle) mat <- readSparseCounts(exprs.path, row.names=1) dim(mat)
We also read in various pieces of metadata; firstly, the per-cell metadata.
meta.path <- bfcrpath(bfc, "http://cells.ucsc.edu/cortex-dev/meta.tsv") meta <- read.delim(meta.path, row.names=1) stopifnot(identical(colnames(mat), rownames(meta))) meta <- DataFrame(meta) meta
And then all of the various reduced dimensions:
red.dim.list <- c( "tMinusSNE_on_WGCNA", "TriMap", "TMinusSNE_scanpy", "UMAP_scanpy", "PAGAPlusForceAtlas2_scanpy" ) reddims <- list() for (i in red.dim.list) { X <- bfcrpath(bfc, sprintf("http://cells.ucsc.edu/cortex-dev/%s.coords.tsv.gz", i)) Y <- as.matrix(read.table(X, row.names=1, sep="\t")) stopifnot(all(rownames(Y) %in% colnames(mat))) expanded <- Y[match(colnames(mat), rownames(Y)),,drop=FALSE] rownames(expanded) <- colnames(mat) stopifnot(identical(colnames(expanded), c("V2", "V3"))) colnames(expanded) <- NULL reddims[[i]] <- expanded }
Making sure we can assemble the final SCE:
sce <- SingleCellExperiment(list(tpm=mat), colData=meta, reducedDims=reddims) sce
We now save all of the relevant components to file for upload to r Biocpkg("ExperimentHub")
.
path <- file.path("scRNAseq", "nowakowski-cortex", "2.6.0") dir.create(path, showWarnings=FALSE, recursive=TRUE) saveRDS(mat, file=file.path(path, "tpm.rds")) saveRDS(meta, file=file.path(path, "coldata.rds")) saveRDS(reddims, file=file.path(path, "reddims.rds"))
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.