Skip to content
Prev 184 / 21312 Next

[Bioc-devel] S4 validity checking {was "eset.Rnw revised in Biobase"}

.................

    Kasper> 7) So the assayData slot does not have a specific
    Kasper> number/names for its components. I see the need for
    Kasper> this. But let us say I want to use it for a specific
    Kasper> case where I have two assays (let us say a two-
    Kasper> color micro array experiment). Do you imagine that
    Kasper> people will create more specific versions of the
    Kasper> class by something like (code not tested)

(yes, it was missing 3 closing ")" 
  --- quickly seen when using Emacs with "paren match" activated)

    >>    setClass("twoclor", representation("eSet"),
    >>       validity = function(object){
    >>          if(!validObject(as(object, "eSet")))
    >>             return(FALSE)  ## this might be unnecessary
    >>          if(sort(names(assayData(object)) != c("green", "red")))
    >>             return(FALSE)
    >>          else
    >>            return(TRUE)
    >>        })

I want to comment on the above code, since
I think I've seen the same mistake several times in people's code:

Validity checking should  **NOT** return TRUE or FALSE,
but  TRUE or <reason for non-validity> .
This has been in `The Green Book' but also the very first entry in
   ?SetValidity
or ?validObject :
Martin