# Set random seed:
set.seed(2)
# Use Day 2016 as source matrix:
cladistic_matrix <- day_2016
# Prune out continuous characters:
cladistic_matrix <- prune_cladistic_matrix(
cladistic_matrix =
cladistic_matrix, blocks2prune = 1
)
# Prune out majority of characters so
# example runs quickly:
cladistic_matrix <- prune_cladistic_matrix(
cladistic_matrix =
cladistic_matrix, characters2prune = 1:32
)
# Generete random tree for matrix taxa:
time_tree <- ape::rtree(n = nrow(day_2016$matrix_1$matrix))
# Add taxon names to tree:
time_tree$tip.label <- rownames(x = day_2016$matrix_1$matrix)
# Add root age to tree:
time_tree$root.time <- max(diag(x = ape::vcv(phy = time_tree)))
# Get all state changes for two simulations:
state_changes <-
map_stochastic_changes(
cladistic_matrix = cladistic_matrix,
time_tree = time_tree, time_bins = seq(time_tree$root.time, 0,
length.out = 3
), n_simulations = 2
)
# View matrix of all stochstic character changes:
state_changes$all_state_changes
# View vector of sampled time for each character:
state_changes$character_times
# View matrix of edge lengths in each time bin:
state_changes$binned_edge_lengths
# View matrix of terminal edge lengths in each time bin:
state_changes$binned_terminal_edge_lengths
# View matrix of internal edge lengths in each time bin:
state_changes$binned_internal_edge_lengths
Run the code above in your browser using DataLab