[R] Finding an order for an hclust (dendrogram) object without intersections

Charles C. Berry
Sun, 13 Jun 2010 16:08:38 -0000

On Sun, 13 Jun 2010, Tal Galili wrote:

> Hello all,
>
> I manually created an hclust object.
> Now I am looking to reorder the leafs so they won't intersect with each
> other, and would be happy for advises on how to do that.

Have a look at the code for hclust().


If you can instead create an object like 'hcl', then pass the results to
.Fortran("hcass2",...), you should be done.

HTH,

Chuck

>
> Here is an example code:
>
>
> #-------------------------------------
> a <- list()  # initialize empty object
> # define merging pattern:
> #    negative numbers are leaves,
> #    positive are merged clusters (defined by row number in $merge)
> a$merge <- matrix(c(-1, -2,
>                    -3, -4,
>                     1,  2,
> -5,-6,
> 3,4), nc=2, byrow=TRUE )
> a$height <- c(1, 1.5, 3,4,4.5)    # define merge heights
> a$order <- c(1,4,2,3,6,5)              # order of leaves(trivial if
> hand-entered)
> a$labels <- 1:6# LETTERS[1:4]    # labels of leaves
> class(a) <- "hclust"        # make it an hclust object
> plot(a)                     # look at the result
>
> #-------------------------------------
>
> A working order solution in this example would be 1:6.
> The question is how can I find it.
>
>
> Thanks,
> Tal
>
>
>
>
>
>
>
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: Tal.Galili at gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
----------------------------------------------------------------------------------------------
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901