require(knitr) opts_chunk$set(error=FALSE, message=FALSE, warning=FALSE)
BiocStyle::markdown()
The r Biocpkg("TENxPBMCData")
package provides a R /
Bioconductor resource for representing and manipulating nine different single-cell RNA-seq (scRNA-seq) and CITE-seq data sets on peripheral blood mononuclear cells (PBMC) generated by 10X Genomics:
The number in the dataset
title is roughly the number of cells in the experiment.
This package makes extensive use of the r Biocpkg("HDF5Array")
package
to avoid loading the entire data set in memory, instead storing
the counts on disk as a HDF5 file and loading subsets of the
data into memory upon request.
Note: The purpose of this package is to provide testing and example data for Bioconductor packages. We have done no processing of the "filtered" 10X scRNA-RNA or CITE-seq data; it is delivered as is.
We use the TENxPBMCData
function to download the relevant files
from Bioconductor's ExperimentHub web resource. This includes the
HDF5 file containing the counts, as well as the metadata on the rows
(genes) and columns (cells). The output is a single
SingleCellExperiment
object from the r Biocpkg("SingleCellExperiment")
package. This is equivalent to a SummarizedExperiment
class but
with a number of features specific to single-cell data.
library(TENxPBMCData) tenx_pbmc4k <- TENxPBMCData(dataset = "pbmc4k") tenx_pbmc4k
Note: of particular interest to some users might be the pbmc68k
dataset for its size.
The first call to TENxPBMCData()
may take some time due to the
need to download some moderately large files. The files are then
stored locally such that ensuing calls in the same or new sessions are
fast. Use the dataset
argument to select which dataset to download; values are visible through the function definition:
args(TENxPBMCData)
The count matrix itself is represented as a DelayedMatrix
from the
r Biocpkg("DelayedArray")
package. This wraps the underlying HDF5
file in a container that can be manipulated in R. Each count
represents the number of unique molecular identifiers (UMIs) assigned
to a particular gene in a particular cell.
counts(tenx_pbmc4k)
To quickly explore the data set, we compute some summary statistics on
the count matrix. We tell the r Biocpkg("DelayedArray")
block
size to indicate that we can use up to 1 GB of memory for loading the
data into memory from disk.
options(DelayedArray.block.size=1e9)
We are interested in library sizes colSums(counts(tenx_pbmc4k))
, number of
genes expressed per cell colSums(counts(tenx_pbmc4k) != 0)
, and average
expression across cells rowMeans(counts(tenx_pbmc4k))
. A naive implement
might be
lib.sizes <- colSums(counts(tenx_pbmc4k)) n.exprs <- colSums(counts(tenx_pbmc4k) != 0L) ave.exprs <- rowMeans(counts(tenx_pbmc4k))
More advanced analysis procedures are implemented in various
Bioconductor packages - see the SingleCell
biocViews for more
details.
Saving the tenx_pbmc4k
object in a standard manner, e.g.,
destination <- tempfile() saveRDS(tenx_pbmc4k, file = destination)
saves the row-, column-, and meta-data as an R object, and remembers
the location and subset of the HDF5 file from which the object is
derived. The object can be read into a new R session with
readRDS(destination)
, provided the HDF5 file remains in it's
original location.
For CITE-seq datasets, both the transcriptomics data and the antibody capture
data are available from a single SingleCellExperiment
object. While the
transcriptomics data can be accessed directly as described above, the antibody
capture data should be accessed with the altExp
function. Again, the resulting
count matrix is represented as a DelayedMatrix
.
tenx_pbmc5k_CITEseq <- TENxPBMCData(dataset = "pbmc5k-CITEseq") counts(altExp(tenx_pbmc5k_CITEseq))
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.