**7.9k**wrote:

Hello,

I am using hierarchical clustering with `heatmap.2`

, and would like to reorder the tree generated for the columns. I have searched here, on bioconductor, and on google but don't seem to find the right solution. Wondering if someone here knows how to manipulate the tree.

In more detail, I have clustered with the following code, and the column tree is perfect, except that I would like the red group left of the blue one (so between green and blue). I know from evolution biology class that these branches in theory can be turned (like a baby mobile). But I don't know how to do this with `heatmap.2`

, I guess I would have to use the `reorderfun`

, but don't know how?

```
heatmap.2(z_RPKM_ro, key = TRUE, col=blueyellow, density.info=c("none"),
scale = c("none"), trace=c("none"), cexCol=1, cexRow=0.7, key.xlab="Row Z-score",
hclustfun = function(x) hclust(x, method = "ward.D"), dendrogram="both",
distfun = function(x) dist(x, method = "euclidean"),
labRow = F, RowSideColors = colorset, ColSideColors = colorBar2)
```

Thanks in advance!

Ben

https://drive.google.com/open?id=0ByVMqlqqt462WGtjX0FBLVRYdGc

You could reorder the matrix and then plot it using heatmap.2

http://stackoverflow.com/questions/27959044/heatmap-2-specify-row-order-or-prevent-reorder

4.6kThanks for your suggestion, but my point is the dendrogram. The dendrogram is showing that the replicates of my groups cluster nice together. Of course I can manually reorder the matrix/heatmap, but will lose then the information of the dendrogram.

Is it possible to rearrange the dendrogram horizontally? Since the distance is depicted vertically, it won't mess up the outcome of the dendrogram.

7.9k