Question: newbie Q about object identity
0
gravatar for Thomas Elliott
12.2 years ago by
Thomas Elliott20 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" 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. 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
gui biobase genefilter • 629 views
ADD COMMENTlink modified 12.2 years ago by Martin Morgan ♦♦ 24k • written 12.2 years ago by Thomas Elliott20
Answer: newbie Q about object identity
0
gravatar for Martin Morgan
12.2 years ago by
Martin Morgan ♦♦ 24k
United States
Martin Morgan ♦♦ 24k wrote:
Hi Thomas -- ExpressionSet and many methods that operate on it are defined in Biobase. In your second session, you load the object but not Biobase. Hence there are no methods for doing things like 'show'ing the expression set, and you get the default 'show' (listing slots, etc., rather than a more tidy 'show' method defined in Biobase). genefilter depends on Biobase, which causes Biobase to be loaded, and voila, the missing methods are available. The object is the same. The issues are two-fold. One is saving an object to disk but not reloading its package when the object is loaded. The argument for the current behavior is that the user should get what they request (the object) and not be surprised with other unexpected stuff (for instance, loading a package like Biobase changes the search path, i.e., the order of places where R looks for symbol definitions). The second is the separation of data definitions from their methods (unlike say Java where data and methods are bundled into a single class). This means that even if the Biobase package were loaded, methods could be defined in other packages, and indeed not in packages at all. So even if the package where ExpressionSet was defined were loaded, it wouldn't guarantee that all relevant methods were available. Hope that helps. The bottom line is: load Biobase first, then the data objects. Martin Thomas Elliott <telliott at="" hsc.wvu.edu=""> writes: > 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" > > 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. > > 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
ADD COMMENTlink written 12.2 years ago by Martin Morgan ♦♦ 24k
Answer: newbie Q about object identity
0
gravatar for James W. MacDonald
12.2 years ago by
United States
James W. MacDonald52k wrote:
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
ADD COMMENTlink written 12.2 years ago by James W. MacDonald52k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 217 users visited in the last hour