I have been developing a Bioconductor package as part of my research at UofL, and a lot of it depends on other classes from another package. The classes in the other package had a function call as part of their initialization, that tended to break whenever these classes were extended as part of new classes.
So in R 2.13.0, it wasn't too hard to get around it:
This generates the following error:
This is due to how the "HyperGParams" class is defined. This happens if you try and extend any of the Category classes, but there is a workaround: give a valid "annotation" to the prototype:
Now, this will work in R 2.13.0, and it will work in R 2.14.1, but what if you want to combine this class with another in a new class?
Note that "GOHyperGParams" also has the "annotation" slot initialized to something useful to avoid the error above.
Now what happens in R 2.14.1?
We get the same error as before! Why?
In R 2.13.0, we were actually creating a new definition of "GOHyperGParams" in the local workspace. However, in 2.14.1, we are no longer allowed to create a duplicate class with the same name. Therefore, to modify it we need to explicitly modify the copy in the original package "Category", like so:
A final twist for embedding this in our new package, is that we have to explicitly import the classes from the other package using "ImportClassFrom" in the NAMESPACE file:
This was much looser in previous implementations, and I'm guessing this is going to help make coding better for developers in R as they have to be a little more explicit about what is going on. It has taken some time for me to learn, as I have only one programming course way back in C, and no formal OO, everything I have learned has been in writing my own package for Bioconductor.
No comments:
Post a Comment