I am having a hard time trying to add several fossil tips to a 100 phylogenetic time trees.
Here is a drawing of what I want to do:
I would like to do it for my 100 trees contained in a single nexus file.
Thank you in advance.
EDIT:
Okay, I figured out how to do it. Here is the code for the example:
library(phytools)
tree <- read.tree(text = '(A:20,(B1:5,B2:5):15);')
plot(tree)
nodelabels()
edgelabels()
case1 <- bind.tip(tree, tip.label="Fossil tip 1", where=which(tree$tip.label=="A"), position = 10, edge.length=10)
plot(case1)
case2 <- bind.tip(tree, tip.label="Fossil tip 2", where=5, position=0.5*tree$edge.length[2], edge.length=0.5*tree$edge.length[2]+tree$edge.length[3])
plot(case2)
case3 <- bind.tip(tree, tip.label="Fossil tip 3", where=5, position=0.5*tree$edge.length[2], edge.length=(0.5*tree$edge.length[2]+tree$edge.length[3])-10)
plot(case3)
And here is the code fo my data:
library(phytools)
mammif <- read.nexus(file.choose()) #100 phyogenetic time trees
tree <- mammif$tree_7736 #for the first tree
plot(tree)
nodelabels()
edgelabels()
case1 <- bind.tip(tree, tip.label="Fossil tip 1", where=which(tree$tip.label=="Tupaia_belangeri"), position = 30, edge.length=30)
plot(case1)
case2 <- bind.tip(tree, tip.label="Fossil tip 2", where=36, position=0.5*tree$edge.length[21], edge.length=0.5*tree$edge.length[21]+tree$edge.length[22])
plot(case2)
case3 <- bind.tip(tree, tip.label="Fossil tip 3", where=33, position=0.5*tree$edge.length[13], edge.length=(0.5*tree$edge.length[13]+tree$edge.length[14])-10)
plot(case3)
The code works just fine for the first tree. I would like to loop it for the rest of the trees but the thing is that the nodes and the edges can change between the trees. I think it would be easier to designate the taxa of a clade rather than a node and the edge leading to a taxon rather than an edge number. Any idea?