[Phylobase-devl] [phylobase-Bugs][177] MRCA of identical taxa is one node down

phylobase-bugs at r-forge.r-project.org phylobase-bugs at r-forge.r-project.org
Thu Dec 18 04:56:58 CET 2008


Bugs item #177, was opened at 2008-07-25 14:13
>Status: Closed
Priority: 3
Submitted By: Brian O'Meara (bcomeara)
Assigned to: Nobody (None)
Summary: MRCA of identical taxa is one node down 
Component: None
Resolution: None
Severity: normal
Version: None
Operating System: MacOS X
URL: 


Initial Comment:
I'm creating a variance-covariance matrix from a phylo4 object. MRCA(tree,taxonA,taxonB) gives their MRCA correctly if A!=B. However, If A==B, it should give the tip node as the most recent common ancestor, but instead gives one node further down. For example, I have a tree where "taxon14" and "taxon15" are sister species and their MRCA is N04. If I enter the following commands:
> MRCA(td,"taxon14","taxon15")
N04 
 24 
> MRCA(td,"taxon14","taxon14")
N04 
 24 
You see that a taxon and its sister taxon have the same MRCA as the taxon does with itself. I'm not changing it myself in case this is the intended behavior, but it doesn't seem like it should be (after all, individuals on the edge subtending taxon14 are ancestors of taxon14 of more recent ancestry than the parent node is).

----------------------------------------------------------------------

Comment By: François Michonneau (francois)
Date: 2008-09-22 16:07

Message:
I propose the following patch to fix this bug. If nobody disagrees I'll commit it.

 ## get ancestors (all nodes)
-ancestors <- function (phy, node, which=c("all","parent")) 
+ancestors <- function (phy, node, which=c("all","parent"))
 {
     which <- match.arg(which)
     if (which=="parent") return(ancestor(phy,node))
@@ -105,6 +105,14 @@
     if (length(nodes)==1 && length(nodes[[1]])>1) {
         nodes <- as.list(nodes[[1]])
     }
-    ancests <- lapply(nodes,ancestors,phy=phy)
-    getnodes(phy,max(Reduce(intersect,ancests)))
+    ## Correct behavior in case of MRCA of identical taxa
+    testNodes <- lapply(nodes, getnodes, phy=phy)
+    uniqueNodes <- unique(testNodes)
+    if(length(uniqueNodes) == 1) {
+        uniqueNodes[[1]]
+    }
+    else {
+        ancests <- lapply(nodes,ancestors,phy=phy)
+        getnodes(phy,max(Reduce(intersect,ancests)))
+    }
 }


----------------------------------------------------------------------

You can respond by visiting: 
http://r-forge.r-project.org/tracker/?func=detail&atid=488&aid=177&group_id=111


More information about the Phylobase-devl mailing list