# NOT RUN {
tree <- PCMTree(ape::rtree(25))
PCMTreeGetPartition(tree)
PCMTreeGetPartRegimes(tree)
PCMTreeGetPartNames(tree)
PCMTreeSetPartRegimes(tree, c(`26` = 2))
PCMTreeGetPartition(tree)
PCMTreeGetPartRegimes(tree)
PCMTreeGetPartNames(tree)
PCMTreeSetPartRegimes(tree, c(`26` = "global-regime"))
PCMTreeGetPartition(tree)
PCMTreeGetPartRegimes(tree)
PCMTreeGetPartNames(tree)
# This should fail because no partition with nodes 26, 28 and 41 has been
# done.
ggplot2::should_stop(
PCMTreeSetPartRegimes(tree, c(`26` = "a", `28` = "b", `41` = "c")))
# This should succeed and change the partition as well as regime assignment
PCMTreeSetPartRegimes(
tree, c(`26` = "a", `28` = "b", `41` = "c"), setPartition = TRUE)
PCMTreeGetPartition(tree)
PCMTreeGetPartRegimes(tree)
PCMTreeGetPartNames(tree)
set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion")
# number of tips
N <- 40
# tree with one regime
tree.a <- ape::rtree(N)
tree.a <- PCMTree(tree.a)
PCMTreeSetPartRegimes(
tree.a,
part.regime = structure("a", names = as.character(N+1L)),
setPartition = TRUE,
inplace = TRUE)
# }
# NOT RUN {
PCMTreePlot(tree.a) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
# }
# NOT RUN {
tree.ab <- tree.a
PCMTreeSetPartRegimes(
tree.ab,
part.regime = structure(c("a", "b"), names = as.character(c(N+1L, N+31L))),
setPartition = TRUE,
inplace = TRUE)
# }
# NOT RUN {
PCMTreePlot(tree.ab) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
# }
Run the code above in your browser using DataCamp Workspace