degradeTree | R Documentation |
degradeTree
removes a proportion of the total nodes in a tree, chosen
randomly, collapsing the nodes to produce a less-resolved tree. The related function collapseNodes
given a tree and a vector of nodes to collapse, removes those nodes from a tree, creating a polytomy.
degradeTree( tree, prop_collapse = NULL, nCollapse = NULL, node.depth = NA, leave.zlb = FALSE ) collapseNodes(tree, nodeID, collapseType, leave.zlb = FALSE)
tree |
A phylogeny of class |
prop_collapse |
Proportion of nodes to collapse |
nCollapse |
Number of nodes to collapse, can be supplied as an
alternative to |
node.depth |
A number between 0 to 1, which conditions the depth of
nodes removed. If |
leave.zlb |
If |
nodeID |
The node ID number(s) to be collapsed into a polytomy, as identified in
the |
collapseType |
Whether to collapse the edge leading the listed node
(if |
In the function degradeTree
, the nodes are removed at random
using the basic R function sample
. degradeTree
can be conditioned to remove nodes of a particular depth with greater
probability/frequency by setting node.depth to a value between zero
(favoring the removal of deep nodes close to the root) or one (shallow nodes
far from the root). Depth is evaluated based on the number of descendant
tips. If node.depth is not NA, the relative proportion of descendants from
each node is calculated, summed to 1 and the node.depth value subtracted
from this proportion. These values are then squared, normalized again to
equal to 1 and then used as the probabilities for sampling nodes for
removal.
By default, branch lengths are removed from the input tree prior to
degradation and entirely absent from the output tree. This is changed if
argument leave.zlb
is TRUE.
Returns the modified tree as an object of class phylo
, with no edge
lengths by default.
David W. Bapst
di2multi
,timeLadderTree
set.seed(444) tree <- rtree(100) tree1 <- degradeTree(tree,prop_collapse = 0.5) tree3 <- degradeTree(tree,nCollapse = 50) #let's compare the input and output layout(matrix(1:2,,2)) plot(tree,show.tip.label = FALSE,use.edge.length = FALSE) plot(tree1,show.tip.label = FALSE,use.edge.length = FALSE) #now with collapseNodes tree <- rtree(10) #collapse nodes backwards #let's collapse lucky node number 13! tree1 <- collapseNodes(nodeID = 13,tree = tree,collapseType = "backward") #collapse nodes forwards tree2 <- collapseNodes(nodeID = 13,tree = tree,collapseType = "forward") #collapse entire clade tree3 <- collapseNodes(nodeID = 13,tree = tree,collapseType = "clade") #let's compare layout(1:4) plot(tree,use.edge.length = FALSE,main = "original") plot(tree1,use.edge.length = FALSE,main = "backward collapse") plot(tree2,use.edge.length = FALSE,main = "forward collapse") plot(tree3,use.edge.length = FALSE,main = "entire clade") layout(1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.