phylogenie 2.1.9__tar.gz → 2.1.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of phylogenie might be problematic. Click here for more details.
- {phylogenie-2.1.9 → phylogenie-2.1.11}/PKG-INFO +1 -1
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/__init__.py +3 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/plot.py +7 -2
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/tree.py +9 -6
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/utils.py +1 -1
- {phylogenie-2.1.9 → phylogenie-2.1.11}/pyproject.toml +1 -1
- {phylogenie-2.1.9 → phylogenie-2.1.11}/LICENSE.txt +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/README.md +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/generators/__init__.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/generators/alisim.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/generators/configs.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/generators/dataset.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/generators/factories.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/generators/trees.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/generators/typeguards.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/io.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/main.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/models.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/msa.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/py.typed +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/skyline/__init__.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/skyline/matrix.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/skyline/parameter.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/skyline/vector.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/treesimulator/__init__.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/treesimulator/events/__init__.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/treesimulator/events/contact_tracing.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/treesimulator/events/core.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/treesimulator/events/mutations.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/treesimulator/features.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/treesimulator/gillespie.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/treesimulator/model.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/typeguards.py +0 -0
- {phylogenie-2.1.9 → phylogenie-2.1.11}/phylogenie/typings.py +0 -0
|
@@ -12,6 +12,7 @@ from phylogenie.generators import (
|
|
|
12
12
|
)
|
|
13
13
|
from phylogenie.io import dump_newick, load_fasta, load_newick
|
|
14
14
|
from phylogenie.msa import MSA
|
|
15
|
+
from phylogenie.plot import Coloring, plot_tree
|
|
15
16
|
from phylogenie.skyline import (
|
|
16
17
|
SkylineMatrix,
|
|
17
18
|
SkylineMatrixCoercible,
|
|
@@ -90,4 +91,6 @@ __all__ = [
|
|
|
90
91
|
"load_fasta",
|
|
91
92
|
"load_newick",
|
|
92
93
|
"MSA",
|
|
94
|
+
"Coloring",
|
|
95
|
+
"plot_tree",
|
|
93
96
|
]
|
|
@@ -3,6 +3,7 @@ from enum import Enum
|
|
|
3
3
|
import matplotlib.colors as mcolors
|
|
4
4
|
import matplotlib.patches as mpatches
|
|
5
5
|
import matplotlib.pyplot as plt
|
|
6
|
+
from matplotlib.axes import Axes
|
|
6
7
|
|
|
7
8
|
from phylogenie import Tree
|
|
8
9
|
from phylogenie.tree import Tree
|
|
@@ -16,13 +17,13 @@ class Coloring(str, Enum):
|
|
|
16
17
|
|
|
17
18
|
def plot_tree(
|
|
18
19
|
tree: Tree,
|
|
19
|
-
ax:
|
|
20
|
+
ax: Axes | None = None,
|
|
20
21
|
color_by: str | None = None,
|
|
21
22
|
default_color: str = "black",
|
|
22
23
|
coloring: str | Coloring | None = None,
|
|
23
24
|
cmap: str | None = None,
|
|
24
25
|
show_legend: bool = True,
|
|
25
|
-
) ->
|
|
26
|
+
) -> Axes:
|
|
26
27
|
if ax is None:
|
|
27
28
|
ax = plt.gca()
|
|
28
29
|
|
|
@@ -57,6 +58,10 @@ def plot_tree(
|
|
|
57
58
|
norm = mcolors.Normalize(vmin=min(values), vmax=max(values))
|
|
58
59
|
colormap = plt.get_cmap(cmap)
|
|
59
60
|
colors = {node: colormap(norm(float(node.get(color_by)))) for node in tree}
|
|
61
|
+
|
|
62
|
+
sm = plt.cm.ScalarMappable(cmap=colormap, norm=norm)
|
|
63
|
+
fig = ax.get_figure()
|
|
64
|
+
fig.colorbar(sm, ax=ax, label=color_by) # pyright: ignore
|
|
60
65
|
else:
|
|
61
66
|
raise ValueError(
|
|
62
67
|
f"Unknown coloring method: {coloring}. Choices are {list(Coloring)}."
|
|
@@ -22,6 +22,14 @@ class Tree:
|
|
|
22
22
|
def features(self) -> dict[str, Any]:
|
|
23
23
|
return self._features.copy()
|
|
24
24
|
|
|
25
|
+
@property
|
|
26
|
+
def time_to_parent(self) -> float:
|
|
27
|
+
if self.parent is None and self.branch_length is None:
|
|
28
|
+
return 0.0
|
|
29
|
+
if self.branch_length is None:
|
|
30
|
+
raise ValueError(f"Branch length of node {self.name} is not set.")
|
|
31
|
+
return self.branch_length
|
|
32
|
+
|
|
25
33
|
def add_child(self, child: "Tree") -> "Tree":
|
|
26
34
|
child._parent = self
|
|
27
35
|
self._children.append(child)
|
|
@@ -69,14 +77,9 @@ class Tree:
|
|
|
69
77
|
def get_leaves(self) -> tuple["Tree", ...]:
|
|
70
78
|
return tuple(node for node in self if not node.children)
|
|
71
79
|
|
|
72
|
-
def parse_branch_length(self) -> float:
|
|
73
|
-
if self.branch_length is None:
|
|
74
|
-
raise ValueError(f"Branch length of node {self.name} is not set.")
|
|
75
|
-
return self.branch_length
|
|
76
|
-
|
|
77
80
|
def get_time(self) -> float:
|
|
78
81
|
parent_time = 0 if self.parent is None else self.parent.get_time()
|
|
79
|
-
return self.
|
|
82
|
+
return self.time_to_parent + parent_time
|
|
80
83
|
|
|
81
84
|
def set(self, key: str, value: Any) -> None:
|
|
82
85
|
self._features[key] = value
|
|
@@ -14,7 +14,7 @@ def get_times(tree: Tree) -> dict[str, float]:
|
|
|
14
14
|
times: dict[str, float] = {}
|
|
15
15
|
for node in tree:
|
|
16
16
|
parent_time = 0 if node.parent is None else times[node.parent.name]
|
|
17
|
-
times[node.name] = node.
|
|
17
|
+
times[node.name] = node.time_to_parent + parent_time
|
|
18
18
|
return times
|
|
19
19
|
|
|
20
20
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|