melil
melil

Reputation: 81

Invalid dendrogram input (hierarchical clustering)

I want to plot a dendogram after performing hierarchical clustering on top.ranked.genes matrix.

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")

Error in graphics:::plotHclust(n1, merge, height, order(x$order), hang, : invalid dendrogram input

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")))

Upvotes: 0

Views: 1638

Answers (1)

dcarlson
dcarlson

Reputation: 11046

The problem is that the centroid method does not produce a monotonic increase in the height of the dendrogram so you can get reversals. The basic dendrogram plot function does not handle that well. The solution is to change the clustering method or to convert to a dendrogram object:

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

The par function increases the bottom margin so that the labels are not truncated.

Dendrogram

Upvotes: 2

Related Questions