如何使用大型数据集绘制树状图?
我在 R 中使用 ape(系统发育和进化分析)包,它具有树状图绘制功能。我使用以下命令读取 Newick 格式的数据,并使用绘图函数绘制树状图:
library("ape")
gcPhylo <-read.tree(file = "gc.tree")
plot(gcPhylo, show.node.label = TRUE)
由于数据集非常大,因此不可能看到树的较低级别的任何细节。我只能看到黑色区域,但看不到细节。我只能从顶部看到几层,然后看不到细节。
我想知道绘图功能是否有缩放功能。我尝试使用 xLim 和 yLim 限制区域,但是,它们只是限制区域,并且不会缩放以使细节可见。缩放或在不缩放的情况下使细节可见将解决我的问题。
我也很高兴知道任何其他可以帮助我克服问题的包、函数或工具。
谢谢。
I am using ape (Analysis of Phylogenetics and Evolution) package in R that has dendrogram drawing functionality. I use following commands to read the data in Newick format, and draw a dendrogram using the plot function:
library("ape")
gcPhylo <-read.tree(file = "gc.tree")
plot(gcPhylo, show.node.label = TRUE)
As the data set is quite large, it is impossible to see any details in the lower levels of the tree. I can see just black areas but no details. I can only see few levels from the top, and then no detail.
I was wondering if there is any zoom capability of the plot function. I tried to limit the area using xLim and yLim, however, they just limit the area, and do not zoom to make the details visible. Either zooming, or making the details visible without zooming will solve my problem.
I am also appreciated to know any other package, function, or tool that will help me overcoming the problem.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以在指定高度
切割
树状图并绘制元素:首先使用内置数据集
USArrests
创建聚类。然后转换为dendrogram
:接下来,使用
cut.dendrogram
在指定高度处进行切割,在本例中为h=75
。这会生成一个树状图列表,用于切割的上
位,以及树状图列表,每个树状图对应于切割下方的每个分支
:It is possible to
cut
a dendrogram at a specified height and plot the elements:First create a clustering using the built-in dataset
USArrests
. Then convert to adendrogram
:Next, use
cut.dendrogram
to cut at a specified height, in this caseh=75
. This produces a list of a dendrogram for theupper
bit of the cut, and a list of dendograms, one for eachbranch
below the cut:其他答案中描述的 cut 函数是一个非常好的解决方案;如果您想将整个树保留在一页上进行一些交互式调查,您也可以绘制到 PDF 上的大页面。
生成的 PDF 已矢量化,因此您可以使用您喜爱的 PDF 查看器进行近距离放大,而不会损失分辨率。
以下是如何将绘图输出直接导出为 PDF 的示例:
The
cut
function described in the other answer is a very good solution; if you would like to maintain the whole tree on one page for some interactive investigation you could also plot to a large page on a PDF.The resulting PDF is vectorized so you can zoom in closely with your favourite PDF viewer without loss of resolution.
Here's an example of how to direct plot output to PDF: