1 Introduction

The TENxPBMCData package provides a R / Bioconductor resource for representing and manipulating nine different single-cell RNA-seq (scRNA-seq) data sets on peripheral blood mononuclear cells (PBMC) generated by 10X Genomics:

  1. pbmc68k
  2. frozen_pbmc_donor_a
  3. frozen_pbmc_donor_b
  4. frozen_pbmc_donor_c
  5. pbmc33k
  6. pbmc3k
  7. pbmc6k
  8. pbmc4k
  9. pbmc8k

The number in the dataset title is roughly the number of cells in the experiment.

This package makes extensive use of the 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 data; it is delivered as is.

2 Work flow

2.1 Loading the data

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 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
## class: SingleCellExperiment 
## dim: 33694 4340 
## metadata(0):
## assays(1): counts
## rownames(33694): ENSG00000243485 ENSG00000237613 ... ENSG00000277475
##   ENSG00000268674
## rowData names(3): ENSEMBL_ID Symbol_TENx Symbol
## colnames: NULL
## colData names(11): Sample Barcode ... Individual Date_published
## reducedDimNames(0):
## spikeNames(0):
## altExpNames(0):

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)
## function (dataset = c("pbmc4k", "pbmc4k", "pbmc68k", "frozen_pbmc_donor_a", 
##     "frozen_pbmc_donor_b", "frozen_pbmc_donor_c", "pbmc33k", 
##     "pbmc3k", "pbmc6k", "pbmc4k", "pbmc8k")) 
## NULL

The count matrix itself is represented as a DelayedMatrix from the 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)
## <33694 x 4340> matrix of class DelayedMatrix and type "integer":
##                    [,1]    [,2]    [,3]    [,4] ... [,4337] [,4338] [,4339]
## ENSG00000243485       0       0       0       0   .       0       0       0
## ENSG00000237613       0       0       0       0   .       0       0       0
## ENSG00000186092       0       0       0       0   .       0       0       0
## ENSG00000238009       0       0       0       0   .       0       0       0
## ENSG00000239945       0       0       0       0   .       0       0       0
##             ...       .       .       .       .   .       .       .       .
## ENSG00000277856       0       0       0       0   .       0       0       0
## ENSG00000275063       0       0       0       0   .       0       0       0
## ENSG00000271254       0       0       0       0   .       0       0       0
## ENSG00000277475       0       0       0       0   .       0       0       0
## ENSG00000268674       0       0       0       0   .       0       0       0
##                 [,4340]
## ENSG00000243485       0
## ENSG00000237613       0
## ENSG00000186092       0
## ENSG00000238009       0
## ENSG00000239945       0
##             ...       .
## ENSG00000277856       0
## ENSG00000275063       0
## ENSG00000271254       0
## ENSG00000277475       0
## ENSG00000268674       0

2.2 Exploring the data

To quickly explore the data set, we compute some summary statistics on the count matrix. We tell the 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.

2.3 Saving computations

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.

3 Session information

sessionInfo()
## R version 3.6.1 (2019-07-05)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.10-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.10-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] TENxPBMCData_1.4.0          HDF5Array_1.14.0           
##  [3] rhdf5_2.30.0                SingleCellExperiment_1.8.0 
##  [5] SummarizedExperiment_1.16.0 DelayedArray_0.12.0        
##  [7] BiocParallel_1.20.0         matrixStats_0.55.0         
##  [9] Biobase_2.46.0              GenomicRanges_1.38.0       
## [11] GenomeInfoDb_1.22.0         IRanges_2.20.0             
## [13] S4Vectors_0.24.0            BiocGenerics_0.32.0        
## [15] knitr_1.25                  BiocStyle_2.14.0           
## 
## loaded via a namespace (and not attached):
##  [1] httr_1.4.1                    bit64_0.9-7                  
##  [3] AnnotationHub_2.18.0          shiny_1.4.0                  
##  [5] assertthat_0.2.1              interactiveDisplayBase_1.24.0
##  [7] BiocManager_1.30.9            BiocFileCache_1.10.0         
##  [9] blob_1.2.0                    GenomeInfoDbData_1.2.2       
## [11] yaml_2.2.0                    BiocVersion_3.10.1           
## [13] pillar_1.4.2                  RSQLite_2.1.2                
## [15] backports_1.1.5               lattice_0.20-38              
## [17] glue_1.3.1                    digest_0.6.22                
## [19] promises_1.1.0                XVector_0.26.0               
## [21] htmltools_0.4.0               httpuv_1.5.2                 
## [23] Matrix_1.2-17                 pkgconfig_2.0.3              
## [25] bookdown_0.14                 zlibbioc_1.32.0              
## [27] purrr_0.3.3                   xtable_1.8-4                 
## [29] later_1.0.0                   tibble_2.1.3                 
## [31] magrittr_1.5                  crayon_1.3.4                 
## [33] mime_0.7                      memoise_1.1.0                
## [35] evaluate_0.14                 tools_3.6.1                  
## [37] stringr_1.4.0                 Rhdf5lib_1.8.0               
## [39] AnnotationDbi_1.48.0          compiler_3.6.1               
## [41] rlang_0.4.1                   grid_3.6.1                   
## [43] RCurl_1.95-4.12               rappdirs_0.3.1               
## [45] bitops_1.0-6                  rmarkdown_1.16               
## [47] ExperimentHub_1.12.0          DBI_1.0.0                    
## [49] curl_4.2                      R6_2.4.0                     
## [51] dplyr_0.8.3                   fastmap_1.0.1                
## [53] bit_1.1-14                    zeallot_0.1.0                
## [55] stringi_1.4.3                 Rcpp_1.0.2                   
## [57] vctrs_0.2.0                   dbplyr_1.4.2                 
## [59] tidyselect_0.2.5              xfun_0.10