# Why hierarchical clustering with pvclust and hclust gives different results? [closed]

I am performing the hierarchical clustering analysis on a dataset of 25 viral populations using 3 viral components (variables) to construct a dendrogram with average method and correlation distance calculation. We firstly used the hclust() method generate a plot, but we still need to support the dendrogram by statistical analysis. So after transposing the data, we choose pvclust() to generate the dendrogramm. However, the plots constructed by pvclust and the one generated by hclust are totally different. We used the same data and same parameters (average method and correlation distance), but the results are so different. Why might this be? Here is the dataset.

# hclust

######### hclust method #############
sd.data = scale(tav.data)
dd = as.dist(1-cor(t(sd.data)))  # correlation-based distance
plot(hclust(dd, method="average"), xlab="", sub="",
main="Average Linkage with Correlation-Based Distance", labels=tav.labs)


# pvclust

######### pvclust method ################
tav.data0 = tav.data[,c(1,2,3)]
rownames(tav.data0) <- tav.labs
tav.data0 = as.data.frame(t(tav.data0))
sd.data0 = scale(tav.data0)
library(pvclust)
result = pvclust(sd.data0, method.hclust="average", method.dist="correlation",
nboot=100, r=seq(0.7,1.4,by=.1))
plot(result)


## closed as off-topic by gung♦, Michael Chernick, mpiktas, John, kjetil b halvorsenMay 16 '17 at 22:46

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – gung, Michael Chernick, mpiktas, John, kjetil b halvorsen
If this question can be reworded to fit the rules in the help center, please edit the question.

• They are two different methods so what makes you think they will return the same answers? – Dan Aug 27 '14 at 16:46
• @Dan,Because the pvclust mentioned they used the same method as hclust – user44425 Aug 27 '14 at 20:09
• Can you give the whole data (and in text, please)? How can one check without the data? – ttnphns Aug 28 '14 at 6:06
• I could reproduce your second dendrogram by clustering in SPSS, but failed to do it for your first dendrogram. You might be doing something wrong in your 1st case. Check if your first 2 statements there give you exactly the same distance matrix as the matrix in your second case. – ttnphns Aug 31 '14 at 10:29

• No: hclust by default looks at rows of passed dataframes, pvclust by default looks at columns. Hence, without transposing, with pvclust you would get a dendrogram of features instead of samples, when hclust gives you a dendrogram of samples for the same input. As a result, and contrary to this answer, transposing would be correct - just in case anybody runs into this answer. – geekoverdose Feb 7 '18 at 12:51
• @geekoverdose I think the issue was that they should not have transposed before using dist. Has been a while, but takeaway from this comment remains: double check how rows and columns are changing in your workflow! – rrr Mar 7 '18 at 2:28