View source: R/plot_tree_radial.R
plot_tree_radial | R Documentation |
Given a rooted phylogenetic tree, visualize the tree in radial form, i.e., with the root placed in the center and descending clades radiating outwards. Optionally, discrete tip metadata may be displayed in the form of colored rings around the tree.
plot_tree_radial(tree,
file_path = NULL,
make_ultrametric = FALSE,
symmetric_arcs = TRUE,
opening = 0,
rotate = 0,
plot_width = 5,
plot_title = NULL,
show_scale_bar = FALSE,
align_tip_labels = FALSE,
tip_cex = 0,
node_cex = 0,
tip_label_cex = NULL,
scale_edge_widths = FALSE,
base_edge_width = 1,
tip_color = "black",
node_color = "black",
edge_color = "#00000080",
node_arc_color = "#00000080",
root_edge_color = "#00000080",
tip_label_color = "black",
ring_colors = NULL,
ring_width = 5,
ring_border_width = 1,
ring_border_color = "#FFFFFF",
legend_colors = NULL,
legend_labels = NULL)
tree |
A rooted tree of class "phylo". The root is assumed to be the unique node with no incoming edge. |
file_path |
Optional character, file path to save the plot to. Any existing file is silently replaced. |
make_ultrametric |
Logical, whether to make the tree ultrametric first, so that all tips appear at the same distance from the center. The transformation is done based on relative evolutionary divergences (Parks et al. 2018). |
symmetric_arcs |
Logical, whether nodes should appear in the middle of their arc.
If |
opening |
Optional numeric, opening angle of the tree in degrees, i.e., separating the two flanks of the tree. If 0, the tips will uniformly cover the whole circle. Must be between 0 and 360. |
rotate |
Optional numeric, angle (degrees) by which to rotate the whole plot, counter-clockwise. By default the tree is oriented such that the outer-most tip is placed on the right-most point of the circle, i.e., at "3'o clock". |
plot_width |
Plot width & height in inches, excluding margins. Only relevant if |
plot_title |
Optional character, plot title. |
show_scale_bar |
Logical, whether to show a scale bar in the corner of the plot. |
align_tip_labels |
Logical, whether to align all tip labels on a single circle, rather than placing each tip label immediately adjacent to each tip. Only relevant for non-ultrametric trees, only if |
tip_cex |
Numeric, circle rescaling for tips. If >0, tips are shown as circles. |
node_cex |
Numeric, circle rescaling for nodes. If >0, nodes are shown as circles. |
tip_label_cex |
Numeric, tip label rescaling. If 0, tip labels are not shown. If |
scale_edge_widths |
Logical, whether to scale the width (thickness) of each edge and node arc proportionally to the square root of the number of tips descending from it.
If |
base_edge_width |
Numeric, base (smallest) width of edges, e.g. at the tips (and everywhere else if |
tip_color |
Either a single character or a character vector of length |
node_color |
Either a single character or a character vector of length |
edge_color |
Either a single character or a character vector of length |
node_arc_color |
Either a single character or a character vector of length |
root_edge_color |
Color of the root edge, if applicable. |
tip_label_color |
Either a single character or a character vector of length |
ring_colors |
Optional specification of discrete data to be visualized as multi-colored rings around the tree. Must be either a data.frame or a matrix of size Ntips x NC, specifying one or more multi-colored rings to show around the tree.
The entries of |
ring_width |
Numeric, line width to use for colored rings around the tree. Only relevant if |
ring_border_width |
Numeric, line width to use for the ring borders. A value of 0 means zero space between successive rings. |
ring_border_color |
Color to use for the ring borders, i.e., separating the rings from each other and from the tree. |
legend_colors |
Vector specifying colors to be defined in a legend. These can be for example colors in |
legend_labels |
Optional character vector specifying labels to be given in a legend, synchronized with |
The input tree may include multi-furcations (i.e. nodes with more than 2 children) as well as mono-furcations (i.e. nodes with only one child).
If tree$edge.length
is NULL
, then all edges in the input tree are assumed to have length 1.
This function returns no value. It either displays a plot (if file_path==NULL
) or saves a plot to a file.
Stilianos Louca
D. H. Parks, M. Chuvochina et al. (2018). A proposal for a standardized bacterial taxonomy based on genome phylogeny. bioRxiv 256800. DOI:10.1101/256800
write_tree
# generate a random ultrametric tree
tree = generate_random_tree(list(birth_rate_intercept=1), max_tips=50, tip_basename="tip.")$tree
# plot in radial layout
castor::plot_tree_radial(tree = tree,
show_scale_bar = TRUE,
tip_cex = 0.5,
node_cex = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.