[R] Coloured label, terminal branch and bars in dendograms

Adaikalavan Ramasamy gisar at nus.edu.sg
Tue Dec 17 11:43:03 CET 2002


Dear R-help,

I have performed a hierarchical clustering on some data that I have and
would like to know some nice ways of visualizing it. I have 2 related
questions:


i) How to color the labels AND the terminal branch of a dendogram? This
is my inelegant way of just getting the colored labels.

data(iris)          # Formatting data into required format
ir <- iris[ ,-5]
ir.class  <- c( rep("s", 50), rep("c", 50), rep("v", 50))

ir.hclust <- hclust( dist(ir), "average" )  # Hierarchical clustering

plclust(ir.hclust, label =rep("", 150))     # could also set hang=-1
option
mtext(ir.class[ir.hclust$order], side=1, col=
ir.fac.class[ir.hclust$order], 	at=1:150, line=-2)

This does not color the terminal branch and does not work very well if I
wish to cluster 400 - 500 objects as the text gets very cramped (even
after cex and las option).


ii) I also wish to investigate if the data is clustered according to
several suspected factors/prognosis. Therefore I want to plot these as
'color filled bars' underneath the dendogram (akin to those published
microarray clustering papers). 

My way of doing this is to use mtext with "-" as follows:

plclust(ir.hclust)
mtext( "-", side=1, col=ir.var1[ir.hclust$order], at=1:150, line=-1)
mtext( "-", side=1, col=ir.var2[ir.hclust$order], at=1:150, line=-1.5)


Any help or reference is greatly appreciated.

Thanks, Adai.




More information about the R-help mailing list