Closed tomsing1 closed 4 years ago
Hi, Thomas. This is an interesting observation, and I hope the situation was not too difficult to diagnose. I don't see anything in the ExpressionSet user-level documentation indicating that the default/expected setting for ExpressionSet storageMode is lockedEnvironment. The vignette you point to indicates the available settings. You can set the storageMode manually after coercion. I don't know that the coercion function should do this, but it is worth discussing.
Thanks a lot for taking a look, Vince! Yes, I agree - an ExpressionSet with an unlocked environment is totally valid. I followed your advice and set the storageMode manually.
The default for a new assayData
object is a lockedEnvironment
(see Biobase::assayDataNew), that's why I probably never encountered an ExpressionSet
with an unlocked assay in the wild before.
Tangentially related:
When I looked up the assayDataNew method, I noticed that the switch
function was called without a right-hand side for the first option (lockedEnvironment):
assayDataNew <-
function(storage.mode = c("lockedEnvironment", "environment", "list"),
...)
{
storage.mode <- match.arg(storage.mode) ## defaults to "lockedEnvironment"
assayData <- switch(storage.mode,
lockedEnvironment =,
environment = new.env(parent=emptyenv()),
list = list())
I didn't even know that's valid R code! Learning something new every day...
I'll update the coercion method
I ran into some unexpected pass-by-reference behavior with
ExpressionSets
that were coerced fromSummarizedExperiments
today.I believe this can be traced to the
SummarizedExperiment -> ExpressionSet
coersion implemented in thesetAs("RangedSummarizedExperiment", "ExpressionSet")
method, which returns anExpressionSet
with an unlocked environment in theassayData
slot, instead of the defaultlockedEnvironment
storage mode.(See page 7 of the BiobaseDevelopment vignette for a discussion of the storage modes.)
I believe the
storageMode
of theExpressionSet
object returned by thesetAs("RangedSummarizedExperiment", "ExpressionSet")
method needs to be locked explicitly here.Reproducible example:
This can lead to unintended pass-by-reference behavior downstream, e.g.
When I copy the ExpressionSet into a new object
the data is same as above, as expected:
But when I modify the
assayData
in the new object:unexpectedly (at least to me), the
assayData
in the originalExpressionSet
(eset) also gets modified:because they both point to the same (unlocked) environment.
SessionInfo