[Phylobase-devl] problem with the S4 dispatcher ?
Thibaut Jombart
jombart at biomserv.univ-lyon1.fr
Fri May 23 14:05:46 CEST 2008
Hi list,
I found a problem with our S4 classes, which also occurs in my package
adegenet, and I would like to know if you can reproduce this (I've
reproduced the bug in R2.6.2 for window$ and R2.7.0 compiled from source
on linux Ubuntu 8.04, 32 bits version).
Problem is that methods defined for our objects seems not to be found by
the dispatcher under certain cirumstances. Try this:
######## launch R
library(phylobase)
E = matrix(c(8,9,10,10,9,9,8,11,11,11,9,10,1,2,3,4,11,5,6,7),ncol=2)
foo=phylo4(E)
foo
taxon.name node ancestor branch.length node.type
1 N1 8 NA NA root
2 N2 9 8 NA internal
3 N3 10 9 NA internal
4 N4 11 8 NA internal
5 T1 1 10 NA tip
6 T2 2 10 NA tip
7 T3 3 9 NA tip
8 T4 4 9 NA tip
9 T5 5 11 NA tip
10 T6 6 11 NA tip
11 T7 7 11 NA tip
save.image()
######## all is ok. Now close R, lunch it again, make sure that
phylobase is not loaded (check your .Rprofile)
> foo
Loading required package: phylobase # ! package is loaded, good
Loading required package: ape
An object of class “phylo4”
Slot "edge":
ancestor descendant
[1,] 8 9
[2,] 9 10
[3,] 10 1
[4,] 10 2
[5,] 9 3
[6,] 9 4
[7,] 8 11
[8,] 11 5
[9,] 11 6
[10,] 11 7
Slot "edge.length":
numeric(0)
Slot "Nnode":
[1] 4
Slot "node.label":
[1] "N1" "N2" "N3" "N4"
Slot "tip.label":
[1] "T1" "T2" "T3" "T4" "T5" "T6" "T7"
Slot "edge.label":
[1] "E9" "E10" "E1" "E2" "E3" "E4" "E11" "E5" "E6" "E7"
Slot "root.edge":
[1] NA
########
When calling a method "show" for the signature c("genind"), the
dispatcher loads the package automatically (as it should). The method
exists:
####
> getMethod("show","phylo4")
Method Definition:
function (object)
printphylo4(object)
<environment: 0x878d7e8>
Signatures:
object
target "phylo4"
defined "phylo4"
####
but is not used. I've got the same problem in adegenet. In both case,
'search()' gives the same result. Trying to detach and reload the
package does not help. However, it works if you load manually the
package before calling the method.
The problem does not appear with the package pixmap:
library(pixmap)
x <- pixmapIndexed(rep(1:8, 9), nrow=6, col=terrain.colors(8))
x
save.image()
### close R and launch it again, without loading pixmap ###
x
Pixmap image
Type : pixmapIndexed
Size : 6x12
Resolution : 1x1
Bounding box : 0 0 12 6
Nr. of colors : 8 of 8
### it works ###
However, I've been through the code of the show method used in pixmap,
and I don't see where the crucial difference is. One hint: it does not
seem to lie in the presence of a zzz.R file.
Another hint may be this recent post between Seth Falcon and answers by BR:
http://tolstoy.newcastle.edu.au/R/e2/devel/07/05/3096.html
but I am still working on the translation (anyone being R-core-fluent?)
I'll try do dig in, but any idea will be welcome.
Cheers,
Thibaut.
--
######################################
Thibaut JOMBART
CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive
Universite Lyon 1
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
Tél. : 04.72.43.29.35
Fax : 04.72.43.13.88
jombart at biomserv.univ-lyon1.fr
http://biomserv.univ-lyon1.fr/%7Ejombart/
http://adegenet.r-forge.r-project.org/
More information about the Phylobase-devl
mailing list