Question: How to reorder dendrogram (R)?
2
gravatar for khaeuk
3.3 years ago by
khaeuk70
khaeuk70 wrote:

Hello everyone! As my title says, I am having difficulty reordering my dendrogram. What I would like to do with my dendrogram is to flip two nodes along the y axis. For example,

enter image description here

How would I do this? I looked at reorder.dendrogram. But I don't quite get what it means and how you're suppose to do it, for most sources basically say the same thing as the manual page without any other examples/explanation. I tried messing around with 'weights' for reorder, but it wouldn't change my dendrogram. I tried looking other pages like, https://www.mail-archive.com/r-help@r-project.org/msg195536.html.

This is an example on the man page.

set.seed(123)

x <- rnorm(10)

hc <- hclust(dist(x))

dd <- as.dendrogram(hc)

dd.reorder <- reorder(dd, 10:1)

plot(dd, main = "random dendrogram 'dd'")

>

op <- par(mfcol = 1:2)

plot(dd.reorder, main = "reorder(dd, 10:1)")

plot(reorder(dd, 10:1, agglo.FUN = mean), main = "reorder(dd, 10:1, mean)")

par(op)

I don't know what that mfcol is but I tried changing the numbers, and it did swap some values, but I don't know how that works.

So next, I tried 'dendextend' package. I looked at the man page, seemed like there are some sort of ordering of the dendrogram, but more like ordering them in reverse or forward. So, my dendrogram would look like ...

enter image description here

Which is not what I'm looking for. Is there any other options? or is reorder.dendrogram is what i'm looking for, and i'm just not getting it? if so, can someone explain how it works?

Thank you!!

ADD COMMENTlink modified 2.5 years ago by Arnaud Ceol840 • written 3.3 years ago by khaeuk70
1

Hi,

have a look at my answer here:

heatmap.2 reorder branches

ADD REPLYlink written 2.5 years ago by e.rempel780
1
gravatar for Arnaud Ceol
2.5 years ago by
Arnaud Ceol840
Milan, Italy
Arnaud Ceol840 wrote:

I've used a few time dendosort (https://f1000research.com/articles/3-177/v1 and https://cran.r-project.org/web/packages/dendsort/index.html), this is a nice library to sort your dendograms. You should have a look.

ADD COMMENTlink written 2.5 years ago by Arnaud Ceol840
0
gravatar for Macherki M E
2.5 years ago by
Macherki M E120
Tunisia/ksour essef
Macherki M E120 wrote:

I thinks that the dendrogram had the some order of user matrix input. In that way user will control the position of each vertice. If you wont separate a specific class statistically based on distance or graphically we have to reformulate data input.

ADD COMMENTlink written 2.5 years ago by Macherki M E120
Please log in to add an answer.

Help
Access

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