Title: | Load and Save SingleCellExperiment from File |
---|---|
Description: | Save SingleCellExperiment 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-10-30 03:27:21 UTC |
Source: | https://github.com/bioc/alabaster.sce |
Read a SingleCellExperiment object from its on-disk representation.
This is usually not directly called by users, but is instead called by dispatch in readObject
.
readSingleCellExperiment(path, metadata, ...)
readSingleCellExperiment(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 SingleCellExperiment object.
Aaron Lun
"saveObject,SingleCellExperiment-method"
, to save the SingleCellExperiment to disk.
# Mocking up an SCE: mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) se <- SingleCellExperiment(list(counts=mat)) se$stuff <- LETTERS[1:10] se$blah <- runif(10) reducedDims(se) <- list( PCA=matrix(rnorm(ncol(se)*10), ncol=10), TSNE=matrix(rnorm(ncol(se)*2), ncol=2) ) altExps(se) <- list(spikes=SummarizedExperiment(list(counts=mat[1:2,]))) # Staging it: tmp <- tempfile() saveObject(se, tmp) readObject(tmp)
# Mocking up an SCE: mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) se <- SingleCellExperiment(list(counts=mat)) se$stuff <- LETTERS[1:10] se$blah <- runif(10) reducedDims(se) <- list( PCA=matrix(rnorm(ncol(se)*10), ncol=10), TSNE=matrix(rnorm(ncol(se)*2), ncol=2) ) altExps(se) <- list(spikes=SummarizedExperiment(list(counts=mat[1:2,]))) # Staging it: tmp <- tempfile() saveObject(se, tmp) readObject(tmp)
Save a SingleCellExperiment to its on-disk representation.
## S4 method for signature 'SingleCellExperiment' saveObject(x, path, ...)
## S4 method for signature 'SingleCellExperiment' saveObject(x, path, ...)
x |
A SingleCellExperiment object or one of its subclasses. |
path |
String containing the path to a directory in which to save |
... |
Further arguments to pass to the RangedSummarizedExperiment method. |
x
is saved into path
and NULL
is invisibly returned.
Aaron Lun
readSingleCellExperiment
, to read the SingleCellExperiment back into the R session.
# Mocking up an SCE: mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) se <- SingleCellExperiment(list(counts=mat)) se$stuff <- LETTERS[1:10] se$blah <- runif(10) reducedDims(se) <- list( PCA=matrix(rnorm(ncol(se)*10), ncol=10), TSNE=matrix(rnorm(ncol(se)*2), ncol=2) ) altExps(se) <- list(spikes=SummarizedExperiment(list(counts=mat[1:2,]))) # Staging it: tmp <- tempfile() saveObject(se, tmp) list.files(tmp, recursive=TRUE)
# Mocking up an SCE: mat <- matrix(rpois(10000, 10), ncol=10) colnames(mat) <- letters[1:10] rownames(mat) <- sprintf("GENE_%i", seq_len(nrow(mat))) se <- SingleCellExperiment(list(counts=mat)) se$stuff <- LETTERS[1:10] se$blah <- runif(10) reducedDims(se) <- list( PCA=matrix(rnorm(ncol(se)*10), ncol=10), TSNE=matrix(rnorm(ncol(se)*2), ncol=2) ) altExps(se) <- list(spikes=SummarizedExperiment(list(counts=mat[1:2,]))) # Staging it: tmp <- tempfile() saveObject(se, tmp) list.files(tmp, recursive=TRUE)