View source: R/plot_changes_on_tree.R
plot_changes_on_tree | R Documentation |
Plots character changes in boxes on branches.
plot_changes_on_tree(character_changes, time_tree, label_size = 0.5)
character_changes |
A matrix of character changes. |
time_tree |
Tree on which character changes occur. |
label_size |
The size of the text for the barnch labels. Default is 0.5. |
Takes the character_changes
output from test_rates and plots it on the tree used to generate it.
A plot of character changes on a tree.
Graeme T. Lloyd graemetlloyd@gmail.com
# Set random seed:
set.seed(17)
# Get first MPT for the Michaux data set:
time_tree <- ape::read.tree(text = paste0("(Ancilla:31.6,(Turrancilla:102.7,",
"(Ancillista:1,Amalda:63.5):1):1);"))
# Set root time for tree:
time_tree$root.time <- 103.7
# Generate two equal length time bins:
time_bins <- matrix(data = c(seq(time_tree$root.time, 0, length.out = 3)[1:2],
seq(time_tree$root.time, 0, length.out = 3)[2:3]), ncol = 2, dimnames = list(LETTERS[1:2],
c("fad", "lad")))
# Set class as timeBins:
class(time_bins) <- "timeBins"
# Get discrete character rates (includes changes):
out <- test_rates(
time_tree = time_tree,
cladistic_matrix = michaux_1989,
time_bins = time_bins,
branch_partitions = list(list(1)),
alpha = 0.01
)
# Plot character changes on the tree:
plot_changes_on_tree(
character_changes = out$inferred_character_changes,
time_tree = time_tree
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.