Learn R Programming

ggalign (version 0.0.4)

dendrogram_data: Dengrogram x and y coordinates

Description

Dengrogram x and y coordinates

Usage

dendrogram_data(
  tree,
  priority = "right",
  center = FALSE,
  type = "rectangle",
  leaf_pos = NULL,
  leaf_braches = NULL,
  reorder_branches = TRUE,
  branch_gap = NULL,
  root = NULL
)

Value

A list of 2 data.frame. One for node coordinates, another for edge coordinates. node and tree segments edge coordinates contains following columns:

  • index: the original index in the tree for the current node

  • label: node label text

  • x and y: x-axis and y-axis coordinates for current node or the start node of the current edge.

  • xend and yend: the x-axis and y-axis coordinates of the terminal node for current edge.

  • branch: which branch current node or edge is. You can use this column to color different groups.

  • panel: which panel current node is, if we split the plot into panel using facet_grid, this column will show which panel current node or edge is from. Note: some nodes may fall outside panel (between two panels), so there are possible NA values in this column.

  • .panel: Similar with panel column, but always give the correct branch for usage of the ggplot facet.

  • panel1 and panel2: The panel1 and panel2 variables have the same functionality as panel, but they are specifically for the edge data and correspond to both nodes of each edge.

  • leaf: A logical value indicates whether current node is a leaf.

Arguments

tree

A hclust or a dendrogram object.

priority

A string of "left" or "right". if we draw from right to left, the left will override the right, so we take the "left" as the priority. If we draw from left to right, the right will override the left, so we take the "right" as priority. This is used by align_dendro() to provide support of facet operation in ggplot2.

center

A boolean value. if TRUE, nodes are plotted centered with respect to the leaves in the branch. Otherwise (default), plot them in the middle of all direct child nodes.

type

A string indicates the plot type, "rectangle" or "triangle".

leaf_pos

The x-coordinates of the leaf node. Must be the same length of the number of observations in tree.

leaf_braches

Branches of the leaf node. Must be the same length of the number of observations in tree. Usually come from cutree.

reorder_branches

A single boolean value, indicates whether reorder the provided leaf_braches based on the actual index.

branch_gap

A single numeric value indicates the gap between different branches.

root

A length one string or numeric indicates the root branch.

Examples

Run this code
dendrogram_data(hclust(dist(USArrests), "ave"))

Run the code above in your browser using DataLab