You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I accidentally ran by your bookdown when I searched for how to display correlation matrix with hierarchical clustering tree. I noticed that your corrplot(correlationMatrix, order = 'hclust', addrect = 2) plot doesn't match with your pheatmap below in terms of variables' order and clustering. It's because in corrplot, the function takes the correlation matrix as a distance matrix and runs hclust directly on it. Meanwhile, pheatmap considers the correlation matrix as a normal data set and re-calculates the distance matrix before feeding it into hclust.
To make the two plots consistent with each other, I suggest changing pheatmap function to add two arguments (clustering_distance_rows and clustering_distance_cols) to it. It basically tells pheatmap to use the current correlation matrix as the distance matrix. The 1 - is to ensure that perfect positive correlation (1) is considered as min distance and perfect negative correlation (-1) is considered as max distance.
I accidentally ran by your bookdown when I searched for how to display correlation matrix with hierarchical clustering tree. I noticed that your
corrplot(correlationMatrix, order = 'hclust', addrect = 2)
plot doesn't match with yourpheatmap
below in terms of variables' order and clustering. It's because incorrplot
, the function takes the correlation matrix as a distance matrix and runs hclust directly on it. Meanwhile,pheatmap
considers the correlation matrix as a normal data set and re-calculates the distance matrix before feeding it into hclust.To make the two plots consistent with each other, I suggest changing
pheatmap
function to add two arguments (clustering_distance_rows
andclustering_distance_cols
) to it. It basically tellspheatmap
to use the current correlation matrix as the distance matrix. The1 -
is to ensure that perfect positive correlation (1) is considered as min distance and perfect negative correlation (-1) is considered as max distance.The text was updated successfully, but these errors were encountered: