library(BiocStyle) knitr::opts_chunk$set(warning=FALSE, error=FALSE, message=FALSE)
LoomExperiment family of classes inherits from the main class
LoomExperiment as well as the Experiment class that they are named after. For example, the
SingleCellLoomExperiment class inherits from both
The purpose of the
LoomExperiment class is to act as an intermediary between Bioconductor's Experiment classes and the Linnarson Lab's Loom File Format (http://linnarssonlab.org/loompy/index.html). The Loom File Format uses HDF5 to store Experiment data.
LoomExperiment family of classes contain the following slots.
Both of these slots are
LoomGraphs objects that describe the
row_graph attributes as specified by the Loom File Format.
There are several ways to create instances of a
LoomExperiment class of object. One can plug an existing SummarizedExperiment type class into the appropriate constructor:
library(LoomExperiment) counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) sce <- SingleCellExperiment(assays = list(counts = counts)) scle <- SingleCellLoomExperiment(sce) ## OR scle <- LoomExperiment(sce)
One can also simply plug the arguments into the appropriate constructor, since all
LoomExperiment constructors call the applicable class's constructor
scle <- SingleCellLoomExperiment(assays = list(counts = counts))
Also, it is also possible to create a
LoomExperiment extending class via coercion:
scle <- as(sce, "SingleCellLoomExperiment") scle
Finally, one can create a
LoomExperiment object from importing a Loom File.
We will use the following
SingleCellLoomExperiment for the remainder of the vignette.
l1_file <- system.file("extdata", "L1_DRG_20_example.loom", package = "LoomExperiment") scle <- import(l1_file, type="SingleCellLoomExperiment") scle
All the following methods apply to all
rowGraphs slots of LoomExperiments correspond to the
row_graphs fields in the Loom File format. Both of these slots require
LoomGraph class extends the
SelfHits class from the
S4Vectors package with the requirements that a
LoomGraph object must:
LoomExperimentobject (if attached to a
from correspond to either
col indices in the
LoomExperiment object while
w is an optional column that specifies the weight.
A LoomGraph can be constructed in two ways:
a <- c(1, 2, 3) b <- c(3, 2, 1) w <- c(100, 10, 1) df <- DataFrame(a, b, w) lg <- as(df, "LoomGraph") ## OR lg <- LoomGraph(a, b, weight = w) lg
LoomGraph objects can be subset by the 'row'/'col' indices.
lg[c(1, 2)] lg[-c(2)]
LoomGraphs object extends the
S4Vectors:SimpleList object. It contains multiple
LoomGraph objects with its only requirement being that it must contain
It can be created simply by using
LoomGraph objects in the
lgs <- LoomGraphs(lg, lg) names(lgs) <- c('lg1', 'lg2') lgs
LoomGraphs assigned to these
rowGraphs slots can be obtained by their eponymous methods:
The same symbols can also be used to replace the respective
colGraphs(scle) <- lgs rowGraphs(scle) <- lgs colGraphs(scle) rowGraphs(scle) colGraphs(scle)[] rowGraphs(scle)[]
LoomExperiment objects can be subsetting in such a way that the
rowGraphs will all be subsetted.
assays will will be subsetted as any
matrix would. The
i element in the subsetting operation will subset the
rowGraphs slot and the
j element in the subsetting operation will subset the
colGraphs slot, as we've seen from the subsetting method from
scle2 <- scle[c(1, 3), 1:2] colGraphs(scle2)[] rowGraphs(scle2)[]
scle3 <- rbind(scle, scle) scle3 colGraphs(scle3) rowGraphs(scle3) colGraphs(scle3)[] rowGraphs(scle3)[]
LoomExperiment object can be exported.
temp <- tempfile(fileext='.loom') export(scle2, temp)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.