Coerce to SummarizedExperiment
.
Source: R/AllGenerics.R
, R/as.SummarizedExperiment-methods.R
as.SummarizedExperiment.Rd
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)
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"