Package 'alabaster.sce'

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-11-29 03:24:05 UTC
Source: https://github.com/bioc/alabaster.sce

Help Index


Read a SingleCellExperiment from disk

Description

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.

Usage

readSingleCellExperiment(path, metadata, ...)

Arguments

path

String containing a path to a directory, itself created using the saveObject method for SingleCellExperiment objects.

metadata

Named list of metadata for this object, see readObjectFile for details.

...

Further arguments passed to readRangedSummarizedExperiment and internal altReadObject calls.

Value

A SingleCellExperiment object.

Author(s)

Aaron Lun

See Also

"saveObject,SingleCellExperiment-method", to save the SingleCellExperiment to disk.

Examples

# 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 disk

Description

Save a SingleCellExperiment to its on-disk representation.

Usage

## S4 method for signature 'SingleCellExperiment'
saveObject(x, path, ...)

Arguments

x

A SingleCellExperiment object or one of its subclasses.

path

String containing the path to a directory in which to save x.

...

Further arguments to pass to the RangedSummarizedExperiment method.

Value

x is saved into path and NULL is invisibly returned.

Author(s)

Aaron Lun

See Also

readSingleCellExperiment, to read the SingleCellExperiment back into the R session.

Examples

# 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)