Message-ID: <047fa7b2ce2031db8f5b6b4401a22a41.squirrel@imap.ifi.lmu.de>
Date: 2017-09-13T21:54:36Z
From: Ludwig Geistlinger
Subject: [Bioc-devel] coerce ExpressionSet to SummarizedExperiment
In-Reply-To: <CAC2h7ut_i2hj5y0AhTPzVbS3qZiACH_08GFL19N3852668+ivQ@mail.gmail.com>
Coercing vice versa, i.e. from SummarizedExperiment to ExpressionSet,
which is defined in
SummarizedExperiment/R/makeSummarizedExperimentFromExpressionSet.R
as follows:
setAs("SummarizedExperiment", "ExpressionSet", function(from)
as(as(from, "RangedSummarizedExperiment"), "ExpressionSet")
)
also seems to be a bit problematic, as it makes you lose your rowData/fData.
Here is an example:
## Constructing the SE similar to examples of ?SummarizedExperiment
> nrows <- 200; ncols <- 6
> counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
> colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
row.names=LETTERS[1:6])
## some rowData with simulated gene IDs
> rowData <- DataFrame(EntrezID=sample(1000, 200), row.names=paste0("g",
1:200))
> se <- SummarizedExperiment(assays=SimpleList(exprs=counts),
colData=colData, rowData=rowData)
# this is how it looks
> rowData(se)
DataFrame with 200 rows and 1 column
EntrezID
<integer>
1 289
2 476
3 608
4 998
5 684
... ...
196 331
197 590
198 445
199 95
200 129
(why did I actually lost the rownames g1-g200 here?)
## Coercing to Expression makes me losing the rowData/fData
> eset <- as(se, "ExpressionSet")
> fData(eset)
data frame with 0 columns and 200 rows
## So where is the problem?
## Apparently in the coercion
## from SummarizedExperiment to RangedSummarizedExperiment
> rse <- as(se, "RangedSummarizedExperiment")
> rowData(rse)
DataFrame with 200 rows and 0 columns