PCMBase (version 1.2.10)

PCMTreeSetPartition: Set a partition of a tree by specifying the partition nodes

Description

Set a partition of a tree by specifying the partition nodes

Usage

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

PCMTreeGetPartition

PCMTree

Examples

Run this code
# NOT RUN {
set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion")
tree <- PCMTree(ape::rtree(8))
PCMTreeSetLabels(tree, paste0("x", PCMTreeGetLabels(tree)))
PCMTreeGetPartition(tree)
PCMTreeGetPartNames(tree)
PCMTreeGetPartRegimes(tree)
# }
# NOT RUN {
PCMTreePlot(tree) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
# }
# NOT RUN {
tree <- PCMTreeSetPartition(tree, c(12, 14), inplace = FALSE)
PCMTreeGetPartition(tree)
PCMTreeGetPartNames(tree)
PCMTreeGetPartRegimes(tree)
# }
# NOT RUN {
PCMTreePlot(tree) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
# }
# NOT RUN {
# reset the partition to a default one, where there is only one part:
PCMTreeSetPartition(tree)

PCMTreeGetPartition(tree)
PCMTreeGetPartNames(tree)
PCMTreeGetPartRegimes(tree)
# }
# NOT RUN {
PCMTreePlot(tree) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
# }
# NOT RUN {
# reset the labels to the default labels which are character representations
# of the node ids
PCMTreeSetLabels(tree)
PCMTreeGetPartition(tree)
PCMTreeGetPartNames(tree)
PCMTreeGetPartRegimes(tree)

# }

Run the code above in your browser using DataCamp Workspace