plot_changes_on_tree: Plots character changes on branches

View source: R/plot_changes_on_tree.R

plot_changes_on_treeR Documentation

Plots character changes on branches

Description

Plots character changes in boxes on branches.

Usage

plot_changes_on_tree(character_changes, time_tree, label_size = 0.5)

Arguments

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.

Details

Takes the character_changes output from test_rates and plots it on the tree used to generate it.

Value

A plot of character changes on a tree.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

Examples


# 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
)

Claddis documentation built on Sept. 11, 2024, 9:18 p.m.