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 generated.
Various transforamtions can be applied to numbers sizes/colors are mapped to.
Several types of tree layout algorithms from igraph
can be used.
heat_tree(...)# S3 method for taxmap
heat_tree(.input, ...)
# S3 method for default
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, 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, ...)
(other named arguments)
Passed to the igraph
layout function used.
An object of type taxmap
The unique ids of taxa.
The unique id of supertaxon taxon_id
is a part of.
See details on labels. Default: no labels.
See details on labels. Default: no labels.
See details on labels. The label to display above each graph. The value of the root of each graph will be used. Default: None.
See details on size. Default: constant size.
See details on size. Default: relative to node size.
See details on size. Default: relative to vertex size.
See details on size. Default: relative to edge size.
See details on size. Default: relative to graph size.
See details on colors. Default: grey.
See details on colors. Default: same as node 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.
See details on colors. Default: black.
See details on colors. Default: black.
See details on colors. Default: black.
See details on transformations.
Default: "area"
.
See details on transformations.
Default: same as node_size_trans
.
See details on transformations.
Default: same as node_size_trans
.
See details on transformations.
Default: same as edge_size_trans
.
See details on transformations.
Default: "area"
.
See details on transformations.
Default: "area"
.
See details on transformations. Default: same as node color transformation.
See details on transformations.
Default: "area"
.
See details on transformations.
Default: "area"
.
See details on transformations.
Default: "area"
.
See details on transformations.
Default: "area"
.
See details on ranges. Defualt: Optimize to balance overlaps and range size.
See details on ranges. Default: relative to node size range.
See details on ranges. Default: relative to node size.
See details on ranges. Default: relative to edge size.
See details on ranges. Default: relative to tree size.
See details on ranges. Default: Color-blind friendly palette.
See details on ranges. Default: same as node color.
See details on ranges. Default: Color-blind friendly palette.
See details on ranges. Default: Color-blind friendly palette.
See details on ranges. Default: Color-blind friendly palette.
See details on ranges. Default: Color-blind friendly palette.
See details on intervals.
Default: The range of values in node_size
.
See details on intervals.
Default: The range of values in node_color
.
See details on intervals.
Default: The range of values in edge_size
.
See details on intervals.
Default: The range of values in edge_color
.
The maximum number of node labels. Default: 20.
The maximum number of edge labels. Default: 20.
The maximum number of tree labels. Default: 20.
(numeric
)
The relative importance of avoiding overlaps vs maximizing size range.
Higher numbers will cause node size optimization to avoid overlaps more.
Default: 1
.
(numeric
of length 2)
The horizontal and vertical margins. c(left, right, bottom, top).
Default: 0, 0, 0, 0
.
The layout algorithm used to position nodes.
See details on layouts.
Default: "reingold-tilford"
.
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.
if TRUE...
Name to print above the graph.
The size of the title relative to the rest of the graph.
The label on the scale axis corresponding to node_color
.
Default: The expression given to node_color
.
The label on the scale axis corresponding to node_size
.
Default: The expression given to node_size
.
The label on the scale axis corresponding to edge_color
.
Default: The expression given to edge_color
.
The label on the scale axis corresponding to edge_size
.
Default: The expression given to edge_size
.
The background color of the plot. Default: Transparent
The path to one or more files to save the plot in using ggsave
.
The type of the file will be determined by the extension given.
Default: Do not save plot.
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.
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"
).
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.
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.
Proprotional to radius/diameter of node
circular area; better perceptual accuracy than "linear"
Log base 10 of radius
Log base 2 of radius
Log base e of radius
Log base 10 of circular area
Log base 2 of circular area
Log base e of circular area
The displayed range of colors and sizes can be explicitly defined or automatically generated.
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"
).
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:
Use as_tree
. A circular tree-like layout.
Use with_dh
. A type of simulated annealing.
Use with_gem
. A force-directed layout.
Use with_graphopt
. A force-directed layout.
Use with_mds
. Multidimensional scaling.
Use with_fr
. A force-directed layout.
Use with_kk
. A layout based on a physical model of springs.
Use with_lgl
. Meant for larger graphs.
Use with_drl
. A force-directed layout.
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 boundaries (such as c(0,1)
for proportions.
Note that this is different from the "range" options, which determine the range of graphed sizes/colors.
# NOT RUN {
heat_tree(contaminants,
node_size = n_obs,
node_color = n_obs,
node_label = name,
tree_label = name,
layout = "fruchterman-reingold")
# }
Run the code above in your browser using DataLab