| plotBranchbyTrait {phytools} | R Documentation |
Plot branch colors by a quantitative trait or value
Description
Function plots a tree with branches colored by the value for a quantitative trait or probability, by various methods.
Usage
plotBranchbyTrait(tree, x, mode=c("edges","tips","nodes"), palette="rainbow",
legend=TRUE, xlims=NULL, ...)
Arguments
tree |
an object of class "phylo".
|
x |
either a vector of states for the edges, tips, or nodes of the tree (for mode="edges", "tips", and "nodes", respectively).
|
mode |
string indicating plotting mode. mode="edges", the default, requires that the mapping state of each edge in the tree should be provided. mode="tips" takes the tip values and estimates the state at each internal node. The mapped character value along each branch is the average of the nodes subtending that branch. mode="nodes" similar to "tips", except that the node values are provided instead of estimated.
|
palette |
color palette to translate character values to color. Options are presently "rainbow" (the default), "heat.colors", and "gray". palette can also be a function produced by colorRampPalette.
|
legend |
can be a logical value (TRUE or FALSE) or a numeric value greater than 0. In the latter case the numeric value gives the length of the plotted legend, which also acts as a scale bar for the branch lengths of the tree.
|
xlims |
range for the translation map between trait values and the color map. Should be inclusive of all the values in x.
|
... |
other optional arguments to be passed to plot.phylo - pretty much all arguments are available. In addition, there plotBranchbyTrait has the following additional optional arguments: tol a small tolerance value to be added to the range of x; prompt for legend=TRUE, a logical value indicating whether to prompt for the position of the legend (or not) - the default is to put the legend in the lower left hand size of the plot; title for legend=TRUE, the title of the legend; and digits for legend=TRUE, the number of digits in the quantitative scale of the legend. Finally, cex can be supplied as either a single numeric value, or as a vector of two different values. If the latter is true than the second element of cex will be passed internally to the function add.color.bar.
|
Details
Unlike most other tree plotting functions in phytools, this function calls plot.phylo (not plotSimmap) internally.
Note that if prompt=TRUE, the function will prompt for the position of the legend.
Value
Plots a phylogeny.
Author(s)
Liam Revell liam.revell@umb.edu
References
Revell, L. J. (2024) phytools 2.0: an updated R ecosystem for phylogenetic comparative methods (and other things). PeerJ, 12, e16505.
[Package
phytools version 2.3-0
Index]