PCMBase (version 1.2.10)

PCMTreeEvalNestedEDxOnTree: Perfrorm nested extractions or drops of clades from a tree

Description

Perfrorm nested extractions or drops of clades from a tree

Usage

PCMTreeEvalNestedEDxOnTree(expr, tree)

Arguments

expr

a character string representing an R expression of nested calls of functions E(x,node) denoting extracting the clade rooted at node from the tree x, or D(x,node), denoting dropping the clade rooted at node from the tree x. These calls can be nested, i.e. x can be either the symbol x (corresponding to the original tree passed as argument) or a nested call to d or e.

tree

a phylo object with named tips and internal nodes

Value

the resulting phylo object from evaluating expr on tree.

Examples

Run this code
# NOT RUN {
set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion")
tree <- PCMTree(ape::rtree(25))
PCMTreeSetPartRegimes(
  tree, c(`26`="a", `28`="b", `45`="c", `47`="d"), setPartition = TRUE)
# }
# NOT RUN {
PCMTreePlot(
  tree, palette=c(a = "red", b = "green", c = "blue", d = "magenta")) +
  ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# }
# NOT RUN {
bluePart <- PCMTreeEvalNestedEDxOnTree("D(E(tree,45),47)", tree)
PCMTreeGetPartRegimes(bluePart)
# }
# NOT RUN {
PCMTreePlot(
  bluePart, palette=c(a = "red", b = "green", c = "blue", d = "magenta")) +
  ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# }
# NOT RUN {
# Swapping the D and E calls has the same result:
bluePart2 <- PCMTreeEvalNestedEDxOnTree("E(D(tree,47),45)", tree)
PCMTreeGetPartRegimes(bluePart2)
# }
# NOT RUN {
PCMTreePlot(
  bluePart2, palette=c(a = "red", b = "green", c = "blue", d = "magenta")) +
  ggtree::geom_nodelab(angle = 45) + ggtree::geom_tiplab(angle = 45)
# }

Run the code above in your browser using DataCamp Workspace