Skip to contents

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

Usage

as.SummarizedExperiment(x, ...)

# S4 method for RangedSummarizedExperiment
as.SummarizedExperiment(x)

# S4 method for SummarizedExperiment
as.SummarizedExperiment(x)

Arguments

x

Object.

...

Additional arguments.

Value

SummarizedExperiment.

Note

Updated 2022-05-04.

Examples

suppressPackageStartupMessages(library(SummarizedExperiment))
data(RangedSummarizedExperiment, package = "AcidTest")

## RangedSummarizedExperiment ===
## Current S4 coercion drops row metadata.
names(metadata(rowRanges(RangedSummarizedExperiment)))
#>  [1] "annotationHubId" "date"            "ensembldb"       "genomeBuild"    
#>  [5] "ignoreVersion"   "level"           "organism"        "packageVersion" 
#>  [9] "provider"        "release"         "call"           
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] "annotationHubId" "date"            "ensembldb"       "genomeBuild"    
#>  [5] "ignoreVersion"   "level"           "organism"        "packageVersion" 
#>  [9] "provider"        "release"         "call"