【问题标题】:Invalid dendrogram input (hierarchical clustering)无效的树状图输入(分层聚类)
【发布时间】:2021-08-12 11:14:36
【问题描述】:

我想在对top.ranked.genes 矩阵执行层次聚类后绘制一个树状图。

top.ranked.genes <- top.genes.matrix[ranked.list, ]
# Hierarchical Clustering via Euclidean
dat.dist <- dist(top.ranked.genes, method="euclidean") # calculate distance
dat.clust <- hclust(dat.dist, method="centroid") # calculate clusters    
plot(dat.clust, labels=colnames(top.ranked.genes), xlab="Clustered Samples", ylab="Distance", main="Hierarchical Clustering Dendrogram\nRanked Angiogenesis Classification")

图形错误:::plotHclust(n1, merge, height, order(x$order), 挂起,:无效的树状图输入

top.ranked.genes <-  dput(top.ranked.genes[1:10, 1:5])
structure(c(278.5, 248.3, 349.9, 376.8, 145.5, 149.2, 113.3, 
            173.9, 171, 298.4, 2336.9, 2630.2, 2230.5, 2306, 2209.9, 1945.7, 
            1955.4, 2075.1, 2121.6, 1789.5, 335, 413.7, 438.5, 385.3, 371, 
            373.7, 517.8, 367.1, 798.8, 524, 1073.2, 1305.3, 1163.6, 1089.3, 
            1798, 1473.7, 1486.1, 2015.1, 1582.9, 2078.3, 215.1, 204.4, 771.8, 
            230.7, 66, 100.2, 112.6, 140.9, 46.4, 148.6), .Dim = c(10L, 5L
            ), .Dimnames = list(c("NB_GSM97800", "NB_GSM97803", "NB_GSM97804", 
                                  "NB_GSM97805", "NB_GSM97807", "NB_GSM97809", "NB_GSM97811", "NB_GSM97812", 
                                  "NB_GSM97816", "NB_GSM97817"), c("243879_at", "212126_at", "219315_s_at", 
                                                                   "201554_x_at", "236462_at")))

    

> dput(top.ranked.genes[1:5, 1:5])
    structure(c(1434.3, 1550.5, 1017.7, 1020.7, 1167.3, 1406.5, 1527.8, 
    1370.7, 1543.8, 2009.2, 475.5, 455.2, 778.6, 527.9, 225.9, 280.3, 
    204.6, 300.4, 225.4, 364.2, 2902.9, 3416.8, 2619.6, 2832.9, 4333.6
    ), .Dim = c(5L, 5L), .Dimnames = list(c("NB_GSM97800", "NB_GSM97803", 
    "NB_GSM97804", "NB_GSM97805", "NB_GSM97807"), c("214722_at", 
    "212511_at", "200616_s_at", "214666_x_at", "208683_at")))

【问题讨论】:

  • 我无法使用您帖子中提供的数据集重现您的错误。我使用了这个代码:pastebin.com/kNTPDxhR 请你在你的 R 机器上测试代码,看看你是否收到错误消息?
  • @MarcoSandri 你是对的。样本dput(top.ranked.genes[1:5,1:5]) 没有给出错误。但是当我将其更改为dput(top.ranked.genes[1:10,1:5]) 时,我能够重现该错误(请参阅修改后的问题)。我猜这个错误可能是由于尺寸造成的。解决办法是什么?

标签: r plot bioinformatics hierarchical-clustering


【解决方案1】:

问题在于质心方法不会产生树状图高度的单调增加,因此您可以获得反转。基本的树状图函数不能很好地处理。解决办法是改变聚类方式或者转换成dendrogram对象:

dend <- as.dendrogram(dat.clust)
par(mar=c(6.1, 4.1, 4.1, 2.1))
plot(dend)

par 函数增加了下边距,这样标签就不会被截断。

【讨论】:

    猜你喜欢
    • 2012-05-05
    • 2020-02-07
    • 2014-12-14
    • 2020-07-09
    • 2016-01-31
    • 2013-12-19
    • 2018-11-26
    • 2014-12-23
    • 1970-01-01
    相关资源
    最近更新 更多