[R] hclust and heatmap - slightly different dendrograms?
minhan.science at gmail.com
Wed Dec 15 21:55:07 CET 2004
I ran heatmap and hclust on the same matrix x (strictly, I ran
heatmap(x), and hclust(dist(t(x))), and realized that the two
dendrograms were slightly different, in that the left-right
arrangement of one pair of subclusters (columns) was reversed in the
two functions (but all individual columns were grouped correctly).
Looking through the code for heatmap as a most definite nonexpert, it
seems to me that hclust is also invoked by heatmap.
function (x, Rowv = NULL, Colv = if (symm) "Rowv" else NULL,
distfun = dist, hclustfun = hclust, add.expr, symm = FALSE,
hcr <- hclustfun(distfun(x))
ddr <- as.dendrogram(hcr)
hcc <- hclustfun(distfun(if (symm)
ddc <- as.dendrogram(hcc)
I understand it is possible to add Rowv=NA and order the samples as
per hclust, but I'm just wondering if there is a reason for this
observation. Any pointers would be very much appreciated.
More information about the R-help