Prune the tree leaving one tip for each or some of its parts

PCMTreeBackbonePartition(tree, partsToKeep = PCMTreeGetPartNames(tree))

Arguments

tree

a PCMTree or a phylo object.

partsToKeep

a character vector denoting part names in the tree to be kept. Defaults to `PCMTreeGetPartNames(tree)`.

Value

a PCMTree object representing a pruned version of tree.

See also

PCMTreeSetPartition

PCMTree

Examples

set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion") tree <- PCMTree(ape::rtree(25)) # \donttest{ PCMTreePlot(tree) + ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# } backb <- PCMTreeBackbonePartition(tree) # \donttest{ PCMTreePlot(backb) + ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# } tree2 <- PCMTreeSetPartRegimes( tree, c(`26` = "a", `28` = "b"), setPartition = TRUE, inplace = FALSE) # \donttest{ PCMTreePlot(tree2) + ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# } backb <- PCMTreeBackbonePartition(tree2) # \donttest{ PCMTreePlot(backb) + ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# } tree3 <- PCMTreeSetPartRegimes( tree, c(`26` = "a", `28` = "b", `41` = "c"), setPartition = TRUE, inplace = FALSE) # \donttest{ PCMTreePlot(tree3) + ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# } backb <- PCMTreeBackbonePartition(tree3) # \donttest{ PCMTreePlot(backb) + ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# } backb41 <- PCMTreeBackbonePartition(tree3, partsToKeep = "41") # \donttest{ PCMTreePlot(backb41) + ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# } backbMoreNodes <- PCMTreeInsertSingletonsAtEpoch( backb, epoch = 3.7, minLength = 0.001) PCMTreeGetPartRegimes(backbMoreNodes)
#> 26 28 41 #> "a" "b" "c"
# \donttest{ PCMTreePlot(backbMoreNodes) + ggtree::geom_nodelab(angle=45) + ggtree::geom_tiplab(angle=45)
# } backbMoreNodes <- PCMTreeInsertSingletonsAtEpoch( backbMoreNodes, epoch = 0.2, minLength = 0.001) PCMTreeGetPartRegimes(backbMoreNodes)
#> 26 28 41 #> "a" "b" "c"
# \donttest{ PCMTreePlot(backbMoreNodes) + ggtree::geom_nodelab(angle=45) + ggtree::geom_tiplab(angle=45)
# } backbMoreNodes <- PCMTreeInsertSingletonsAtEpoch( backbMoreNodes, epoch = 1.2, minLength = 0.001) PCMTreeGetPartRegimes(backbMoreNodes)
#> 26 i_1.2_x_28 41 #> "a" "b" "c"
# \donttest{ PCMTreePlot(backbMoreNodes) + ggtree::geom_nodelab(angle=45) + ggtree::geom_tiplab(angle=45)
# }