PCMTree is class that inherits from the class 'phylo' in the R-package 'ape'. Thus, all the functions working on a phylo object would work in the same way if they receive as argument an object of class 'PCMTree'. A PCMTree object has the following members in addition to the regular members ('tip.label', 'node.label', 'edge', 'edge.length') found in a regular phylo object:

edge.part

a character vector having as many elements as there are branches in the tree (corresponding to the rows in `tree$edge`). Each element denotes the name of the part to which the corresponding branch belongs. A part in the tree represents a connected subset of its nodes and the branches leading to these nodes. A partition of the tree represents the splitting of the tree into a number of parts. Visually, a partition can be represented as a coloring of the tree, in which no color is assigned to more than one part. In other words, if two branches in the tree are connected by the same color, they either share a node, or all the branches on the path in the tree connecting these two branches have the same color. Formally, we define a partition of the tree as any set of nodes in the tree that includes the root. Each node in this set defines a part as the set of its descendant nodes that can be reached without traversing another partition node. We name each part by the label of its most ancestral node, that is, the node in it, which is closest to the root fo the tree. The value of edge.part for an edge in the tree is the name of the part that contains the node to which the edge is pointing.

part.regime

a named vector of size the number of parts in the tree. The names correspond to part-names whereas the values denote the ids or character names of regimes in a PCM object.

The constructor PCMTree() returns an object of call

PCMTree(tree)

Arguments

tree

a phylo object. If this is already a PCMTree object, a copy of this object will be returned.

Value

an object of class PCMTree. This is a copy of the passed phylo object which is guaranteed to have node.label, edge.part and a part.regime entries set.

Examples

tree <- ape::rtree(8) # the following four are NULLs tree$node.label
#> NULL
tree$edge.part
#> NULL
tree$part.regime
#> NULL
tree$edge.regime
#> NULL
# In previous version regimes were assigned directly to the edges via # tree$edge.regime. This is supported but not recommended anymore: tree$edge.regime <- sample( letters[1:3], size = PCMTreeNumNodes(tree) - 1, replace = TRUE) tree.a <- PCMTree(tree) PCMTreeGetLabels(tree.a)
#> [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15"
tree.a$node.label
#> [1] "9" "10" "11" "12" "13" "14" "15"
tree.a$edge.part
#> [1] "9" "1" "11" "2" "11" "9" "13" "13" "14" "5" "6" "15" "7" "8"
tree.a$part.regime
#> 9 1 11 13 15 2 14 7 8 5 6 #> "c" "b" "a" "b" "b" "c" "a" "c" "a" "b" "b"
# this is set to NULL - starting from PCMBase 1.2.9 all of the information # for the regimes is stored in tree$edge.part and tree$part.regime. tree.a$edge.regime
#> NULL
#> 9 1 11 13 15 2 14 7 8 5 6 #> 9 1 11 13 15 2 14 7 8 5 6
#> [1] "9" "1" "11" "13" "15" "2" "14" "7" "8" "5" "6"
#> 9 1 11 13 15 2 14 7 8 5 6 #> "c" "b" "a" "b" "b" "c" "a" "c" "a" "b" "b"
# let's see how the tree looks like
PCMTreePlot(tree.a) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
#> Loading required namespace: ggtree
#> Registered S3 method overwritten by 'treeio': #> method from #> root.phylo ape
# This is the recommended way to set a partition on the tree PCMTreeSetPartition(tree.a, c(10, 12)) PCMTreeGetPartition(tree.a)
#> 9 10 12 #> 9 10 12
#> [1] "9" "10" "12"
#> 9 10 12 #> 1 2 3
PCMTreePlot(tree.a) + ggtree::geom_nodelab() + ggtree::geom_tiplab()
PCMTreeGetPartsForNodes(tree.a, c(11, 15, 12))
#> [1] "10" "12" "12"
PCMTreeGetPartsForNodes(tree.a, c("11", "15", "12"))
#> [1] "10" "12" "12"
PCMTreeSetPartRegimes(tree.a, c(`9` = 'a', `10` = 'b', `12` = 'c')) PCMTreeGetPartition(tree.a)
#> 9 10 12 #> 9 10 12
#> [1] "9" "10" "12"
#> 9 10 12 #> "a" "b" "c"
PCMTreePlot(tree.a) + ggtree::geom_nodelab() + ggtree::geom_tiplab()