Description Usage Arguments Details Value Author(s) Examples
Adjust dendrogram based on width of leaves
1 | adjust_dend_by_leaf_width(dend, width = 1, offset = 0)
|
dend |
a |
width |
a vector of width. The order of width SHOULD be same as the order of original elements before clustering. |
offset |
offset to x = 0 |
In the standard dendrogram
object, leaves locate at x = 0.5, 1.5, ..., n - 0.5,
which means, the width of leaves are always 1 and the distance to neighbouring leaves is always 1 as well.
Here adjust_dend_by_leaf_width
adjusts the dendrogram by setting different width for leaves so that leaves
have unequal distance to other leaves.
The adjusted dendrogram can be sent to grid.dendrogram2
to make the dendrogram.
For each branch as well each leaf, a new attribute of x
is added which is the position of the middle point or the leaf.
For each leaf, a new attribute of width
is added which is the width of current leaf.
A dendrogram
object. The adjustment will not affect other standard dendrogram functions.
Zuguang Gu <z.gu@dkfz.de>
1 2 3 4 5 6 7 | m = matrix(rnorm(100), 10)
dend = as.dendrogram(hclust(dist(m)))
dend = adjust_dend_by_leaf_width(dend, width = 1:10)
require(dendextend)
get_leaves_attr(dend, "label")
get_leaves_attr(dend, "width")
get_leaves_attr(dend, "x")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.