如何相对于系统发育树上的树梢调整梢标签的位置? [英] How can I adjust the position of tip labels relative to tree tips on a phylogenetic tree?

查看:78
本文介绍了如何相对于系统发育树上的树梢调整梢标签的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 R 中的 ape phytools 软件包在系统发育树上创建连续性状图的图用于出版物.我尝试生成的示例代码如下:

I am trying to create a figure of a map of a continuous trait onto a phylogenetic tree using the ape and phytools packages in R for a publication. An example code of what I am trying to produce is as follows:

library("ape")
library("phytools")
orig_tree<-rtree(n=350)
plot(orig_tree)
values<-data.frame("residuals"=runif(350,min=-1,max=1),row.names=orig_tree$tip.label)
values<-setNames(values$residuals,rownames(values))
residualsignalfit<-fastAnc(orig_tree,values,vars=TRUE,CI=TRUE)
obj<-contMap(orig_tree,values,plot=FALSE)
plot(obj,type="fan",fsize=.1,lwd=0.5)

唯一的区别是分支的末端长度相同,因为它们都是活的类群,但这足以说明我遇到的问题.我在这棵树中有大量的分类单元,因此必须使用 fsize = 参数将文本缩小到相当小的范围,以使其清晰易读.但是,从示例代码中可以看到,这样做会导致每个物种名称的末端被系统树的轮廓所遮盖.我尝试删除该轮廓,但是这使得系统发育的热图非常难以阅读.我一直找不到缩小轮廓厚度的方法,它似乎是自动生成的.

The only difference is the terminal of the branches are all the same length because they are all living taxa, but this works well enough to illustrate the problem I am having. I have a large number of taxa in this tree, and as a result I have to shrink the text down fairly small using the fsize= argument to make them legible. However, as you can see from the example code, doing so causes the ends of each species name to be obscured by the outline for the phylogenetic tree. I have tried removing the outline but it makes the heatmap of the phylogeny very hard to read. I have been unable to find any way to reduce the thickness of the outline, it seems to be automatically generated.

我还尝试将 cex 命令添加到 plot(obj ...),但是它对生成的树完全没有影响.

I also tried adding the cex command to plot(obj...), but it has no effect on the produced tree at all.

我要弄清楚的方法是如何放置尖端标签,以使其更清晰,并且没有被树的轮廓所遮盖.我不能使用 dplyr mutate 函数或类似的方法在每个终端的前面简单地添加一个空格,因为分类单元名称的位置并不总是一致的,有时是左侧该名称的名称附加在笔尖上,而其他时候则在右侧.我尝试不以风扇的形式绘制数据,但这最终会导致创建一个具有大量死区的图形,原因是我在树中有一些非常深的裂缝(基本上将图形绘制为朝右的树结果)一半的数字是死空间,因为我的分类单元在中生代分叉,但仅在KT边界之后才出现.

What I am trying to figure out how to do is how to position the tip labels in order to make them more legible and not covered up by the outline for the tree. I cannot simply add a space in front of each terminal using the dplyr mutate function or something like that because the position of the taxon name is not always consistent, sometimes the left side of the name is attached to the tip and other times it is the right side. I have tried not plotting the data as a fan, but this ends up creating a figure with a huge amount of dead space due to the fact I have some very deep splits within the tree (basically plotting the figure as a right-facing tree results in half of the figure being dead space because my taxa diverged in the Mesozoic but only speciated after the K-T boundary).

推荐答案

您可以将树放大,而不是缩小文本.您可以将绘图导出为具有特定宽度和高度的图像.将两者都设置为20应该可以使所有笔尖标签清晰可见.

Instead of shrinking the text down, you can scale the tree up. You can export the plot as image with a specific width and height. Setting both to 20 should make all tip labels legible.

类似

setEPS()
postscript("output.eps", width = 20, height = 20)
plot(obj,type="fan",lwd=0.5)
dev.off()

这会将图保存到 output.eps ,而不是在默认查看器中显示.因此,它不受屏幕尺寸的限制.您仍然需要摆弄 lwd fsize 的最佳值,但是根据我的经验,当您有一块大画布时,这要容易得多.

This saves the plot to output.eps instead of showing it in the default viewer. So it is not restricted by the screen size. You still need to fiddle around with the best values of lwd and fsize, but in my experience it is much easier, when you have a big canvas.

对不起, width height 的单位是英寸而不是像素.因此,将其设置为10或20.

Sorry, the unit of width and height is inches not pixels. So rather set it to 10 or 20.

这篇关于如何相对于系统发育树上的树梢调整梢标签的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆