simplifyToSCE {SingleCellExperiment} | R Documentation

## Simplify a list to a single SingleCellExperiment

### Description

Simplify a list of SingleCellExperiment, usually generated by `applySCE` on main and alternative Experiments, into a single SingleCellExperiment containing some of the results in its `altExps`.

### Usage

    simplifyToSCE(results, which.main, warn.level = 2)

### Arguments

`results` | A named list of SummarizedExperiment or SingleCellExperiment objects.
`which.main` | Integer scalar specifying which entry of `results` contains the output generated from the main Experiment. If `NULL` or a vector of length zero, this indicates that no entry was generated from the main Experiment. Defaults to the unnamed entry of `results`.
`warn.level` | Integer scalar specifying the type of warnings that can be emitted.

### Details

Each entry of `results` should be a SummarizedExperiment with the same number and names of the columns. There should not be any duplicate entries in `names(results)`, as the names are used to represent the names of the alternative Experiments in the output. If `which.main` is a scalar, the corresponding entry of `results` should be a SingleCellExperiment. Failure to meet these conditions may result in a warning or error depending on `warn.level`.

The type of warnings that are emitted can be controlled with `warn.level`. If `warn.level=0`, no warnings are emitted. If `warn.level=1`, all warnings are emitted except for those related to `results` not being of the appropriate class. If `warn.level=2`, all warnings are emitted, and if `warn.level=3`, warnings are promoted to errors.

### Value

A SingleCellExperiment corresponding to the entry of `results` generated from the main Experiment. All results generated from the alternative Experiments of `x` are stored in the `altExps` of the output.

If no main Experiment was used to generate `results`, an empty SingleCellExperiment is used as a container for the various `altExps`.

If simplification could not be performed, `NULL` is returned with a warning (depending on `warn.level`.

### Author(s)

Aaron Lun

### See Also

`applySCE`, where this function is used when `SIMPLIFY=TRUE`.

### Examples

    ncells <- 100
    u <- matrix(rpois(20000, 5), ncol=ncells)
    sce <- SingleCellExperiment(assays=list(counts=u))
    altExp(sce, "BLAH") <- SingleCellExperiment(assays=list(counts=u*10))
    altExp(sce, "WHEE") <- SingleCellExperiment(assays=list(counts=u*2))

    # Setting FUN=identity just extracts each piece:
    results <- applySCE(sce, FUN=identity, SIMPLIFY=FALSE)
    results

    # Simplifying to an output that mirrors the structure of 'sce'.
    simplifyToSCE(results)

[Package SingleCellExperiment version 1.14.1 Index]