Skip to content
Back to formatted view

Raw Message

Message-ID: <CAEFkoxrchyCv-6rna6Fj4F_yk0W-SEcUEHdpSUbxF3dB76q4Hg@mail.gmail.com>
Date: 2014-02-16T05:54:37Z
From: Chih-Hsin
Subject: Help on reorder the dendrogram

Hi all,

I would like to reorder the leaves of a dendrogram. I attached the tree in
the attachment.
The code I apply is

reorder.tree = function(
  Dend, # the dendrogram you want to order
  order.n){ # the order of leaves from left to right

  new.order = rbind(order.n, 1:length(order.n))
  wts = new.order[2, order(new.order[1,])]
  new.Dend = reorder(Dend, wts, min)
  return(new.Dend)
 }

the order I want is order.n = c(5,1,8,2,4,6,7,12,3,9,10,11)
But when I apply the reorder function, it gives me

> Dend = as.dendrogram(Tree)

> new.Dend = reorder.tree(Dend,order.n)

> order.dendrogram(new.Dend) [1]  8  5  1  2  4  6  7 12  3  9 10 11


Thanks for answering the question.


Best,

CH.