equiv.nodes | R Documentation |
For a given set of trees of close construction (i.e., tips in common), this function returns the equivalences in node labels (or numbers if no node labels are provided) for each node given the subtaxa of each
equiv.nodes(trees,nodes,equitips=NULL,out=c("matrix","vector"),out.collapse="/")
trees |
Phylogenetic trees to consider |
nodes |
Optional. The nodes to be compared; without specifying it, all nodes of all trees are compared. Can be the node number (from 1 to the number of nodes, or from the number of tips +1 to the number of tips + number of nodes) |
equitips |
Optional. If there are "equivalent tips" between phylogenies (i.e., same tip but not same label for that tip), they should be provided as a list of vectors, each containing the equivalent labels (the first one being to be used) |
out |
The type of output. Can be a matrix (if |
out.collapse |
The way to collate node labels (or numbers) if a vector is desired as output. Default is set to |
require(ape)
require(phytools)
# Get three random trees of 20, 19, and 21 tips (hence with some tips not present in all trees)
## Start by having the larger tree, of 21 tips
set.seed(1)
tree<-rtree(21)
plot(tree)
axisPhylo()
## Removing taxon #10 to get the first other tree
arrows(nodeHeights(tree)[tree$edge[,2]==10,2]+0.3,10,nodeHeights(tree)[tree$edge[,2]==10,2]+0.13,10,length=0.1,lwd=3,col="red")
## Removing the taxa #5 and #14 for the second other tree
for(i in c(5,14)){
arrows(nodeHeights(tree)[tree$edge[,2]==i,2]+0.3,i,nodeHeights(tree)[tree$edge[,2]==i,2]+0.13,i,length=0.1,lwd=3,col="green3")
}
trees<-c(drop.tip(tree,10),drop.tip(tree,c(5,14)),tree)
# Getting node equivalences
equiv.nodes(trees)
# Checking node names and equivalence
par(mfrow=c(1,3),mar=rep(0,4))
for(i in 1:3){
plot(trees[[i]],show.tip.label = FALSE)
nodelabels()
tiplabels()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.