unsplitAltExps: Unsplit the alternative experiments

View source: R/unsplitAltExps.R

unsplitAltExpsR Documentation

Unsplit the alternative experiments

Description

Combine the main and alternative experiments back into one SingleCellExperiment object. This is effectively the reverse operation to splitAltExps.

Usage

unsplitAltExps(sce, prefix.rows = TRUE, prefix.cols = TRUE, delayed = TRUE)

Arguments

sce

A SingleCellExperiment containing alternative experiments in the altExps slot.

prefix.rows

Logical scalar indicating whether the (non-NULL) row names should be prefixed with the name of the alternative experiment.

prefix.cols

Logical scalar indicating whether the names of column-related fields should be prefixed with the name of the alternative experiment. If NA, any colData of the altExps are ignored.

delayed

Logical scalar indicating whether the combining of the assays should be delayed.

Details

This function is intended for downstream applications that accept a SingleCellExperiment but are not aware of the altExps concept. By consolidating all data together, applications like iSEE can use the same machinery to visualize any feature of interest across all modalities. However, for quantitative analyses, it is usually preferable to keep different modalities separate.

Assays with the same name are rbinded together in the output object. If a particular name is not present for any experiment, its values are filled in with the appropriately typed NA instead. By default, this is done efficiently via ConstantMatrix abstractions to avoid actually creating a dense matrix of NAs. If delayed=FALSE, the combining of matrices is done without any DelayedArray wrappers, yielding a simpler matrix representation at the cost of increasing memory usage.

Any colData or reducedDims in the alternative experiments are added to those of the main experiment. The names of these migrated fields are prefixed by the name of the alternative experiment if prefix.cols=TRUE.

Setting prefix.rows=FALSE, prefix.cols=NA and delayed=FALSE will reverse the effects of splitAltExps.

Value

A SingleCellExperiment where all features in the alternative experiments of sce are now features in the main experiment. The output object has no alternative experiments of its own.

Author(s)

Aaron Lun

See Also

splitAltExps, which does the reverse operation of this function.

Examples

counts <- matrix(rpois(10000, 5), ncol=100)
sce <- SingleCellExperiment(assays=list(counts=counts))
feat.type <- sample(c("endog", "ERCC", "adt"), nrow(sce),
    replace=TRUE, p=c(0.8, 0.1, 0.1))
sce <- splitAltExps(sce, feat.type)

# Making life a little more complicated.
logcounts(sce) <- log2(counts(sce) + 1)
sce$cluster <- sample(5, ncol(sce), replace=TRUE)
reducedDim(sce, "PCA") <- matrix(rnorm(ncol(sce)*2), ncol=2)
 
# Now, putting Humpty Dumpty back together again. 
restored <- unsplitAltExps(sce)
restored


drisso/SingleCellExperiment documentation built on March 28, 2024, 7:49 a.m.