[BioC] newbie Q about object identity

James W. MacDonald jmacdon at med.umich.edu
Wed Oct 10 15:31:14 CEST 2007


Hi Thomas,

Thomas Elliott wrote:
> I am new to R and Bioconductor.  I'm exploring using the  
> ExpressionSet object provided in Bioconductor Biobase package called  
> sample.ExpressionSet.  I'm troubled because what looks like the same  
> object behaves very differently depending on my "history."
> 
> With a clean history (.Rhistory and .Rdata deleted), I get this:
> 
>  > library("genefilter")
>  > data(sample.ExpressionSet)
>  > eset = sample.ExpressionSet
>  > eset
> ExpressionSet (storageMode: lockedEnvironment)
> assayData: 500 features, 26 samples
>    element names: exprs, se.exprs
> 
> and this call (and others like it) work:
>  > varLabels(eset)
> [1] "sex"   "type"  "score"
> 
> But if I now quit and save history, then start again and go:
>  > eset
> An object of class “ExpressionSet”
> Slot "assayData":
> <environment: 0xd2eac54>
> 
> The output is very different, and this call (and others like it)  
> don't work:
> 
>  > varLabels(eset)
> Error: could not find function "varLabels"

This is because the ExpressionSet class and methods are defined in the 
Biobase package. In the first case you have already loaded Biobase, so R 
knows what this object is. In the second case you haven't loaded Biobase 
so R has no methods to dispatch on this object.

> 
> The two objects are closely related.  For example, this call gives  
> the same result:
>  > class(eset)
> [1] "ExpressionSet"
> attr(,"package")
> [1] "Biobase"
> 
> If I then go
> 
>  > library("genefilter")
>  > data(sample.ExpressionSet)
> 
> and **without reassigning to eset**, I get the first behavior.

That is because genefilter depends on Biobase, so now you have Biobase 
loaded and R now knows what to do with your ExpressionSet object.

An example:

eset prior to loading Biobase. Try show() method:

 > eset
An object of class "ExpressionSet"
Slot "assayData":
<environment: 0x026c784c>

Slot "phenoData":
An object of class "AnnotatedDataFrame"
Slot "varMetadata":
       labelDescription
sex        Female/Male
type      Case/Control
score    Testing Score

Slot "data":
      sex    type score
A Female Control  0.75
B   Male    Case  0.40
C   Male Control  0.73
D   Male    Case  0.42
E Female    Case  0.93
F   Male Control  0.22
G   Male    Case  0.96
H   Male    Case  0.79
I Female    Case  0.37
J   Male Control  0.63
K   Male    Case  0.26
L Female Control  0.36
M   Male    Case  0.41
N   Male    Case  0.80
O Female    Case  0.10
P Female Control  0.41
Q Female    Case  0.16
R   Male Control  0.72
S   Male    Case  0.17
T Female    Case  0.74
U   Male Control  0.35
V Female Control  0.77
W   Male Control  0.27
X   Male Control  0.98
Y Female    Case  0.94
Z Female    Case  0.32

Slot "dimLabels":
[1] "sampleNames"  "sampleColums"

Slot ".__classVersion__":
An object of class "Versions"
[[1]]
[1] 1 1 0



Slot "featureData":
An object of class "AnnotatedDataFrame"
Slot "varMetadata":
[1] labelDescription
<0 rows> (or 0-length row.names)

Slot "data":
NULL data frame with 500 rows

Slot "dimLabels":
[1] "featureNames"   "featureColumns"

Slot ".__classVersion__":
An object of class "Versions"
[[1]]
[1] 1 1 0



Slot "experimentData":
An object of class "MIAME"
Slot "name":
[1] "Pierre Fermat"

Slot "lab":
[1] "Francis Galton Lab"

Slot "contact":
[1] "pfermat at lab.not.exist"

Slot "title":
[1] "Smoking-Cancer Experiment"

Slot "abstract":
[1] "An example object of expression set (exprSet) class"

Slot "url":
[1] "www.lab.not.exist"

Slot "pubMedIds":
[1] ""

Slot "samples":
list()

Slot "hybridizations":
list()

Slot "normControls":
list()

Slot "preprocessing":
list()

Slot "other":
$notes
[1] "An example object of expression set (exprSet) class"


Slot ".__classVersion__":
An object of class "Versions"
[[1]]
[1] 1 0 0



Slot "annotation":
[1] "hgu95av2"

Slot ".__classVersion__":
An object of class "Versions"
[[1]]
[1] 2 4 0

[[2]]
[1]  1 11 34

[[3]]
[1] 1 1 0

[[4]]
[1] 1 0 0


Now we load Biobase and try show() again:

 > eset
ExpressionSet (storageMode: lockedEnvironment)
assayData: 500 features, 26 samples
   element names: exprs, se.exprs
phenoData
   sampleNames: A, B, ..., Z  (26 total)
   varLabels and varMetadata description:
     sex: Female/Male
     type: Case/Control
     score: Testing Score
featureData
   featureNames: AFFX-MurIL2_at, AFFX-MurIL10_at, ..., 31739_at  (500 total)
   fvarLabels and fvarMetadata description: none
experimentData: use 'experimentData(object)'
Annotation: hgu95av2


Best,

Jim


> 
> How can the same object behave so differently?  This is deeply  
> unnerving to me coming to R from Python.
> 
> Also, it seems obvious that one is an older way of doing things.  How  
> do I know which way is up to date?  This is a general issue when many  
> Vignettes reference older things like exprSet objects.  I assume the  
> old stuff is left in for backwards compatibility but it is an obvious  
> source of confusion to the newcomer.
> 
> Thanks for any insight.
> 
> Tom Elliott
> 
> Biobase 1.16.0, genefilter 1.16.0
> R 2.6.0 GUI 1.21 (4815) on OS X 10.4.10
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor

-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623



More information about the Bioconductor mailing list