Question: R - pheatmap - changing column order
gravatar for piotr.grabowski
5.7 years ago by
piotr.grabowski60 wrote:

Dear Community,

I am drawing a heatmap with pheatmap package in R. I would like to show a certain property of two datasets and show two heatmaps next to each other. However, the order of the columns/rows in both heatmaps is slightly different. I understand that the order in which the columns/rows are organized has it's function in heatmap.

However, the two sample types I would like to change the order of, are next to another and this shouldn't disturb the whole idea of clustering. Is it possible to change the order of samples on a heatmap in pheatmap package ?

Please look at the example below:



I would like to have control in the bottom-right, and f4 in the middle. That would make this heatmap consistent with the other one I generated.

heatmap pheatmap R • 16k views
ADD COMMENTlink modified 8 months ago by RamRS26k • written 5.7 years ago by piotr.grabowski60

Thanks Devon! I am getting so much help from you on different platforms, I really appreciate it.

So it seems that it's not possible to tweak the order of the samples without losing (and manipulating) the dendrogram ? In my case rotating the left end of the dendrogram by 180 degrees forward (from our faces) wouldn't distort the meaning, but I don't expect it to be a one-liner option in the package...

Best regards ;)

ADD REPLYlink modified 8 months ago by RamRS26k • written 5.7 years ago by piotr.grabowski60

It seems that that's not a built-in option. You do it by tweaking the source code of that function, but since you only have one affected figure, it's probably faster to just save it as a pdf and reorder things in Adobe Illustrator (this sort of thing would obviously constitute the maximum permissible changes you could make to a figure). Just make sure you mention having done that in the figure legend!

ADD REPLYlink written 5.7 years ago by Devon Ryan94k
gravatar for Devon Ryan
5.7 years ago by
Devon Ryan94k
Freiburg, Germany
Devon Ryan94k wrote:

Just input thing with the rows and columns in the order you want and then use cluster_rows=F, cluster_cols=F.

ADD COMMENTlink written 5.7 years ago by Devon Ryan94k
gravatar for RamRS
8 months ago by
Houston, TX
RamRS26k wrote:

Revisiting this topic so the answer is more current, I highly recommend using ComplexHeatmap. Its manual is comprehensive and covers a ton of options. The developer is active and responsive.

Carrying over row order between heatmaps can be done with

ro_1 <- row_order(heatmap_1)
heatmap_2 <- Heatmap(..., row_order = ro_1, ...)
ADD COMMENTlink modified 8 months ago • written 8 months ago by RamRS26k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2126 users visited in the last hour