[BioC] problem extending Category classes

Robert M. Flight rflight79 at gmail.com
Thu Dec 23 20:58:01 CET 2010


Hi Martin,

Well that looks like it should help me out. I had tried something
similar, but I was trying it on the GOHyperGParams class, and that
kept dying on me, so I didn't see it.

So this will work:

> setClass("H",
+ contains="HyperGParams",
+ prototype=prototype(annotation="GO"))
[1] "H"
> H1 <- new("H")
> H1
A H instance
  category:
annotation: GO

> setClass("I",
+ contains="H",
+ representation=representation(numrep="numeric"),
+ prototype=prototype(numrep=1))
[1] "I"
> I1 <- new("I")
> I1
A I instance
  category:
annotation: GO


But, I can't do it from the GOHyperGParam directly, and this is what
was tripping me up earlier. I didn't think to go back a step and put
in a default.

> setClass("H",
+ contains="GOHyperGParams",
+ prototype=prototype(annotation="GO"))
Loading required package: .db
Error in DatPkgFactory(annotation) :
  annotation package '.db' not available
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE,  :
  there is no package called '.db'

And this is due to the DatPkgFactory function needing some kind of
default annotation. Ok, weird, but I think I can make it work.

Thanks,

-Robert


On Thu, Dec 23, 2010 at 14:33, Martin Morgan <mtmorgan at fhcrc.org> wrote:
> Hi Robert --
>
> On 12/23/2010 09:48 AM, Robert M. Flight wrote:
>> Hi All,
>>
>> I am trying to make my own package a little easier to use, and want to
>> extend some of the Category parameter classes. I can easily extend the
>> primary virtual class without any problems, but I run into
>> difficulties if I first extend the virtual class, and then try and
>> extend that, or extend any of the other classes already built on it. I
>> want to add just one slot to the classes, but would rather not
>> redefine a bunch of stuff if the previously defined classes already
>> have what I need (which is what I would do if I extended the
>> HyperGParams class directly).
>>
>> Two examples should illustrate what I am trying to do and the problem.
>>
>>
>> Extend the VIRTUAL class "HyperGParams", works as expected
>>
>>> setClass("T1",
>> +          contains="HyperGParams",
>> +          representation=representation(numrep="numeric"),
>> +          prototype=prototype(numrep=1))
>> [1] "T1"
>
> not quite --
>
>> new("T1")
> Loading required package: .db
> Error in DatPkgFactory(annotation) :
>  annotation package '.db' not available
> In addition: Warning message:
> In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
>  there is no package called '.db'
>
> And simpler
>
>> setClass("H", "HyperGParams")
> [1] "H"
>> new("H")
> Loading required package: .db
> Error in DatPkgFactory(annotation) :
>  annotation package '.db' not available
> In addition: Warning message:
> In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
>  there is no package called '.db'
>
> A solution is to provide a default for the 'annotation' slot, along the lines of
>
>> setClass("H", "HyperGParams",
> +          prototype=prototype(annotation="GO"))
> [1] "H"
>> new("H")
> A H instance
>  category:
> annotation: GO
>
> Martin
>
>>
>>
>> Now lets extend it to something like the "GOHyperGParams"
>>
>>> setClass("GOT1",
>> + contains="T1",
>> +         representation=representation(ontology="character",
>> +                         conditional="logical"),
>> +         prototype=prototype(categoryName="GO",
>> +            conditional=FALSE))
>> Loading required package: .db
>> Error in DatPkgFactory(annotation) :
>>   annotation package '.db' not available
>> In addition: Warning message:
>> In library(package, lib.loc = lib.loc, character.only = TRUE,
>> logical.return = TRUE,  :
>>   there is no package called '.db'
>>
>>
>> This behavior seems to be caused by the DatPkgFactory function in
>> Category, but I can't figure out how to get around it in the class
>> definition
>>
>>
>> Ok, what about trying to extend the GOHyperGParams directly then?
>>
>>> setClass("T2",
>> +          contains="GOHyperGParams",
>> +          representation=representation(numrep="numeric"),
>> +          prototype=prototype(numrep=1))
>> Loading required package: .db
>> Error in DatPkgFactory(annotation) :
>>   annotation package '.db' not available
>> In addition: Warning message:
>> In library(package, lib.loc = lib.loc, character.only = TRUE,
>> logical.return = TRUE,  :
>>   there is no package called '.db'
>>
>> Same problem. Is this expected behavior? Is there a way to get around
>> this? I would really appreciate any insight someone might have into
>> this.
>>
>>> sessionInfo()
>> R version 2.12.0 (2010-10-15)
>> Platform: x86_64-pc-mingw32/x64 (64-bit)
>>
>> locale:
>> [1] LC_COLLATE=English_United States.1252
>> [2] LC_CTYPE=English_United States.1252
>> [3] LC_MONETARY=English_United States.1252
>> [4] LC_NUMERIC=C
>> [5] LC_TIME=English_United States.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] GOstats_2.16.0       RSQLite_0.9-3        DBI_0.2-5
>> [4] graph_1.28.0         Category_2.16.0      AnnotationDbi_1.12.0
>> [7] Biobase_2.10.0
>>
>> loaded via a namespace (and not attached):
>>  [1] annotate_1.28.0   genefilter_1.32.0 GO.db_2.4.5       GSEABase_1.12.1
>>  [5] RBGL_1.26.0       splines_2.12.0    survival_2.36-1   tools_2.12.0
>>  [9] XML_3.2-0.2       xtable_1.5-6
>>
>>
>> Regards,
>>
>> -Robert
>>
>> Robert M. Flight, Ph.D.
>> University of Louisville Bioinformatics Laboratory
>> University of Louisville
>> Louisville, KY
>>
>> PH 502-852-0467
>> EM robert.flight at louisville.edu
>> EM rflight79 at gmail.com
>>
>> Williams and Holland's Law:
>>        If enough data is collected, anything may be proven by
>> statistical methods.
>>
>> _______________________________________________
>> Bioconductor mailing list
>> Bioconductor at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>
>
> --
> 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 Bioconductor mailing list