仅将 hclust 绘制到切割的簇,而不是每片叶子 [英] Plotting hclust only to the cut clusters, not every leaf

查看:57
本文介绍了仅将 hclust 绘制到切割的簇,而不是每片叶子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含近 2000 个样本的 hclust 树.我已将其切割为适当数量的集群,并希望绘制树状图,但以我切割集群的高度结束,而不是一直到每片叶子.每个绘图指南都是关于按簇为所有叶子着色或绘制一个框,但似乎没有什么能让切割线下方的叶子完全消失.

I have an hclust tree with nearly 2000 samples. I have cut it to an appropriate number of clusters and would like to plot the dendrogram but ending at the height that I cut the clusters rather than all the way to every individual leaf. Every plotting guide is about coloring all the leaves by cluster or drawing a box, but nothing seems to just leave the leaves below the cut line out completely.

我的完整树状图如下所示:

My full dendrogram looks like the following:

我想绘制它,好像它停在我在这里绘制 abline 的地方(例如):

I would like to plot it as if it stops where I've drawn the abline here (for example):

推荐答案

这应该会让你开始.我建议阅读树状图"的帮助页面

This should get you started. I suggest reading the help page for "dendrogram"

以下是帮助页面的示例:

Here is the example from the help page:

hc <- hclust(dist(USArrests))
dend1 <- as.dendrogram(hc)
plot(dend1)
dend2 <- cut(dend1, h = 100)
plot(dend2$upper)
plot(dend2$upper, nodePar = list(pch = c(1,7), col = 2:1))

通过对树状图对象(不是 hclust 对象)执行切割,您可以绘制树状图的上部.根据您的分析,替换 branch1、2、3 和 4 标签需要一些工作.

By performing the cut on the dendrogram object (not the hclust object) you can then plot the upper part of the dendrogram. It will take a some work to replace the branch1, 2, 3, and 4 labels depending on your analysis.

祝你好运.

这篇关于仅将 hclust 绘制到切割的簇,而不是每片叶子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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