Skip to content

[Bioc-devel] Passing variable argument list to ExpressionSet

5 messages · Martin Morgan, Seth Falcon, Sean Davis

#
This is a simple question, but I haven't found an answer.  I am reading data 
with varying types of data that I would like to store in the assayData slot 
of an ExpressionSet-like object.  So, I would like to go from a named list of 
matrices to a new assayData object.  A concrete example:

x <- list()
x[['cy3']] <- matrix(rnorm(1000),nc=2)
x[['cy5']] <- matrix(rnorm(1000),nc=2)
....

So, can I construct a call using assayDataNew() or ExpressionSet() that uses 
the names and values in the variable x to construct a bunch of matrices in 
the assayData slot?  Or should I just write my own assayDataNew() function 
(downside being keeping up with changes in API and/or implementation of 
assayData)?

Thanks,
Sean
#
Hi Sean --

Two things.

ExpressionSet expects an element named 'exprs', so if this doesn't fit
the description of your data then you'll need to look
elsewhere. Perhaps not too far, though, as "MultiSet" might do the
trick. MultiSet will give you many features of ExpressionSet (e.g.,
subsetting, sampleNames, featureNames, etc; see the help page for
MultiSet or use showMethods(classes="MultiSet")).

The assayData slot of ExpressionSet (or MultiSet) can contain lists or
environemnts, with the requirement that all elements have the same
dimensions. So
Loading required package: tools

Welcome to Bioconductor

    Vignettes contain introductory material. To view, type
    'openVignette()' or start with 'help(Biobase)'. For details
    on reading vignettes, see the openVignette help page.
MultiSet (storageMode: list)
assayData: 500 features, 2 samples 
  element names: cy3, cy5 
phenoData
  sampleNames: 1, 2
  varLabels and varMetadata: none
featureData
  featureNames: 1, 2, ..., 500 (500 total)
  varLabels and varMetadata: none
experimentData: use 'experimentData(object)'
Annotation character(0)

creates a new MultiSet based on your list (note 'storageMode: list' in
the output).

Probably I should stop now. But to be complete, you could have created
a MultiSet as
MultiSet (storageMode: lockedEnvironment)
assayData: 500 features, 2 samples 
  element names: cy3, cy5 
phenoData
  sampleNames: 1, 2
  varLabels and varMetadata: none
featureData
  featureNames: 1, 2, ..., 500 (500 total)
  varLabels and varMetadata: none
experimentData: use 'experimentData(object)'
Annotation character(0)

or converted your 'list'-based MultiSet to a 'lockedEnvironment'
MultiSet with storageMode(m) <- "lockedEnvironment" (a
lockedEnvironment is meant to provide beneficial storage efficiency /
copying consequences, but this might often not be important).

You could also create an envionment and stored your elements in
it
MultiSet (storageMode: environment)
assayData: 500 features, 2 samples 
  element names: cy3, cy5 
phenoData
  sampleNames: 1, 2
  varLabels and varMetadata: none
featureData
  featureNames: 1, 2, ..., 500 (500 total)
  varLabels and varMetadata: none
experimentData: use 'experimentData(object)'
Annotation character(0)

Note that this could be VERY SURPRISING, as the data in an
'environment' is not copied the way a list is -- changing a value in
cy3 of your MultiSet will change the value in x as well, which does
not happen with lists.

Martin

Sean Davis <sdavis2 at mail.nih.gov> writes:

  
    
#
On Thursday 01 February 2007 11:57, Martin Morgan wrote:

            
Thanks, Martin.  This is what I was looking for.  As for the particular class, 
I have a custom one, but a MultiSet might work just as well.

Thanks again,
Sean
#
Sean Davis <sdavis2 at mail.nih.gov> writes:
One comment here:

  It is better to create new environments as:

       x <- new.env(hash=TRUE, parent=emptyenv())

   When using an environment as a hashtable, you really do not want
   any inheritance (hence the emptyenv() as parent).  For small
   environments with fewer than 50 (made up number) elements, the
   default hash=FALSE is probably fine.


+ seth
#
On Thursday 01 February 2007 12:32, Seth Falcon wrote:
Thanks, Seth, for the detail here.

Sean