HCAData 1.21.0
Compiled date: 2024-05-02
Last edited: 2019-05-24
License: MIT + file LICENSE
HCAData
packageThe HCAData package allows a direct access to the dataset generated by the Human Cell Atlas project for further processing in R and Bioconductor. It does so by providing the datasets as SingleCellExperiment objects, i.e. a format which is both efficient and very widely adopted throughout many existing Bioconductor workflows.
The datasets are otherwise available in other formats (also as raw data) at this link: http://preview.data.humancellatlas.org/.
HCAData
The HCAData package can be installed in the conventional way via BiocManager.
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("HCAData")
This package makes extensive use of the HDF5Array package to avoid loading the entire data set in memory. Instead, it stores the counts on disk as a HDF5 file, and loads subsets of the data into memory upon request.
HCAData
and the Human Cell Atlas datalibrary("HCAData")
We use the HCAData
function to download the relevant files from Bioconductor’s ExperimentHub web resource.
If no argument is provided, a list of the available datasets is returned, specifying which name to enter as dataset
parameter when calling HCAData
.
HCAData()
The list of relevant files 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.
Being based on ExperimentHub, the data related to this package can be accessed and queried directly using the package name. Retrieval is then as easy as using their ExperimentHub accession numbers (for the single components of each set), or by using the convenience function provided in this package.
suppressPackageStartupMessages({
library("ExperimentHub")
library("SingleCellExperiment")
})
eh <- ExperimentHub()
query(eh, "HCAData")
#> ExperimentHub with 6 records
#> # snapshotDate(): 2024-04-29
#> # $dataprovider: Human Cell Atlas
#> # $species: Homo sapiens
#> # $rdataclass: character
#> # additional mcols(): taxonomyid, genome, description,
#> # coordinate_1_based, maintainer, rdatadateadded, preparerclass, tags,
#> # rdatapath, sourceurl, sourcetype
#> # retrieve records with, e.g., 'object[["EH2047"]]'
#>
#> title
#> EH2047 | Human Cell Atlas - Census of Immune Cells, Bone marrow, 'dense m...
#> EH2048 | Human Cell Atlas - Census of Immune Cells, Bone marrow, sample (...
#> EH2049 | Human Cell Atlas - Census of Immune Cells, Bone marrow, gene (ro...
#> EH2050 | Human Cell Atlas - Census of Immune Cells, Umbilical cord blood,...
#> EH2051 | Human Cell Atlas - Census of Immune Cells, Umbilical cord blood,...
#> EH2052 | Human Cell Atlas - Census of Immune Cells, Umbilical cord blood,...
# these three are the components to the bone marrow dataset
bonemarrow_h5densematrix <- eh[["EH2047"]]
bonemarrow_coldata <- eh[["EH2048"]]
bonemarrow_rowdata <- eh[["EH2049"]]
# and are put together when calling...
sce_bonemarrow <- HCAData("ica_bone_marrow")
sce_bonemarrow
#> class: SingleCellExperiment
#> dim: 33694 378000
#> metadata(0):
#> assays(1): counts
#> rownames(33694): ENSG00000243485 ENSG00000237613 ... ENSG00000277475
#> ENSG00000268674
#> rowData names(2): ID Symbol
#> colnames(378000): MantonBM1_HiSeq_1-AAACCTGAGCAGGTCA-1
#> MantonBM1_HiSeq_1-AAACCTGCACACTGCG-1 ...
#> MantonBM8_HiSeq_8-TTTGTCATCTGCCAGG-1
#> MantonBM8_HiSeq_8-TTTGTCATCTTGAGAC-1
#> colData names(1): Barcode
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
# similarly, to access the umbilical cord blood dataset
sce_cordblood <- HCAData("ica_cord_blood")
sce_cordblood
#> class: SingleCellExperiment
#> dim: 33694 384000
#> metadata(0):
#> assays(1): counts
#> rownames(33694): ENSG00000243485 ENSG00000237613 ... ENSG00000277475
#> ENSG00000268674
#> rowData names(2): ID Symbol
#> colnames(384000): MantonCB1_HiSeq_1-AAACCTGAGGAGTTGC-1
#> MantonCB1_HiSeq_1-AAACCTGAGGCATTGG-1 ...
#> MantonCB8_HiSeq_8-TTTGTCATCCAGATCA-1
#> MantonCB8_HiSeq_8-TTTGTCATCGGTCTAA-1
#> colData names(1): Barcode
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):
iSEE
The datasets are provided in the form of a SingleCellExperiment
object.
A natural companion to this data structure is the iSEE package, which can be used for interactive and reproducible data exploration.
Any analysis steps should be performed in advance before calling iSEE
, and since these datasets can be quite big, the operations can be time consuming, and/or require a considerable amount of resources.
For the scope of the vignette, we subset some cells in the bone marrow dataset to reduce the runtime, and apply some of the steps one would ideally follow in analysing droplet based datasets. For more information on how to properly process such datasets, please refer to the amazing set of resources available in the simpleSingleCell workflow package.
In brief: we start loading the required libraries for preprocessing, and taking a subset of the bone marrow dataset
library("scran")
library("BiocSingular")
library("scater")
library("scuttle")
set.seed(42)
sce <- sce_bonemarrow[, sample(seq_len(ncol(sce_bonemarrow)), 1000, replace = FALSE)]
First, we relabel the rows with the gene symbols for easier reading with the uniquifyFeatureNames()
function from scater.
Then we compute some QC metrics and add these to the original sce
object, using addPerCellQC()
.
rownames(sce) <- uniquifyFeatureNames(rowData(sce)$ID, rowData(sce)$Symbol)
head(rownames(sce))
#> [1] "RP11-34P13.3" "FAM138A" "OR4F5" "RP11-34P13.7"
#> [5] "RP11-34P13.8" "RP11-34P13.14"
is.mito <- grep("MT-", rownames(sce))
counts(sce) <- as.matrix(counts(sce))
sce <- scuttle::addPerCellQC(sce, subsets=list(Mito=is.mito))
We proceed with normalization, performed with the deconvolution method implemented in scran - a pre-clustering step is done in advance, to avoid pooling cells that are very different between each other.
lib.sf.bonemarrow <- librarySizeFactors(sce)
summary(lib.sf.bonemarrow)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.0157 0.3407 0.6291 1.0000 0.9087 18.0304
set.seed(42)
clusters <- quickCluster(sce)
table(clusters)
#> clusters
#> 1 2 3 4 5
#> 137 232 207 239 185
sce <- computeSumFactors(sce, min.mean=0.1, cluster=clusters)
sce <- logNormCounts(sce)
assayNames(sce)
#> [1] "counts" "logcounts"
In the following lines of code, we model the mean-variance trend (with technical noise as Poisson), to extract the biological component of the variance for the genes under inspection.
dec.bonemarrow <- modelGeneVarByPoisson(sce)
top.dec <- dec.bonemarrow[order(dec.bonemarrow$bio, decreasing=TRUE),]
head(top.dec)
#> DataFrame with 6 rows and 6 columns
#> mean total tech bio p.value FDR
#> <numeric> <numeric> <numeric> <numeric> <numeric> <numeric>
#> S100A8 1.09003 5.19285 1.03231 4.16054 0 0
#> S100A9 1.08007 4.96772 1.02675 3.94097 0 0
#> MALAT1 7.23554 4.50786 0.69933 3.80853 0 0
#> LYZ 1.12696 4.79231 1.05247 3.73984 0 0
#> HBB 1.07098 4.35318 1.02161 3.33157 0 0
#> RPS27 4.96094 3.76764 1.22724 2.54039 0 0
fit.bonemarrow <- metadata(dec.bonemarrow)
plot(fit.bonemarrow$mean, fit.bonemarrow$var, xlab="Mean of log-expression",
ylab="Variance of log-expression", pch = 16)
curve(fit.bonemarrow$trend(x), col="dodgerblue", add=TRUE, lwd=2)
plotExpression(sce, features=rownames(top.dec)[1:10])