PageRenderTime 21ms CodeModel.GetById 19ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/working/auteur.extended/R/prunelastsplit.R

http://github.com/eastman/auteur
R | 12 lines | 9 code | 1 blank | 2 comment | 1 complexity | 19a7cd370b094213b7a22c209ac9967b MD5 | raw file
 1#general phylogenetic utility for pruning the most recent speciation event from a phylogeny
 2#author: JM EASTMAN 2010
 3
 4prunelastsplit<-function(phy) {
 5	require(ape)
 6	nn=as.numeric(names(xx<-branching.times(phy))[which(xx==min(xx))])
 7	for(node in 1:length(nn)) {	
 8		sp=sample(phy$edge[which(phy$edge[,1]==nn[node]),2],1)
 9		obj=drop.tip(phy,phy$tip.label[sp])
10	}
11	return(obj)
12}