[Phylobase-commits] r120 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Feb 24 19:44:26 CET 2008


Author: jombart
Date: 2008-02-24 19:44:26 +0100 (Sun, 24 Feb 2008)
New Revision: 120

Modified:
   pkg/R/phylo4.R
Log:
Summary of phylo4: when there are polytomies, compute the degree of the nodes and the type of polytomy (no, internal or terminal). NEEDS TESTING.


Modified: pkg/R/phylo4.R
===================================================================
--- pkg/R/phylo4.R	2008-02-23 23:33:10 UTC (rev 119)
+++ pkg/R/phylo4.R	2008-02-24 18:44:26 UTC (rev 120)
@@ -357,8 +357,19 @@
         res$sumry.el <- NULL
     }
 
-    ##TODO: polytomies
-    ## I'll finish this - Tibo
+    ## polytomies
+    if(hasPoly(x)){ # if there are polytomies
+        E <- edges(x)
+        temp <- tabulate(E[,1])
+        degree <- temp[E[,1]] # contains the degree of the ancestor for all edges
+        endsAtATip <- !(E[,2] %in% E[,1])
+        terminPoly <- (degree>2) & endsAtATip
+        internPoly <- (degree>2) & !endsAtATip
+        res$degree <- degree
+        res$polytomy <- rep("no poly.",nrow(E))
+        res$polytomy[terminPoly] <- "terminal poly."
+        res$polytomy[internPoly] <- "internal poly."
+    }
     
     ## model info
     res$loglik <- attr(x, "loglik")
@@ -387,6 +398,10 @@
         cat("        distribution :\n")
         print(res$sumry.el)
     }
+    if(hasPoly(x)){
+        cat("\nDegree of the nodes  :", res$degree, "\n")
+        cat("Polytomies at the nodes:", res$polytomy, "\n")
+    }
     
     if (!is.null(attr(x, "loglik"))) {
         cat("Phylogeny estimated by maximum likelihood.\n")



More information about the Phylobase-commits mailing list