| Title: | LoomExperiment container |
|---|---|
| Description: | The LoomExperiment package provide a means to easily convert the Bioconductor "Experiment" classes to loom files and vice versa. |
| Authors: | Martin Morgan, Daniel Van Twisk |
| Maintainer: | Bioconductor Package Maintainer <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 1.31.0 |
| Built: | 2026-05-30 09:38:04 UTC |
| Source: | https://github.com/bioc/LoomExperiment |
Exports a LoomExperiment to a LoomFile. Note the colGraph and rowGraph contained within
the LoomExperimnet object are 1-indexed in R and are converted to 0-indexed in the loom file.
## S4 method for signature 'LoomExperiment,LoomFile,ANY' export(object, con, matrix=assayNames(object)[1], rownames_attr="rownames", colnames_attr="colnames")## S4 method for signature 'LoomExperiment,LoomFile,ANY' export(object, con, matrix=assayNames(object)[1], rownames_attr="rownames", colnames_attr="colnames")
object |
A |
con |
The connection from which data is loaded or to which data is saved. If this is a |
matrix |
A |
rownames_attr |
A |
colnames_attr |
A |
An error code indiciating whether the operation was successful.
counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) sce <- SingleCellExperiment(assays = list(counts = counts)) scle <- SingleCellLoomExperiment(sce) tempfile <- tempfile(fileext=".loom") export(scle, tempfile)counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) sce <- SingleCellExperiment(assays = list(counts = counts)) scle <- SingleCellLoomExperiment(sce) tempfile <- tempfile(fileext=".loom") export(scle, tempfile)
Imports a LoomExperiment from a LoomFile. Note the colGraph and rowGraph contained within
the 0-indexed loom file will be converted to the 1-indexed represnetation in the resulting LoomExperiment object.
## S4 method for signature 'LoomFile,ANY,ANY' import(con, ..., type = c("SingleCellLoomExperiment", "LoomExperiment", "RangedLoomExperiment"), rownames_attr=NULL, colnames_attr=NULL)## S4 method for signature 'LoomFile,ANY,ANY' import(con, ..., type = c("SingleCellLoomExperiment", "LoomExperiment", "RangedLoomExperiment"), rownames_attr=NULL, colnames_attr=NULL)
con |
A character indicating the loom file to be created. File must have the |
... |
Additional arguments |
type |
Either "SingleCellLoomExperiment", "LoomExperiment", or "RangedLoomExperiment".
This value decides what type of object that will be returned by |
rownames_attr |
A |
colnames_attr |
A |
An object of class LoomExperiment
l1_file <- system.file("extdata", "L1_DRG_20_example.loom", package = "LoomExperiment") scle <- import(l1_file, type="SingleCellLoomExperiment") sclel1_file <- system.file("extdata", "L1_DRG_20_example.loom", package = "LoomExperiment") scle <- import(l1_file, type="SingleCellLoomExperiment") scle
An example hdf5 file in the Loom file format obtained from the Linnarson
Lab.
The original file was imported using LoomExperiment and truncated using
the package's subsetting methods. The purpose of this truncation was to reduce
the total size of the data as the file's purpose is simply to
demonstrate LoomExperiment's functionality.
The data set has dimensions of 20x20. The file contains 7 rowData and 103
colData entries each corresponding to readings generated by
high-throughput sequencing experiments. In addition, a colGraphs entry
encoding aLoomGraph containing two LoomGraph objects are also
included.
An hdf5 file in the Loom format
## Load L1_DRG_20_example.loom using LoomExperiment's import() method l1_file <- system.file("extdata", "L1_DRG_20_example.loom", package = "LoomExperiment") scle <- import(l1_file, type="SingleCellLoomExperiment") scle## Load L1_DRG_20_example.loom using LoomExperiment's import() method l1_file <- system.file("extdata", "L1_DRG_20_example.loom", package = "LoomExperiment") scle <- import(l1_file, type="SingleCellLoomExperiment") scle
The LoomExperiment family of classes is used as a bridge between Bioconductor's "Experiment" classes and the Linnarson Lab's http://linnarssonlab.org/loompy/index.html.
The family of LoomExperiment classes all inherit from the class LoomExperiment as well as their respectively named parent classes.
The LoomExperiment class inheirts from SummarizedExperiment.
## Constructor LoomExperiment(..., colGraphs = LoomGraphs(), rowGraphs = LoomGraphs()) RangedLoomExperiment(..., colGraphs = LoomGraphs(), rowGraphs = LoomGraphs()) SingleCellLoomExperiment(..., colGraphs = LoomGraphs(), rowGraphs = LoomGraphs()) ## Accessors ## S4 method for signature 'LoomExperiment' colGraphs(x, ...) ## S4 replacement method for signature 'LoomExperiment' colGraphs(x, ...) <- value ## S4 method for signature 'LoomExperiment' rowGraphs(x, ...) ## S4 replacement method for signature 'LoomExperiment' rowGraphs(x, ...) <- value ## Subsetting ## S4 method for signature 'LoomExperiment' x[i, j, ..., drop=TRUE] ## Binding ## S4 method for signature 'LoomExperiment' rbind(..., deparse.level=1) ## S4 method for signature 'LoomExperiment' cbind(..., deparse.level=1)## Constructor LoomExperiment(..., colGraphs = LoomGraphs(), rowGraphs = LoomGraphs()) RangedLoomExperiment(..., colGraphs = LoomGraphs(), rowGraphs = LoomGraphs()) SingleCellLoomExperiment(..., colGraphs = LoomGraphs(), rowGraphs = LoomGraphs()) ## Accessors ## S4 method for signature 'LoomExperiment' colGraphs(x, ...) ## S4 replacement method for signature 'LoomExperiment' colGraphs(x, ...) <- value ## S4 method for signature 'LoomExperiment' rowGraphs(x, ...) ## S4 replacement method for signature 'LoomExperiment' rowGraphs(x, ...) <- value ## Subsetting ## S4 method for signature 'LoomExperiment' x[i, j, ..., drop=TRUE] ## Binding ## S4 method for signature 'LoomExperiment' rbind(..., deparse.level=1) ## S4 method for signature 'LoomExperiment' cbind(..., deparse.level=1)
x |
A LoomExperiment object |
colGraphs, rowGraphs
|
LoomGraphs to be placed in either the colGraphs or rowGraphs slot respectively |
value |
For |
... |
For constructors, |
i, j
|
For subsetting, indices specifying elements to subset LoomGraph by. For dropHits, numeric indicating the node number |
drop |
For matrices and arrays. If 'TRUE' the result is coerced to the lowest posible dimesnion. This only woeks for extracting elements, not for the replacement. |
deparse.level |
See '?base::cbind' for a description of this argument. |
The LoomExperiment class is a virtual class meant to to act as an interface for other "_LoomExperiment" classes.
It contains two slots:
colGraphs:A LoomGraphs object containing col_graph data as specified by the loom format.
rowGraphs:A LoomGraphs object containing row_graph data as specified by the loom format.
The intended use of this class is as an interface that allows various slots and operations necessary for subsequent "_LoomExperiment" classes to be defined.
The colGraphs and rowGraphs slot stores a LoomGraphs object that stores a graph of edges between vertices and possibly associated weights. These slots may be NULL.
An object of class LoomExperiment
Daniel Van Twisk
SummarizedExperiment,
RangedSummarizedExperiment,
SingleCellExperiment
## Construction counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) sce <- SingleCellExperiment(assays = list(counts = counts)) scle <- SingleCellLoomExperiment(sce) # OR scle <- SingleCellLoomExperiment(assays = list(counts = counts)) # OR scle <- as(sce, "SingleCellLoomExperiment") scle ## Get and replace rowGraphs and colGraphs colGraphs(scle) rowGraphs(scle) a <- c(1, 2, 3) b <- c(3, 2, 1) w <- c(100, 10, 1) lg <- LoomGraph(a, b, weight=w) lgs <- LoomGraphs(lg, lg) names(lgs) <- c('lg1', 'lg2') lgs colGraphs(scle) <- lgs rowGraphs(scle) <- lgs colGraphs(scle) rowGraphs(scle) colGraphs(scle)[[1]] rowGraphs(scle)[[1]] ## Subsetting scle2 <- scle[c(1, 3), 1:2] colGraphs(scle2)[[1]] rowGraphs(scle2)[[1]]## Construction counts <- matrix(rpois(100, lambda = 10), ncol=10, nrow=10) sce <- SingleCellExperiment(assays = list(counts = counts)) scle <- SingleCellLoomExperiment(sce) # OR scle <- SingleCellLoomExperiment(assays = list(counts = counts)) # OR scle <- as(sce, "SingleCellLoomExperiment") scle ## Get and replace rowGraphs and colGraphs colGraphs(scle) rowGraphs(scle) a <- c(1, 2, 3) b <- c(3, 2, 1) w <- c(100, 10, 1) lg <- LoomGraph(a, b, weight=w) lgs <- LoomGraphs(lg, lg) names(lgs) <- c('lg1', 'lg2') lgs colGraphs(scle) <- lgs rowGraphs(scle) <- lgs colGraphs(scle) rowGraphs(scle) colGraphs(scle)[[1]] rowGraphs(scle)[[1]] ## Subsetting scle2 <- scle[c(1, 3), 1:2] colGraphs(scle2)[[1]] rowGraphs(scle2)[[1]]
A LoomFile class represents a loom file based on the Linnarson Lab's
http://linnarssonlab.org/loompy/index.html. A loom
file is encoded as an hdf5 file. A loom file consists of a main matrix,
optional additional layers, a variable number of row and column annotations
and sparse graph objects. It is used to efficienctly stroe very large omics
datasets.
The LoomFile class extends the functionality of the
BiocFile from the BiocIO
package.
Daniel Van Twisk
The LoomGraph class extends the SelfHits class.
The SelfHits class represents a set of hits between a set of left node and right nodes.
Only the Hits are stored in a SelfHits object.
The LoomGraph class is meant to store graph information and was created to be used in conjunction with the LoomExperiment class.
Its purpose is to store either a col_graph or row_graph as specified by the loom file format.
Attributes from and to indicate an edge between two vertices.
The w column indicates the weight of the corresponding edge and is optional.
LoomGraph(from, to, nnode=max(from, to), ..., weight=NULL) ## S4 method for signature 'LoomGraph' rbind(..., deparse.level=1) ## S4 method for signature 'LoomGraph' cbind(..., deparse.level=1)LoomGraph(from, to, nnode=max(from, to), ..., weight=NULL) ## S4 method for signature 'LoomGraph' rbind(..., deparse.level=1) ## S4 method for signature 'LoomGraph' cbind(..., deparse.level=1)
... |
Arguments to pass to the |
from |
A numeric vector of nodes indicating one side of the graph's edge. |
to |
A numeric vector of node indicating the second side of the graph's edge. |
nnode |
An integer indicating the maximum number of nodes in the graph. |
weight |
A numeric vector indicating the weight between the prospective edges. |
deparse.level |
See '?base::cbind' for a description of this argument |
A LoomGraph object is returned from the constructor.
Daniel Van Twisk
LoomExperiment,
LoomGraphs,
SelfHits
## Construction 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 ## Subsetting lg[c(1, 2)] lg[-c(2)]## Construction 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 ## Subsetting lg[c(1, 2)] lg[-c(2)]
The LoomGraphs class extends the SimpleList class.
It is meant to store multiple LoomGraph objects and was created to be used in conjunction with the LoomExperiment class.
Its purpose is to store multiple col_graph or row_graph as specified by the loom file format.
Only LoomGraph obects may be stored in a LoomGraphs object.
LoomGraphs(...) ## S4 method for signature 'LoomGraphs' rbind(..., deparse.level=1) ## S4 method for signature 'LoomGraphs' cbind(..., deparse.level=1)LoomGraphs(...) ## S4 method for signature 'LoomGraphs' rbind(..., deparse.level=1) ## S4 method for signature 'LoomGraphs' cbind(..., deparse.level=1)
... |
|
deparse.level |
See '?base::cbind' for a description of this argument |
A LoomGraphs object is returned from the constructor.
Daniel Van Twisk
LoomExperiment,
LoomGraph,
SimpleList
## Construction lg1 <- LoomGraph(c(1, 2, 3), c(3, 2, 1), weight=c(4, 7, 8)) lg2 <- LoomGraph(c(3, 3, 1), c(3, 1, 2)) lgs <- LoomGraphs(lg1, lg2) lgs## Construction lg1 <- LoomGraph(c(1, 2, 3), c(3, 2, 1), weight=c(4, 7, 8)) lg2 <- LoomGraph(c(3, 3, 1), c(3, 1, 2)) lgs <- LoomGraphs(lg1, lg2) lgs