[Adephylo-commits] r15 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Nov 21 11:29:20 CET 2008
Author: jombart
Date: 2008-11-21 11:29:20 +0100 (Fri, 21 Nov 2008)
New Revision: 15
Modified:
pkg/R/partition.R
Log:
Commented out shortestPath -> moved to phylobase package. This is definitely part of treewalk stuff.
Modified: pkg/R/partition.R
===================================================================
--- pkg/R/partition.R 2008-11-20 19:55:17 UTC (rev 14)
+++ pkg/R/partition.R 2008-11-21 10:29:20 UTC (rev 15)
@@ -96,33 +96,38 @@
###############
# shortestPath
###############
-shortestPath <- function(x, node1, node2){
- if(!require(phylobase)) stop("phylobase package is not installed")
+## shortestPath <- function(x, node1, node2){
+## if(!require(phylobase)) stop("phylobase package is not installed")
- ## conversion from phylo, phylo4 and phylo4d
- x <- as(x, "phylo4")
+## ## conversion from phylo, phylo4 and phylo4d
+## x <- as(x, "phylo4")
- ## check phylo4 object
- if (is.character(checkval <- check_phylo4(x))) stop(checkval)
+## ## come checks
+## if (is.character(checkval <- check_phylo4(x))) stop(checkval)
+## t1 <- getnodes(x, node1)
+## t2 <- getnodes(x, node2)
+## if(any(is.na(c(t1,t2)))) stop("wrong node specified")
+## if(t1==t2) return(NULL)
- ## main computations
- t1 <- getnodes(x, node1)
- t2 <- getnodes(x, node2)
+## ## main computations
+## comAnc <- MRCA(x, t1, t2) # common ancestor
+## desComAnc <- descendants(x, comAnc, which="all")
+## ancT1 <- ancestors(x, t1, which="all")
+## path1 <- intersect(desComAnc, ancT1) # path: common anc -> t1
- comAnc <- MRCA(x, t1, t2) # common ancestor
- desComAnc <- descendants(x, comAnc, which="all")
- ancT1 <- ancestors(x, t1, which="all")
- path1 <- intersect(desComAnc, ancT1) # path: common anc -> t1
+## ancT2 <- ancestors(x, t2, which="all")
+## path2 <- intersect(desComAnc, ancT2) # path: common anc -> t2
- ancT2 <- ancestors(x, t2, which="all")
- path2 <- intersect(desComAnc, ancT2) # path: common anc -> t2
+## res <- union(path1, path2) # union of the path
+## ## add the common ancestor if it differs from t1 or t2
+## if(!comAnc %in% c(t1,t2)){
+## res <- c(comAnc,res)
+## }
- res <- union(path1, path2) # union of the path
- res <- c(comAnc,res) # add the common ancestor
- res <- getnodes(x, res)
+## res <- getnodes(x, res)
- return(res)
-} # end shortestPath
+## return(res)
+## } # end shortestPath
More information about the Adephylo-commits
mailing list