[Adephylo-commits] r6 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Nov 20 17:17:41 CET 2008


Author: jombart
Date: 2008-11-20 17:17:41 +0100 (Thu, 20 Nov 2008)
New Revision: 6

Added:
   pkg/R/partition.R
Log:
Added a source file: functions partitioning a tree into groups of tips.


Added: pkg/R/partition.R
===================================================================
--- pkg/R/partition.R	                        (rev 0)
+++ pkg/R/partition.R	2008-11-20 16:17:41 UTC (rev 6)
@@ -0,0 +1,25 @@
+##
+## Functions to obtain partitions of tips from a tree.
+## For instance to obtain dummy vectors used in the orthogram.
+##
+
+############
+# listTips
+############
+listTips <- function(tree){
+    if(!require(phylobase)) stop("phylobase package is not installed")
+
+    x <- tree
+    ## conversion from phylo4 and phylo4d
+    x <- as(x, "phylo4")
+
+    ## check phylo4 object
+    if (is.character(checkval <- check_phylo4(res))) stop(checkval)
+
+    ## computations
+    res <- lapply(nodeLabels(x), function(e) descendants(x, e))
+
+    names(res) <- nodeLabels(x)
+
+    return(res)
+}



More information about the Adephylo-commits mailing list