使用点将尖端标签链接到系统树 [英] Link tip labels to phylogenetic tree using dots
问题描述
我正在尝试使用R中的ape包和函数plot.phylo()来生成非超常树.我正在努力寻找有关如何使尖端标签的左侧边缘垂直对齐以及一系列将物种名称链接到节点尖端的点(可变长度)的文档.
I'm trying to produce a non-ultrametric tree using the ape package in R and the function plot.phylo(). I'm struggling to find any documentation on how to keep the tip label vertically aligned on their left edge and with a series of dots (variable length) linking the species' name to the tip of the node.
任何帮助以及R内其他可能实现此目的的软件包的链接将不胜感激.
Any help would be much appreciated as well as links to other packages within R that may be able to achieve this.
我没有我想要的任何树形示例,但是,描述似乎很容易解释.标签将全部移至最右侧,并在其左侧对齐,然后一系列的点(..)将标签链接到旧位置.
I don't have any tree examples of what i want, however, the description seems self explanatory. the labels would all be shifted to the very right, and aligned on their left side, then a series of dots (.......) would link the label to where there old position was.
MLJTT = newickTree (as a string)
plot.phylo(read.tree(text = MLJTT), show.tip.label = T,use.edge.length = T, no.margin = T, cex = 0.55)
我想从在这里:
推荐答案
好,我最终稍微修改了默认的plot.phylo
代码以适应这样的更改.这是它的样子
Ok, I ended up slightly modifying the default plot.phylo
code to accomidate such a change. Here's how it looks
library(ape)
plot.phylo2 <- plot.phylo
environment(plot.phylo2) <- environment(plot.phylo)
body(plot.phylo2)[[c(34, 3, 6, 3, 4, 3)]] <- quote({
mx <- max(xx[1:Ntip])
segments(xx[1:Ntip], yy[1:Ntip] + loy, mx, yy[1:Ntip] + loy,
lty=2, col="grey")
text(mx + lox, yy[1:Ntip] + loy, x$tip.label, adj = adj,
font = font, srt = srt, cex = cex, col = tip.color)
})
这有些脆弱,并且可能在ape
的不同版本中更改,我已经在ape_3.1-4
版本中对此进行了测试.您可以通过验证
This is somewhat fragile and may change in different version of ape
, I've tested this with version ape_3.1-4
. You can check if this will work by verifying that
body(plot.phylo)[[c(34, 3, 6, 3, 4, 3)]]
返回
text(xx[1:Ntip] + lox, yy[1:Ntip] + loy, x$tip.label, adj = adj,
font = font, srt = srt, cex = cex, col = tip.color)
只是为了确保我们更改了正确的行.但是上面的代码基本上是通过移动绘制标签的x轴并添加虚线段来替换绘制标签的那条线.然后,您可以将其与测试数据一起运行
just to make sure we are changing the correct line. But the code above basically replaces that line where the labels are drawn by moving the x axis where they are drawn and adding in the segments for the dotted lines. Then you can run this with your test data
MLJTT = read.tree(text="..<sample data>..")
plot.phylo2(MLJTT,
show.tip.label = T,use.edge.length = T, no.margin = T, cex = 0.55)
这产生了
这篇关于使用点将尖端标签链接到系统树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!