computeHclustPlotOrder: computeHclustPlotOrder

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Given the merge matrix of an hclust object, compute a valid ordering of the samples so a dendogram can be plotted with no line crossings.

Note: It's been implemented from scratch but in our experience reproduces exactly the ordering produced by R own ordering algorithm used by hclust.

Usage

1

Arguments

m

(matrix) A merge matrix with 2 columns representing the merges bewteen elements and clusters. The format is described in the documentation of hclust.

Value

A vector with the ordering of the nodes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
ztree <- matrix(c(0,3,0.1,2,
                  1,4,0.2,2,
                  5,2,0.3,2,
                  6,7,0.4,2),
                  nrow=4)
                
 hc.tree <- Ztree2Hclust(ztree)
 plot(hc.tree)
 
 #Set the ordering to a non-correct ordering
 hc.tree$order <- c(1:5)
 
 #When we plot, we see line crossings
 plot(hc.tree)
 
 #Compute a correct ordering and replot
 element.order <- computeHclustPlotOrder(hc.tree$merge)
 hc.tree$order <- element.order
 plot(hc.tree)

CopyNumberPlots documentation built on Nov. 8, 2020, 6:51 p.m.