Moves

There are several operations to change the topology or any of the branch lengths of a tree. The different functions which are available in MCPhyloTree are listed here.

While the tree building methods in this package are generally built in a way that ensures that the nodes of the tree are fully initialized, i.e. they have a unique number, binary representation and a height, the move methods listed here do not automatically update these fields. After using these methods you might want to run initialize_tree! or update_tree! to ensure the nodes remain / are initialized.

WARNING: Do not run initialize_tree! after changing a tree, if you rely on the num field of the nodes to identify them. The same applies to the method number_nodes that is called in initalize_tree.

Edge Length

MCPhyloTree.change_edge_length!Method
change_edge_length!(root::T) where T <:AbstractNode

Pick a random node and increase or decrease its length randomly.

  • root : root node of tree.
source
MCPhyloTree.move!Method
move!(node1::T, node2::T, proportion::Float64) where T <:AbstractNode

Change the incoming length of node1 and node2 while keeping their combined length constant.

  • node1 : Node whose inc_length will be modified; this node's inc_length will be the total inc_length of both nodes, times proportion.

  • node2 : Node whose inc_length will be modified; this node's inc_length will be the remainder of total - the new inc_length value of node1.

  • proportion : Float64, determines proportion of the inc_length of both nodes assigned to node1.

source
MCPhyloTree.slide!Method
slide!(root::T) where T<:AbstractNode

This function performs a slide move on an intermediate node. The node is moved upwards or downwards on the path specified by its mother and one of its daughters.

  • root : root Node of tree.
source
MCPhyloTree.slideMethod
slide(root::T)::T where T<:AbstractNode

This function performs a slide move on an intermediate node. The node is moved upwards or downwards on the path specified by its mother and one of its daughters.

Returns root Node of new tree.

  • root : root Node of tree.
source
MCPhyloTree.swing!Method
swing!(root::T) where T<:AbstractNode

This function performs a swing node. A random non-leave node is selected and moved along the path specified by its two children.

  • root : root Node of tree.
source
MCPhyloTree.swingMethod
swing(root::T)::T where T<:AbstractNode

This function performs a swing node. A random non-leave node is selected and moved along the path specified by its two children.

Returns root Node of new tree.

  • root : root Node of tree.
source

NNI

MCPhyloTree.NNI!Method
NNI!(root::T)::Int64  where T<:AbstractNode

This function does a nearest neighbour interchange (NNI) move on the tree specified by root. The target is identified by the number of the target node.

The function returns 1 if the move was successful and 0 else.

  • root : root node of tree on which to perform the NNI.
source
MCPhyloTree.NNI!Method
NNI!(root::T, target::Int64)::Int64  where T<:AbstractNode

This function does a nearest neighbour interchange (NNI) move on the tree specified by root. The target is identified by the number of the target node.

The function returns 1 if the move was successful and 0 else.

  • root : root node of tree on which to perform the NNI.

  • target : specific node of tree to interchange.

source
MCPhyloTree.NNI!Method
NNI!(root::T, target::Int64)::Int64  where T<:AbstractNode

This function does a nearest neighbour interchange (NNI) move on the tree specified by root. The target is identified by the number of the target node. The function returns 1 if the move was successfull and 0 else.

source
MCPhyloTree.NNI!Method
NNI(root::T, target::T, lor::Bool)::Int64   where T<:AbstractNode

This function does a nearest neighbour interchange (NNI) move on the tree specified by root. The parameter target specifies the node which performs the interchange move using the left or right child of the target node. If the left child should be used lor=true.

The function returns 1 if the move was successful and 0 else.

  • root : root node of tree on which to perform the NNI.

  • target : specific node of tree to interchange.

  • lor : Bool; "true" uses the left child of target, "false," the right child.

source
MCPhyloTree.NNIMethod
NNI(root::T)::T  where T<:AbstractNode

This function does a nearest neighbour interchange (NNI) move on the tree specified by root.

Returns a mutated copy while leaving the original tree intact.

  • root : root node of tree on which to perform the NNI.
source

Randomize

MCPhyloTree.randomize!Method
randomize!(root::T, num::Int64=100)::Nothing where T <:AbstractNode

This function randomizes the tree by performing a number of nearest neighbour interchange (NNI) moves and a randomization of the branch lengths. The number of NNI moves is specified in the parameter num.

  • root : root node of tree to be edited.

  • num : amount of NNI moves to perform.

source
MCPhyloTree.randomizeMethod
randomize(root::T, num::Int64=100)::T where T <:AbstractNode

This function returns a randomized copy of the tree by performing a number of nearest neighbour interchange (NNI) moves and a randomization of the branch lengths. The number of NNI moves is specified in the parameter num.

  • root : root node of tree to be edited.

  • num : amount of NNI moves to perform.

source

Rerooting

SPR

MCPhyloTree.SPR!Method
SPR!(root::T)::T where T <:AbstractNode

Performs SPR on tree in place. Takes reference to root of tree; Returns reference to root of altered tree. Throws error if tree is improperly formatted.

source
MCPhyloTree.SPRMethod
function SPR(original_root<:AbstractNode)

Performs SPR on tree. Takes a copy of root of the tree; Returns a copy of root of altered tree. Throws error if tree is improperly formatted.

source
MCPhyloTree.perform_sprMethod
perform_spr(root::T) where T <: GeneralNode

performs SPR on binary tree. Returns root of tree post-SPR.

  • root : Node of tree on which to perform SPR.
source
MCPhyloTree.perform_sprMethod
perform_spr(root::T,subtree::T,target::T) where T <: GeneralNode

performs SPR on binary tree. Returns root of tree post-SPR.

  • root : Node of tree on which to perform SPR.
  • subtree : Root of subtree to be moved.
  • target : Target of SPR.
source
MCPhyloTree.perform_sprMethod
perform_spr(root::T,subtree::T) where T <: GeneralNode

performs SPR on binary tree. Returns root of tree post-SPR.

  • root : Node of tree on which to perform SPR.
  • subtree : Root of subtree to be moved.
source
MCPhyloTree.risky_SPR!Method
    risky_SPR!(root<:AbstractNode)

Performs SPR on tree in place. Returns reference to root of altered tree. Does not check for correct formatting of tree.

  • root : root node of tree.
source
MCPhyloTree.risky_SPRMethod
function risky_SPR(original_root::T)::T where T<:AbstractNode

Performs SPR on tree in place. Takes reference to root of tree Returns copy of root of altered tree. Does not check for correct formatting of tree.

source