adjust_dend_by_x: Adjust the Positions of nodes/leaves in the Dendrogram

Description Usage Arguments Details Examples

View source: R/grid.dendrogram.R

Description

Adjust the Positions of nodes/leaves in the Dendrogram

Usage

1
adjust_dend_by_x(dend, leaf_pos = 1:nobs(dend)-0.5)

Arguments

dend

A dendrogram object.

leaf_pos

A vector of positions of leaves. The value can also be a unit object.

Details

The positions of nodes stored as x attribute are recalculated based on the new positions of leaves.

By default, the position of leaves are at 0.5, 1.5, ..., n-0.5.

Examples

1
2
3
4
5
6
m = matrix(rnorm(100), 10)
dend = as.dendrogram(hclust(dist(m)))
dend = adjust_dend_by_x(dend, sort(runif(10)))
str(dend)
dend = adjust_dend_by_x(dend, unit(1:10, "cm"))
str(dend)

Example output

Loading required package: grid
========================================
ComplexHeatmap version 2.6.2
Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
Github page: https://github.com/jokergoo/ComplexHeatmap
Documentation: http://jokergoo.github.io/ComplexHeatmap-reference

If you use it in published research, please cite:
Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
  genomic data. Bioinformatics 2016.

This message can be suppressed by:
  suppressPackageStartupMessages(library(ComplexHeatmap))
========================================

--[dendrogram w/ 2 branches and 10 members at h = 6.15]
  |--[dendrogram w/ 2 branches and 3 members at h = 3.5]
  |  |--leaf 3 ( x = 0.12 )
  |  `--[dendrogram w/ 2 branches and 2 members at h = 3.22]
  |     |--leaf 4 ( x = 0.265 )
  |     `--leaf 6 ( x = 0.493 )
  `--[dendrogram w/ 2 branches and 7 members at h = 5.49]
     |--[dendrogram w/ 2 branches and 3 members at h = 4.08]
     |  |--leaf 8 ( x = 0.566 )
     |  `--[dendrogram w/ 2 branches and 2 members at h = 3.23]
     |     |--leaf 2 ( x = 0.607 )
     |     `--leaf 7 ( x = 0.708 )
     `--[dendrogram w/ 2 branches and 4 members at h = 4.5]
        |--[dendrogram w/ 2 branches and 2 members at h = 3.35]
        |  |--leaf 5 ( x = 0.72 )
        |  `--leaf 9 ( x = 0.773 )
        `--[dendrogram w/ 2 branches and 2 members at h = 4.15]
           |--leaf 1 ( x = 0.868 )
           `--leaf 10 ( x = 0.894 )
--[dendrogram w/ 2 branches and 10 members at h = 6.15]
  |--[dendrogram w/ 2 branches and 3 members at h = 3.5]
  |  |--leaf 3 ( x = 1cm )
  |  `--[dendrogram w/ 2 branches and 2 members at h = 3.22]
  |     |--leaf 4 ( x = 2cm )
  |     `--leaf 6 ( x = 3cm )
  `--[dendrogram w/ 2 branches and 7 members at h = 5.49]
     |--[dendrogram w/ 2 branches and 3 members at h = 4.08]
     |  |--leaf 8 ( x = 4cm )
     |  `--[dendrogram w/ 2 branches and 2 members at h = 3.23]
     |     |--leaf 2 ( x = 5cm )
     |     `--leaf 7 ( x = 6cm )
     `--[dendrogram w/ 2 branches and 4 members at h = 4.5]
        |--[dendrogram w/ 2 branches and 2 members at h = 3.35]
        |  |--leaf 5 ( x = 7cm )
        |  `--leaf 9 ( x = 8cm )
        `--[dendrogram w/ 2 branches and 2 members at h = 4.15]
           |--leaf 1 ( x = 9cm )
           `--leaf 10 ( x = 10cm )

ComplexHeatmap documentation built on Nov. 14, 2020, 2:01 a.m.