[Picante-commits] r194 - branches/will/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Nov 19 00:09:24 CET 2009
Author: will_cornwell
Date: 2009-11-19 00:09:24 +0100 (Thu, 19 Nov 2009)
New Revision: 194
Added:
branches/will/R/evol.distinct.R
Log:
initial import of ed function
Added: branches/will/R/evol.distinct.R
===================================================================
--- branches/will/R/evol.distinct.R (rev 0)
+++ branches/will/R/evol.distinct.R 2009-11-18 23:09:24 UTC (rev 194)
@@ -0,0 +1,24 @@
+#Evolutionary distinctiveness by equal splits (Redding and Mooers 2006)
+
+ED.equal.splits<- function(tree){
+
+for(i in 1:length(tree$tip.label)){
+ spp<- tree$tip.label[i]
+ nodes<- get.nodes(tree, spp)
+ #get rid of root node
+ nodes<- nodes[1:(length(nodes)-1)]
+
+ brlen<- tree$edge.length[which(tree$edge[,2] %in% nodes)]
+ portion<- sort(rep(.5, length(brlen))^c(1:length(brlen)))
+ brlen<- brlen*portion
+ ED<- sum(brlen, tree$edge.length[which.edge(tree, spp)])
+
+ if(i==1)
+ w<- ED else
+ w<- c(w, ED)
+ }
+results<- cbind(tree$tip.label, as.data.frame(w))
+names(results)<- c("Species", "w")
+results
+
+ }
\ No newline at end of file
More information about the Picante-commits
mailing list