Есть ли какая-либо функция, которая делает это за один шаг? Я применяю двухшаговый обходной путь
{
require(grid)
require(phytools)
require(ggtree)
set.seed(10)
tree <- rtree(7)
myggtreeplot <- ggtree(tree) + geom_nodepoint() + geom_tiplab() + geom_treescale()
edge=data.frame(parent=tree$edge[,1], node=tree$edge[,2], other=NA,stringsAsFactors = F)
# tree with node names
myggtreeplot %<+% edge + geom_label(aes(x=branch, label=node)) + geom_treescale()
# 1st step: add tip
tree2 <- bind.tip(tree, "new tip", edge.length= 0.5, where= 3, position=0.5)
ggtree(tree2) + geom_nodepoint() + geom_tiplab() + geom_treescale()
# 2nd step: remove to obtain singleton
tree3 <- drop.tip(tree2, "new_tip", collapse.singles = FALSE) # ape
# identify number of node
newtreeplot <- ggtree(tree3) + geom_nodepoint() + geom_tiplab()
edge=data.frame(parent=tree2$edge[,1], node=tree2$edge[,2], other=NA,stringsAsFactors = F)
newtreeplot %<+% edge + geom_label(aes(x=branch, label=node))
{
grid.newpage()
pushViewport(viewport(layout = grid.layout(1, 2)))
pushViewport(viewport(layout.pos.col = 1, layout.pos.row = 1))
print(myggtreeplot,newpage=F)
popViewport()
pushViewport(viewport(layout.pos.col = 2, layout.pos.row = 1))
print( (newtreeplot + geom_point2(aes(subset=(node==11)), shape=21, size=5, fill='green') + geom_treescale() ),
newpage = F )
}
}