Coerce to SummarizedExperiment.

as.SummarizedExperiment(x, ...)

# S4 method for SummarizedExperiment
as.SummarizedExperiment(x)

# S4 method for RangedSummarizedExperiment
as.SummarizedExperiment(x)

Arguments

x

Object.

...

Additional arguments.

Value

SummarizedExperiment.

Details

Improved S4 methods for reliably coercing objects that extend RangedSummarizedExperiment to a standard SummarizedExperiment, that doesn't drop rowData().

Related S4 coercion method of interest:

getMethod(
    f = "coerce",
    signature = signature(
        from = "RangedSummarizedExperiment",
        to = "SummarizedExperiment"
    ),
    where = asNamespace("SummarizedExperiment")
)

Examples

suppressPackageStartupMessages(library(SummarizedExperiment)) data(RangedSummarizedExperiment, package = "acidtest") ## RangedSummarizedExperiment === ## Current S4 coercion drops row metadata. names(metadata(rowRanges(RangedSummarizedExperiment)))
#> [1] "package" "version" "date" "organism" #> [5] "genomeBuild" "ensemblRelease" "ensembldb" "level" #> [9] "id"
se <- as(RangedSummarizedExperiment, "SummarizedExperiment") names(metadata(rowData(se)))
#> NULL
## Our alternate S3 method preserves the metadata. se <- as.SummarizedExperiment(RangedSummarizedExperiment) names(metadata(rowData(se)))
#> [1] "package" "version" "date" "organism" #> [5] "genomeBuild" "ensemblRelease" "ensembldb" "level" #> [9] "id"