如何用大数据集绘制树状图

如何用大数据集绘制树状图

本文介绍了如何用大数据集绘制树状图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 R 中使用具有树状图绘制功能的 ape(系统发育和进化分析)包.我使用以下命令读取 Newick 格式的数据,并使用 plot 函数绘制树状图:

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.

我想知道绘图功能是否有任何缩放功能.我尝试使用 xLim 和 yLim 来限制区域,但是,它们只是限制区域,而不是缩放以显示细节.无论是缩放还是在不缩放的情况下使细节可见都可以解决我的问题.

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.

谢谢.

推荐答案

另一个回答中描述的cut函数是一个很好的解决方案;如果您想在一页上维护整个树以进行一些交互式调查,您还可以在 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.

生成的 PDF 已矢量化,因此您可以使用您最喜欢的 PDF 查看器进行放大,而不会降低分辨率.

The resulting PDF is vectorized so you can zoom in closely with your favourite PDF viewer without loss of resolution.

以下是如何将绘图输出定向为 PDF 的示例:

Here's an example of how to direct plot output to PDF:

# Open a PDF for plotting; units are inches by default
pdf("/path/to/a/pdf/file.pdf", width=40, height=15)

# Do some plotting
plot(gcPhylo)

# Close the PDF file's associated graphics device (necessary to finalize the output)
dev.off()

这篇关于如何用大数据集绘制树状图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 09:17