| MatArray Toolbox | Search Help Desk |
| hierarc | Examples See Also |
Syntax
tree = hierarc(dist, type)
tree = hierarc(dist, type, flag)
Description
The function performs a hierarchical clustering of the distance matrix dist. The clustering can for instance be exported with
clustTV for visualization with TreeView.
The parameter type determines the type of clustering performed:
0: single linkage
1: average linkage
2: complete linkage
3: Ward's method
The resulting tree is given as a 4-columns matrix, each line of the matrix
being a node, as [ num val l r ]
num: number of leaves in the node (1 if the node is a leaf).
val: if the node is a leaf, the index of the leaf. Otherwise,
the distance at the junction.
l: Node at the left.
r: Node at the right.
The tree starts on the first line.
If flag is present, tree is given as a
UINT16 array. In this case val serves only as indexes
for the leaves. This mode is marginally faster, it is essentially useful when
the trees are meant to be used by another mex-file.
For the Ward's method, the distance matrix dist should be
the squared euclidian distances, like the ones obtained with dl2c
. The tree obtained is given with squared distances as well, which may fit
or not. There is also a factor 2 between the distances shown
and the real distances. To obtain the correct distances, identical to the
ones obtained with linkage, simply type
tree = prettytree(tree);
tree(1:(size(tree,1)-1)/2,2) = sqrt(.5*tree(1:(size(tree,1)-1)/2,2));
Examples
Creation of a random ratio matrix with 100 genes and 10 slides, and of a name char array with the slide names.ratio = randn(100,10);Say we only want to keep the genes where at least one absolute ratio is over 1.5
name = { 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'k' };
w = max(abs(ratio),[],2)>1.5;Creation of an average linkage hierarchical clustering on the genes where
w == 1. The similarity matrix obtained with corrcoef
is transformed in a distance matrix
tG = hierarc(1-corrcoef(ratio(w,:)'),1);Export of the clustering with the name
abc for visualization
with TreeView
clustTV('abc',ratio,name,w,tG,[]);
The clustering can be viewed by opening abc.cdt in the current
directory with TreeView. The result will of course show little order as the
ratio matrix was random.
See Also
clustTV
, dl2c
, orderleaves