[Phylobase-devl] patch for nodeId
François Michonneau
francois.michonneau at gmail.com
Tue Mar 31 01:55:54 CEST 2009
Hello -
I realized that nodeId wasn't returning some nodes ID if the tree wasn't
fully dichotomous. I propose the following patch to fix this. It
slightly changes the order in which the nodes are returned compared to
the old version. However, it didn't in the code a place where it
matters. Does anybody have another suggestion to fix the problem or have
an opinion about the order nodeId needs to return the nodes ID?
Cheers,
-- François
BEFORE
> nodeId(geospiza, "internal")
[1] 16 17 18 19 20 21 22 23 24 25 26 27 15
> nodeId(geospiza, "all")
[1] 16 17 18 19 20 21 22 23 24 1 2 3 4 5 6 25 7 26 27 8 9 10
11 12 13
[26] 14 15
__________________________________________________________________________
AFTER
> nodeId(geospiza, "internal")
[1] 15 16 17 18 19 20 21 22 23 24 25 26 27
> nodeId(geospiza, "tip")
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14
> nodeId(geospiza, "all")
[1] 15 16 17 18 19 20 21 22 23 24 25 26 27 1 2 3 4 5 6 7 8 9
10 11 12
___________________________________________________________________________
NEW VERSION
setMethod("nodeId", "phylo4",
function(x,which=c("internal","tip","allnode")) {
which <- match.arg(which)
tipNid <- x at edge[x at edge[,2]<=nTips(x),2]
allNid <- unique(as.vector(x at edge))
intNid <- allNid[! allNid %in% tipNid]
nid <- switch(which,
internal = intNid,
tip = tipNid,
allnode = allNid)
#nid <- switch(which,
# internal=x at edge[x at edge[,2]>nTips(x),2],
# tip = x at edge[x at edge[,2]<=nTips(x),2],
# allnode = x at edge[,2])
return(nid[!is.na(nid)])
})
More information about the Phylobase-devl
mailing list