[Bioc-devel] eSet extension
Martin Morgan
mtmorgan at fhcrc.org
Tue Jul 19 00:03:00 CEST 2011
On 07/18/2011 01:34 PM, Kasper Daniel Hansen wrote:
> I am interested in extending the eSet class. Specifically I want to
> have a number of specifically name elements in my assayData slot (I
> also have additional slots, but leave that aside). It looks like a
> way to achieve this is by
>
> setClass("RGChannelSet",
> contains = "eSet",
> validity = function(object) {
> ## msg<- validMsg(NULL,
> Biobase:::isValidVersion0(object, "RGChannelSet"))
> msg<- validMsg(NULL,
> assayDataValidMembers(assayData(object),
> c("Red",
> "Green")))
> if (is.null(msg)) TRUE else msg
> })
>
> (this is clearly a two color array). However, this fails in the sense that
>
> new("RGChannelSet")
>
> fails, presumably because nothings tells initialize that these two
> elements of assayData needs to be there. Looking at the code for
> ExpressionSet and NChannelset, it seems like the way around this is to
> write a big initialize method that takes care of this. I have done
> so, essentially copying most of the code from intialize-eSet, but this
> seems like code duplication. Is there any other approach?
I'm a little rusty on ExpressionSet. I would have thought that providing
a prototype would help, but apparently not. So I ended up with
setClass("RGChannelSet", contains = "eSet")
setValidity("RGChannelSet", function(object) {
msg <- validMsg(NULL,
assayDataValidMembers(assayData(object),
c("Red", "Green")))
if (is.null(msg)) TRUE else msg
})
setMethod(initialize, "RGChannelSet",
function(.Object, ...,
assayData=assayDataNew(Red=matrix(), Green=matrix()))
{
callNextMethod(.Object, ..., assayData=assayData)
})
ExpressionSet has some unusual wrinkles. Also, it might make sense to
extend NChannelSet instead of eSet.
Martin
>
> Now, one may ask, why do I care, because even if new("RGChannelSet")
> does not work, stuff like
> new("RGChannelSet", Red = SOMETHING, Green = SOMETHING)
> still works. However, it is impossible to further extend my
> RGChannelSet without errors, ie., something like
> setClass("RGChannelExt", contains = "RGChannelSet")
> fails.
>
> Kasper
>
> _______________________________________________
> Bioc-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel
--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109
Location: M1-B861
Telephone: 206 667-2793
More information about the Bioc-devel
mailing list