Reordering clusters when plotting pheatmap in R
1
0
Entering edit mode
ecg1g15 ▴ 30
@ecg1g15-19970
Last seen 4.0 years ago

I am plotting a set of genes belonging to three groups A, B, C, and the heatmap orders them such as C, A, B. (I have read this is due to that it plots on the right the cluster with the strongest similarity). I would like to order the clusters to the groups are seen as A, B, C (therefore reorganising the order of the cluster branches.

> pheatmap(mat, annotation_col = anno, color = colorRampPalette(c("blue", "white", "red"))(50),show_rownames = F)

Heatmap with clusters https://ibb.co/G3F7ssg

I have tried adding cluster_cols = FALSE. This orders the columns in sample number order (which is similar to dendrogram) but ignores the clustering which I am interested to see (ie. samples 1419 and 1421 are clustered together, but when using cluster_cols = FALSE sample 1420 shows in the middle.

pheatmap(mat, annotation_col = anno, cluster_cols = FALSE, color = colorRampPalette(c("blue", "white", "red"))(50),show_rownames = F)

is there any function I could use to specify (even manually) the order of the columns maintaining the clusters?

Heatmap without clusters https://ibb.co/dD1mQ7S

R pheatmap clusters • 5.4k views
ADD COMMENT
0
Entering edit mode
ecg1g15 ▴ 30
@ecg1g15-19970
Last seen 4.0 years ago

I have found you can use clustering_callback function, but I need to construct it, how do I do it?

clustering_callback callback function to modify the clustering. Is called with two parameters: original hclust object and the matrix used for clustering. Must return a hclust object.

ADD COMMENT

Login before adding your answer.

Traffic: 520 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6