heat_tree

0th

Percentile

Plot a taxonomic tree

Plots the distribution of values associated with a taxonomic classification. Taxonomic classifications can have multiple roots, resulting in multiple trees on the same plot. Sizes and colors of nodes, edges, labels, and individual trees can be displayed relative to numbers (e.g. taxon statistics, such as abundance). The displayed range of colors and sizes can be explicitly defined or automatically genereated. Various transforamtions can be applied to numbers sizes/colors are mapped to. Several types of tree layout algorithms from igraph can be used.

Keywords
internal
Usage
heat_tree(...)
"heat_tree"(.input, ...)
"heat_tree"(taxon_id, supertaxon_id, node_label = NA, edge_label = NA, tree_label = NA, node_size = 1, edge_size = node_size, node_label_size = node_size, edge_label_size = edge_size, tree_label_size = as.numeric(NA), node_color = "#999999", edge_color = node_color, tree_color = NA, node_label_color = "#000000", edge_label_color = "#000000", tree_label_color = "#000000", node_size_trans = "area", edge_size_trans = node_size_trans, node_label_size_trans = node_size_trans, edge_label_size_trans = edge_size_trans, tree_label_size_trans = "area", node_color_trans = "area", edge_color_trans = node_color_trans, tree_color_trans = "area", node_label_color_trans = "area", edge_label_color_trans = "area", tree_label_color_trans = "area", node_size_range = c(NA, NA), edge_size_range = c(NA, NA), node_label_size_range = c(NA, NA), edge_label_size_range = c(NA, NA), tree_label_size_range = c(NA, NA), node_color_range = quantative_palette(), edge_color_range = node_color_range, tree_color_range = quantative_palette(), node_label_color_range = quantative_palette(), edge_label_color_range = quantative_palette(), tree_label_color_range = quantative_palette(), node_size_interval = range(node_size, na.rm = TRUE, finite = TRUE), node_color_interval = NULL, edge_size_interval = range(edge_size, na.rm = TRUE, finite = TRUE), edge_color_interval = NULL, node_label_max = 40, edge_label_max = 40, tree_label_max = 40, overlap_avoidance = 1, margin_size = c(0, 0), layout = "reingold-tilford", initial_layout = "fruchterman-reingold", make_legend = TRUE, title = NULL, title_size = 0.08, node_color_axis_label = NULL, node_size_axis_label = NULL, edge_color_axis_label = NULL, edge_size_axis_label = NULL, background_color = "#FFFFFF00", output_file = NULL, ...)
Arguments
...
(other named arguments) Passed to the igraph layout function used.
.input
An object of type taxmap
taxon_id
The unique ids of taxa.
supertaxon_id
The unique id of supertaxon taxon_id is a part of.
node_label
See details on labels. Default: no labels.
edge_label
See details on labels. Default: no labels.
tree_label
See details on labels. The label to display above each graph. The value of the root of each graph will be used. Default: None.
node_size
See details on size. Default: constant size.
edge_size
See details on size. Default: relative to node size.
node_label_size
See details on size. Default: relative to veterx size.
edge_label_size
See details on size. Default: relative to edge size.
tree_label_size
See details on size. Default: relative to graph size.
node_color
See details on colors. Default: grey.
edge_color
See details on colors. Default: same as node color.
tree_color
See details on colors. The value of the root of each graph will be used. Overwrites the node and edge color if specified. Default: Not used.
node_label_color
See details on colors. Default: black.
edge_label_color
See details on colors. Default: black.
tree_label_color
See details on colors. Default: black.
node_size_trans
See details on transformations. Default: "area".
edge_size_trans
See details on transformations. Default: same as node_size_trans.
node_label_size_trans
See details on transformations. Default: same as node_size_trans.
edge_label_size_trans
See details on transformations. Default: same as edge_size_trans.
tree_label_size_trans
See details on transformations. Default: "area".
node_color_trans
See details on transformations. Default: "area".
edge_color_trans
See details on transformations. Default: same as node color transformation.
tree_color_trans
See details on transformations. Default: "area".
node_label_color_trans
See details on transformations. Default: "area".
edge_label_color_trans
See details on transformations. Default: "area".
tree_label_color_trans
See details on transformations. Default: "area".
node_size_range
See details on ranges. Defualt: Optimize to balance overlaps and range size.
edge_size_range
See details on ranges. Default: relative to node size range.
node_label_size_range
See details on ranges. Default: relative to node size.
edge_label_size_range
See details on ranges. Default: relative to edge size.
tree_label_size_range
See details on ranges. Default: relative to tree size.
node_color_range
See details on ranges. Default: Color-blind friendly palette.
edge_color_range
See details on ranges. Default: same as node color.
tree_color_range
See details on ranges. Default: Color-blind friendly palette.
node_label_color_range
See details on ranges. Default: Color-blind friendly palette.
edge_label_color_range
See details on ranges. Default: Color-blind friendly palette.
tree_label_color_range
See details on ranges. Default: Color-blind friendly palette.
node_size_interval
See details on intervals. Default: The range of values in node_size.
node_color_interval
See details on intervals. Default: The range of values in node_color.
edge_size_interval
See details on intervals. Default: The range of values in edge_size.
edge_color_interval
See details on intervals. Default: The range of values in edge_color.
node_label_max
The maximum number of node labels. Default: 20.
edge_label_max
The maximum number of edge labels. Default: 20.
tree_label_max
The maximum number of tree labels. Default: 20.
overlap_avoidance
(numeric) The relative importance of avoiding overlaps vs maximizing size range. Higher numbers will cause node size optimazation to avoid overlaps more. Default: 1.
margin_size
(numeric of length 2) The horizontal and vertical margins. Default: 0, 0.
layout
The layout algorithm used to position nodes. See details on layouts. Default: "reingold-tilford".
initial_layout
he layout algorithm used to set the initial position of nodes, passed as input to the layout algorithm. See details on layouts. Default: Not used.
make_legend
if TRUE...
title
Name to print above the graph.
title_size
The size of the title realtive to the rest of the graph.
node_color_axis_label
The label on the scale axis corresponding to node_color. Default: The expression given to node_color.
node_size_axis_label
The label on the scale axis corresponding to node_size. Default: The expression given to node_size.
edge_color_axis_label
The label on the scale axis corresponding to edge_color. Default: The expression given to edge_color.
edge_size_axis_label
The label on the scale axis corresponding to edge_size. Default: The expression given to edge_size.
background_color
The background color of the plot. Default: Transparent
output_file
The path to a file to save the plot in using ggsave. The type of the file will be determined by the extension given. Default: Do not save plot.
size

The size of nodes, edges, labels, and trees can be mapped to arbitrary numbers. This is useful for displaying statistics for taxa, such as abundance. Only the relative size of numbers is used, not the values themeselves. They can be transformed to make the mapping non-linear using the transformation options. The range of actual sizes displayed on the graph can be set using the range options. Accepts a numeric vector, the same length taxon_id or a factor of its length.

colors

The colors of nodes, edges, labels, and trees can be mapped to arbitrary numbers. This is useful for highlighting groups of taxa. Only the relative size of numbers is used, not the values themeselves. They can be transformed to make the mapping non-linear using the transformation options. The range of actual colors displayed on the graph can be set using the range options. Accepts a vector, the same length taxon_id or a factor of its length. If a numeric vector is given, it is mapped to a color scale. Hex values or color names can be used (e.g. #000000 or "black").

labels

The labels of nodes, edges, and trees can be added. Node labels are centered over their node. Edge labels are displayed over edges, in the same orientation. Tree labels are displayed over their tree. Accepts a vector, the same length taxon_id or a factor of its length.

transformations

Before any numbers specified are mapped to color/size, they can be transformed to make the mapping non-linear. Any of the transformations listed below can be used by specifying their name. A customized function can also be supplied to do the transformation.

ranges

The displayed range of colors and sizes can be explicitly defined or automatically genereated. Size ranges are specified by supplying a numeric vector with two values: the minimum and maximum. The units used should be between 0 and 1, representing the proportion of a dimension of the graph. Since the dimensions of the graph are determined by layout, and not always square, the value that 1 corresponds to is the square root of the graph area (i.e. the side of a square with the same area as the plotted space). Color ranges can be any number of color values as either HEX codes (e.g. #000000) or color names (e.g. "black").

layout

Layouts determine the position of nodes on the graph. The are implemented using the igraph package. Any additional arguments passed to heat_tree are passed to the igraph function used. The following character values are understood:

intervals

This is the minimum and maximum of values displayed on the legend scales. Intervals are specified by supplying a numeric vector with two values: the minimum and maximum. These are defined in the same units as element size/color. By default, the minimum and maximum equals the range of the values used to infer size/color. Setting a custom interval is useful for making size/color in multiple graphs correspond to the same statistics, or setting logical bounderies (such as c(0,1) for proportions. Note that this is different from the "range" options, which determine the range of graphed sizes/colors.

Aliases
  • heat_tree
  • heat_tree.default
  • heat_tree.taxmap
Examples
heat_tree(contaminants,
          node_size = n_obs,
          node_color = n_obs,
          node_label = name,
          tree_label = name,
          layout = "fruchterman-reingold")

Documentation reproduced from package metacoder, version 0.1.2, License: GPL-2 | GPL-3

Community examples

Looks like there are no examples yet.