Set a partition of a tree by specifying the partition nodes

PCMTreeSetPartition(tree, nodes = c(PCMTreeNumTips(tree) + 1L), inplace = TRUE)

Arguments

tree

a PCMTree object.

nodes

a character vector containing tip or node labels or an integer vector denoting tip or internal nodes in tree - the parts change at the start of the branches leading to these nodes. Default: c(PCMTreeNumTips(tree) + 1L).

inplace

a logical indicating if the change should be done to the tree in the calling environment (TRUE) or a copy of the tree with set edge.part member should be returned (FALSE). Default is TRUE.

Value

If inplace is TRUE nothing, otherwise a copy of the tree with set edge.part member.

See also

Examples

set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion") tree <- PCMTree(ape::rtree(8)) PCMTreeSetLabels(tree, paste0("x", PCMTreeGetLabels(tree))) PCMTreeGetPartition(tree)
#> x9 #> 9
#> [1] "x9"
#> x9 #> 1
# \donttest{ PCMTreePlot(tree) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
# } tree <- PCMTreeSetPartition(tree, c(12, 14), inplace = FALSE) PCMTreeGetPartition(tree)
#> x9 x14 x12 #> 9 14 12
#> [1] "x9" "x14" "x12"
#> x9 x14 x12 #> 1 2 3
# \donttest{ PCMTreePlot(tree) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
# } # reset the partition to a default one, where there is only one part: PCMTreeSetPartition(tree) PCMTreeGetPartition(tree)
#> x9 #> 9
#> [1] "x9"
#> x9 #> 1
# \donttest{ PCMTreePlot(tree) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
# } # reset the labels to the default labels which are character representations # of the node ids PCMTreeSetLabels(tree) PCMTreeGetPartition(tree)
#> 9 #> 9
#> [1] "9"
#> 9 #> 1