[BioC] adapt exprSet class

Martin Morgan mtmorgan at fhcrc.org
Wed Oct 3 18:10:55 CEST 2007


Hi Sjoerd --

Actually, you want to start with eSet. The next steps are likely the
vignettes ExpressionSetIntroduction (more end-user oriented) and
BiobaseDevelopment (developer oriented) in Biobase.

> library(Biobase)
> openVignettes()

I'd then recommend a little refection on the data you're trying to
model. In some ways an eSet is a way to organize one or more matrices
with identical structure (in the assayData slot) with annotations on
the rows (featureData) and columns (phenoData) and on the object as a
whole (experiementData). How does this fit in with your data? If the
fit is good, then likely you'll want to extend the eSet class; the
AnnotatedDataFrame class might be useful to incorporate into other
classes where you want a data frame with metadata about columns. The
most basic extension is

> setClass("MyClass", contains="eSet")

If your data model is somehow more elaborate than an eSet, you might
add slots to the class, using the 'representation' argument to
setClass. You'll also likely add a function to check validity of
objects, using the 'validity' argument or setValidity
function. Perhaps your data is not all like eSet, and then you should
either find another suitable class or start from scratch.

Having decided what your data looks like, I'd then suggest going on to
define methods for what you'd like to do with your data. These likely
include 'accessors' to retrieve slots, 'show' and subset ([, [[, $)
methods, etc. If your class is as simple as above, then likely these
methods have already been defined for you, your object inherits
them from eSet, and you don't have to do anything more.

> showMethods(class="eSet")

An eSet is defined to contain an assayData slot, but does not specify
what is in the assayData. You'll likely put a particular type of data
there, and want to write accessors for that data. For instance, the
ExpressionSet class puts a matrix of expression values in the
assayData. There are accessors to retrieve and set these. They look
like

setMethod("exprs", ...

setReplaceMethod("exprs, ...

in Biobase/R/methods-ExpressionSet.R. Likely your object will contain
some type of data different from expression values, so you'll define a
new accessors for your data. On the other hand, if your assayData
_does_ contain something conceptually identical to 'exprs', then you
might consider a class that contains 'ExpressionSet' rather than
'eSet'. You'll then automatically inherit the  'exprs' accessors (and
also the constraints on what assayData can contain to be a valid
ExpressionSet.

You'll likely want to define an 'initialize' method, to create your
object when you or the user calls new("MyClass"). The initialize (and
other) method will almost certainly use 'callNextMethod' to initialize
the classes that your class extends from.

The key help pages are probably ?Classes, ?Methods, ?setClass,
?setGeneric, ?setMethod.

Hope that's enough to get going. The bioc-devel list might be a better
forum to continue this discussion.

Martin

"Vosse, S.J." <S.Vosse at vumc.nl> writes:

> Dear all,
>
>  
>
> to add greater structure to the data exported by our package, we have
> been advised to work with S4 classes. As a starting point we would like
> to adapt the exprSet class, by adding new slots for example. I'm having
> a very hard time finding out where to start though. Does anybody have
> any pointers to documentation on S4 classes and the exprSet class?
>
>  
>
> Thanking you in advance,
>
>  
>
> Sjoerd Vosse
>
>  
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> 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

-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org



More information about the Bioconductor mailing list