adjust_dend_by_leaf_width {ComplexHeatmap} | R Documentation

## Adjust dendrogram based on width of leaves

### Description

Adjust dendrogram based on width of leaves

### Usage

    adjust_dend_by_leaf_width(dend, width = 1, offset = 0)

### Arguments

`dend` | a `dendrogram` object.
`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

### Details

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.

### Value

A `dendrogram` object. The adjustment will not affect other standard dendrogram functions.

### Author(s)

Zuguang Gu <z.gu@dkfz.de>

### Examples

    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")

[Package ComplexHeatmap version 1.20.0 Index]