Title: | Load and Save SummarizedExperiments from File |
---|---|
Description: | Save SummarizedExperiments into file artifacts, and load them back into memory. This is a more portable alternative to serialization of such objects into RDS files. Each artifact is associated with metadata for further interpretation; downstream applications can enrich this metadata with context-specific properties. |
Authors: | Aaron Lun [aut, cre] |
Maintainer: | Aaron Lun <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.7.0 |
Built: | 2024-11-17 06:12:17 UTC |
Source: | https://github.com/bioc/alabaster.se |
rowRanges
empty?Check the rowRanges
of a RangedSummarizedExperiment is empty,
i.e., a GRangesList with no ranges.
emptyRowRanges(x)
emptyRowRanges(x)
x |
A RangedSummarizedExperiment object or the contents of its |
Metadata in mcols
is ignored for the purpose of this discussion,
as this can be moved to the rowData(x)
of the base SummarizedExperiment class without loss.
In other words, non-empty mcols
will not be used to determine that the rowRanges
is not empty.
However, non-empty fields in the metadata
or in the inner mcols
of the GRanges will trigger a non-emptiness decision.
A logical scalar indicating whether x
has empty rowRanges
.
emptyRowRanges(SummarizedExperiment()) emptyRowRanges(SummarizedExperiment(rowRanges=GRanges())) emptyRowRanges(SummarizedExperiment(rowRanges=GRangesList()))
emptyRowRanges(SummarizedExperiment()) emptyRowRanges(SummarizedExperiment(rowRanges=GRanges())) emptyRowRanges(SummarizedExperiment(rowRanges=GRangesList()))
Read a RangedSummarizedExperiment from its on-disk representation.
This is usually not directly called by users, but is instead called by dispatch in readObject
.
readRangedSummarizedExperiment(path, metadata, ...)
readRangedSummarizedExperiment(path, metadata, ...)
path |
String containing a path to a directory, itself created using the |
metadata |
Named list of metadata for this object, see |
... |
Further arguments passed to |
A RangedSummarizedExperiment object.
Aaron Lun
"saveObject,RangedSummarizedExperiment-method"
, to save the RangedSummarizedExperiment to disk.
# Mocking up an experiment: mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) gr <- GRanges("chrA", IRanges(1:1000, width=10)) se <- SummarizedExperiment(list(counts=mat), rowRanges=gr) se$stuff <- LETTERS[1:10] rowData(se)$blah <- runif(1000) metadata(se)$whee <- "YAY" tmp <- tempfile() saveObject(se, tmp) readObject(tmp)
# Mocking up an experiment: mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) gr <- GRanges("chrA", IRanges(1:1000, width=10)) se <- SummarizedExperiment(list(counts=mat), rowRanges=gr) se$stuff <- LETTERS[1:10] rowData(se)$blah <- runif(1000) metadata(se)$whee <- "YAY" tmp <- tempfile() saveObject(se, tmp) readObject(tmp)
Read a SummarizedExperiment from its on-disk representation.
This is usually not directly called by users, but is instead called by dispatch in readObject
.
readSummarizedExperiment(path, metadata, ...)
readSummarizedExperiment(path, metadata, ...)
path |
String containing a path to a directory, itself created using the |
metadata |
Named list of metadata for this object, see |
... |
Further arguments passed to internal |
A SummarizedExperiment object.
Aaron Lun
"saveObject,SummarizedExperiment-method"
, to save the SummarizedExperiment to disk.
# Mocking up an experiment: mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) se <- SummarizedExperiment(list(counts=mat)) se$stuff <- LETTERS[1:10] rowData(se)$blah <- runif(1000) metadata(se)$whee <- "YAY" tmp <- tempfile() saveObject(se, tmp) readObject(tmp)
# Mocking up an experiment: mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) se <- SummarizedExperiment(list(counts=mat)) se$stuff <- LETTERS[1:10] rowData(se)$blah <- runif(1000) metadata(se)$whee <- "YAY" tmp <- tempfile() saveObject(se, tmp) readObject(tmp)
Save a RangedSummarizedExperiment to its on-disk representation.
## S4 method for signature 'RangedSummarizedExperiment' saveObject(x, path, ...)
## S4 method for signature 'RangedSummarizedExperiment' saveObject(x, path, ...)
x |
A RangedSummarizedExperiment object or one of its subclasses. |
path |
String containing the path to a directory in which to save |
... |
Further arguments to pass to |
x
is saved into path
and NULL
is invisibly returned.
Aaron Lun
readRangedSummarizedExperiment
, to read the RangedSummarizedExperiment back into the R session.
mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) gr <- GRanges("chrA", IRanges(1:1000, width=10)) se <- SummarizedExperiment(list(counts=mat), rowRanges=gr) se$stuff <- LETTERS[1:10] rowData(se)$blah <- runif(1000) metadata(se)$whee <- "YAY" tmp <- tempfile() saveObject(se, tmp) list.files(tmp, recursive=TRUE)
mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) gr <- GRanges("chrA", IRanges(1:1000, width=10)) se <- SummarizedExperiment(list(counts=mat), rowRanges=gr) se$stuff <- LETTERS[1:10] rowData(se)$blah <- runif(1000) metadata(se)$whee <- "YAY" tmp <- tempfile() saveObject(se, tmp) list.files(tmp, recursive=TRUE)
Save a SummarizedExperiment to its on-disk representation.
## S4 method for signature 'SummarizedExperiment' saveObject(x, path, SummarizedExperiment.allow.dataframe.assay = FALSE, ...)
## S4 method for signature 'SummarizedExperiment' saveObject(x, path, SummarizedExperiment.allow.dataframe.assay = FALSE, ...)
x |
A SummarizedExperiment object or one of its subclasses. |
path |
String containing the path to a directory in which to save |
SummarizedExperiment.allow.dataframe.assay |
Logical scalar indicating whether to allow data frames as assays of |
... |
Further arguments to pass to internal |
By default, we consider the presence of data frames in the assays to be an error.
Users should coerce these into an appropriate matrix type, e.g., a dense matrix or a sparse dgCMatrix.
If a DataFrame as an assay is truly desired, users may set options(alabaster.se.reject_data.frames=FALSE)
to skip the error.
Note that this only works for DataFrame objects - data.frame objects will not be saved correctly.
x
is saved into path
and NULL
is invisibly returned.
Aaron Lun
readSummarizedExperiment
, to read the SummarizedExperiment back into the R session.
mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) se <- SummarizedExperiment(list(counts=mat)) se$stuff <- LETTERS[1:10] rowData(se)$blah <- runif(1000) metadata(se)$whee <- "YAY" tmp <- tempfile() saveObject(se, tmp) list.files(tmp, recursive=TRUE)
mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) se <- SummarizedExperiment(list(counts=mat)) se$stuff <- LETTERS[1:10] rowData(se)$blah <- runif(1000) metadata(se)$whee <- "YAY" tmp <- tempfile() saveObject(se, tmp) list.files(tmp, recursive=TRUE)