phylox.networkproperties.murepresentation
A module for generating the mu-vectors for a given DiNetwork. The mu-vectors are added as attributes to the nodes.
author: Christopher Reichling co-author: Remie Janssen
Functions
|
The mu-vectors are added as a tuple(str, int, ..., int) with the label of the node as first entry, and then the mu-vector consisting of num_path values. |
The unlabeled mu-vectors are added as a tuple(int, ..., int) consisting of num_path values. |
- phylox.networkproperties.murepresentation.add_unlabeled_mu_vectors_as_attribute(network)
The unlabeled mu-vectors are added as a tuple(int, …, int) consisting of num_path values. For each labeled node, the num_paths value belonging to their label is set to one. Then, starting with the leaves and going up, the number of paths to each labeled node is calculated for all of the nodes, by adding the mu-vector of its children to that of itself.
The mu-vector entries are each sorted, as labels must be ignored after computing the vectors.
The resulting vectors are stored in the node attr MUVECTOR_UNLABELED_ATTR and the network is modified in place.
- Parameters:
network – a DiNetwork
- Example:
>>> from phylox import DiNetwork >>> from phylox.networkproperties.murepresentation import add_unlabeled_mu_vectors_as_attribute >>> network = DiNetwork.from_newick("((A,B),C);") >>> add_unlabeled_mu_vectors_as_attribute(network) >>> network.nodes[network.labels["A"][0]].get(MUVECTOR_UNLABELED_ATTR) (0, 0, 1) >>> network.nodes[network.labels["B"][0]].get(MUVECTOR_UNLABELED_ATTR) (0, 0, 1) >>> network.nodes[network.labels["C"][0]].get(MUVECTOR_UNLABELED_ATTR) (0, 0, 1)
- phylox.networkproperties.murepresentation.add_mu_vectors_as_attribute(network)
The mu-vectors are added as a tuple(str, int, …, int) with the label of the node as first entry, and then the mu-vector consisting of num_path values. For each labeled node, the num_paths value belonging to their label is set to one. Then, starting with the leaves and going up, the number of paths to each labeled node is calculated for all of the nodes, by adding the mu-vector of its children to that of itself.
The mu-vector entries are ordered by label.
The resulting vectors are stored in the node attr MUVECTOR_ATTR and the network is modified in place.
- Parameters:
network – a DiNetwork
- Example:
>>> from phylox import DiNetwork >>> from phylox.networkproperties.murepresentation import add_mu_vectors_as_attribute >>> network = DiNetwork.from_newick("((A,B),C);") >>> add_mu_vectors_as_attribute(network) >>> network.nodes[network.labels["A"][0]].get(MUVECTOR_ATTR) ('A', 1, 0, 0) >>> network.nodes[network.labels["B"][0]].get(MUVECTOR_ATTR) ('B', 0, 1, 0) >>> network.nodes[network.labels["C"][0]].get(MUVECTOR_ATTR) ('C', 0, 0, 1)