[BioC] newbie Q about object identity
Martin Morgan
mtmorgan at fhcrc.org
Wed Oct 10 15:54:02 CEST 2007
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
More information about the Bioconductor
mailing list