phylox.generators.trees.add_edges
Classes
|
- phylox.generators.trees.add_edges.random_vplu_move_at_bottom(network, seed=None)
Returns a VPLU move that adds an edge between the incoming edges of two leaves.
- Parameters:
network – the network to add an edge to.
seed – the seed to use for the random number generator, may be an integer or a numpy.random.RandomState.
- Returns:
a VPLU move that adds an edge between the incoming edges of two leaves.
- Example:
>>> from phylox import DiNetwork >>> from phylox.rearrangement.movetype import MoveType >>> from phylox.generators.trees.well_known import generate_balanced_tree >>> from phylox.generators.trees.add_edges import random_vplu_move_at_bottom >>> tree = generate_balanced_tree(8) >>> move = random_vplu_move_at_bottom(tree) >>> move.is_type(MoveType.VPLU) True
- phylox.generators.trees.add_edges.random_vplu_move_uniform(network, seed=None)
Returns a VPLU move that adds an edge between two edges in the network. Two edges are chosen uniformly at random from the network.
- Parameters:
network – the network to add an edge to.
seed – the seed to use for the random number generator, may be an integer or a numpy.random.RandomState.
- Returns:
a VPLU move that adds an edge between two edges in the network.
- Example:
>>> from phylox import DiNetwork >>> from phylox.rearrangement.movetype import MoveType >>> from phylox.generators.trees.well_known import generate_balanced_tree >>> from phylox.generators.trees.add_edges import random_vplu_move_uniform >>> tree = generate_balanced_tree(8) >>> move = random_vplu_move_uniform(tree) >>> move.is_type(MoveType.VPLU) True
- phylox.generators.trees.add_edges.random_vplu_move_local(network, stop_prob=0.2, max_steps=None, max_tries=None, seed=None)
Returns a VPLU move that adds an edge between two edges in the network. Pick one edge, move a random number of edges through the network to find a second edge.
- Parameters:
network – the network to add an edge to.
stop_prob – the probability to stop the random walk.
max_steps – the maximum number of steps to take in the random walk.
max_tries – the maximum number of tries to find a second edge.
- Returns:
a VPLU move that adds an edge between two edges in the network.
- Example:
>>> from phylox import DiNetwork >>> from phylox.rearrangement.movetype import MoveType >>> from phylox.generators.trees.well_known import generate_balanced_tree >>> from phylox.generators.trees.add_edges import random_vplu_move_local >>> tree = generate_balanced_tree(8) >>> move = random_vplu_move_local(tree) >>> move.is_type(MoveType.VPLU) True
- class phylox.generators.trees.add_edges.AddEdgeMethod(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
Enum
- phylox.generators.trees.add_edges.network_from_tree(tree, reticulations, method, seed=None)
Returns a network with the given number of reticulations added to the given tree.
- Parameters:
tree – a phylogenetic network, i.e., a DAG with leaf labels stored as the node attribute LABEL_ATTR.
reticulations – the number of reticulations to add to the tree.
method – the method to use to add the reticulations.
- Returns:
a network with the given number of reticulations added to the given tree.
- Example:
>>> from phylox import DiNetwork >>> from phylox.rearrangement.movetype import MoveType >>> from phylox.generators.trees.well_known import generate_balanced_tree >>> from phylox.generators.trees.add_edges import network_from_tree, AddEdgeMethod >>> tree = generate_balanced_tree(8) >>> network = network_from_tree(tree, 2, AddEdgeMethod.BOTTOM) >>> len(network.leaves) 8 >>> network.reticulation_number 2