Pheatmap cluster by columns not working
1
0
Entering edit mode
7 weeks ago
Bine ▴ 90

Good morning,

I am using below code to create an heatmap:

   f0<-pheatmap(my_signature, annotation_col=annot_cols,cluster_rows=F,cluster_cols=T,show_colnames=F,main="My test)
   f0

Even though I specify "cluster_cols=TRUE" it does not cluster all column (which are similar) together.

Can anyone explain me this behaviour? Am I doing anyting incorrect?

Thank you!

enter image description here

R pheatmap • 533 views
ADD COMMENT
1
Entering edit mode
7 weeks ago

I will guess we are looking at a heatmap of gene counts with 5 different metadata.

Looks like it does. A clustering is based on your count matrix not your metadata.

In your example one could say by eye that all your columns with the less variation (more or less pale blue) are clustered together, while on the far right you have 2 columns with the same genes fluctuation clustered together.

Please elaborate on the expected behavior and why you think the clustering is incorrect.

ADD COMMENT
0
Entering edit mode

Thank you very much for your reply.

Yes, gene counts with 5 different metadata.

Sorry for not being clear. I meant that i expected that the columns on the left and on the right should cluster together. And then the ones in pale blue next to it...

ADD REPLY
2
Entering edit mode

I guess you are talking about the chunk of 3 columns together on the left side and the chunk of 6 columns together on the right side. Your genes expression look quite different between the 2 chunks, so maybe the right chunk is cluster from the pale blue chunk than the left chunk.

You can change the clustering_method parameter if you think another method would better fit your data. You have multiple choice described here.

ADD REPLY
0
Entering edit mode

Great, thanks a lot for the explanation and info!

ADD REPLY
1
Entering edit mode

i expected that the columns on the left and on the right should cluster together. And then the ones in pale blue next to it...

Perhaps you are overlooking that in a dendrogram you can rotate branches without changing the structure of the tree. If you rotate the branch containing the central big cluster and the cluster on the right with 6 columns, then you have the "left" and "right" cluster visually close to each other without changing anything in the underlying tree. If I'm not mistaken, base R rotates branches to have them in alphabetical order (or something like that). Often it is visually more useful to have them ordered by branch length. Check the ladderize function in dendextend package. In other words, if my guess of what you want is correct, your dendrogram is already the way you expect it, it's just not plotted the way you want.

ADD REPLY
0
Entering edit mode

Great, thanks a lot, I will check that.

ADD REPLY

Login before adding your answer.

Traffic: 1772 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