bella-companion 0.0.44__tar.gz → 0.0.45__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 bella-companion might be problematic. Click here for more details.

Files changed (123) hide show
  1. {bella_companion-0.0.44 → bella_companion-0.0.45}/PKG-INFO +2 -2
  2. bella_companion-0.0.45/bella_companion/__pycache__/__init__.cpython-310.pyc +0 -0
  3. bella_companion-0.0.45/bella_companion/__pycache__/cli.cpython-310.pyc +0 -0
  4. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/cli.py +2 -2
  5. bella_companion-0.0.45/bella_companion/eucovid/__pycache__/__init__.cpython-310.pyc +0 -0
  6. bella_companion-0.0.45/bella_companion/eucovid/__pycache__/run_beast.cpython-310.pyc +0 -0
  7. bella_companion-0.0.45/bella_companion/platyrrhine/__init__.py +5 -0
  8. bella_companion-0.0.45/bella_companion/platyrrhine/__pycache__/__init__.cpython-310.pyc +0 -0
  9. bella_companion-0.0.45/bella_companion/platyrrhine/__pycache__/results.cpython-310.pyc +0 -0
  10. bella_companion-0.0.45/bella_companion/platyrrhine/__pycache__/run_beast.cpython-310.pyc +0 -0
  11. bella_companion-0.0.45/bella_companion/platyrrhine/__pycache__/summarize.cpython-310.pyc +0 -0
  12. bella_companion-0.0.45/bella_companion/platyrrhine/__pycache__/summarize_logs.cpython-310.pyc +0 -0
  13. bella_companion-0.0.45/bella_companion/platyrrhine/results.py +109 -0
  14. bella_companion-0.0.44/bella_companion/platyrrhine/summarize_logs.py → bella_companion-0.0.45/bella_companion/platyrrhine/summarize.py +6 -6
  15. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/__init__.py +2 -2
  16. bella_companion-0.0.45/bella_companion/simulations/__pycache__/__init__.cpython-310.pyc +0 -0
  17. bella_companion-0.0.45/bella_companion/simulations/__pycache__/features.cpython-310.pyc +0 -0
  18. bella_companion-0.0.45/bella_companion/simulations/__pycache__/generate_data.cpython-310.pyc +0 -0
  19. bella_companion-0.0.45/bella_companion/simulations/__pycache__/generate_figures.cpython-310.pyc +0 -0
  20. bella_companion-0.0.45/bella_companion/simulations/__pycache__/metrics.cpython-310.pyc +0 -0
  21. bella_companion-0.0.45/bella_companion/simulations/__pycache__/run_beast.cpython-310.pyc +0 -0
  22. bella_companion-0.0.45/bella_companion/simulations/__pycache__/summarize.cpython-310.pyc +0 -0
  23. bella_companion-0.0.45/bella_companion/simulations/__pycache__/summarize_logs.cpython-310.pyc +0 -0
  24. bella_companion-0.0.45/bella_companion/simulations/figures/__pycache__/__init__.cpython-310.pyc +0 -0
  25. bella_companion-0.0.45/bella_companion/simulations/figures/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  26. bella_companion-0.0.45/bella_companion/simulations/figures/__pycache__/epi_skyline.cpython-310.pyc +0 -0
  27. bella_companion-0.0.45/bella_companion/simulations/figures/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  28. bella_companion-0.0.45/bella_companion/simulations/figures/__pycache__/fbd_no_traits.cpython-310.pyc +0 -0
  29. bella_companion-0.0.45/bella_companion/simulations/figures/__pycache__/scenarios.cpython-310.pyc +0 -0
  30. bella_companion-0.0.45/bella_companion/simulations/figures/__pycache__/utils.cpython-310.pyc +0 -0
  31. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/epi_multitype.py +3 -3
  32. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/epi_skyline.py +1 -1
  33. bella_companion-0.0.45/bella_companion/simulations/figures/explain/__pycache__/__init__.cpython-310.pyc +0 -0
  34. bella_companion-0.0.45/bella_companion/simulations/figures/explain/__pycache__/pdp.cpython-310.pyc +0 -0
  35. bella_companion-0.0.45/bella_companion/simulations/figures/explain/__pycache__/shap.cpython-310.pyc +0 -0
  36. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/fbd_2traits.py +3 -3
  37. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/fbd_no_traits.py +1 -3
  38. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/metrics.py +1 -1
  39. bella_companion-0.0.45/bella_companion/simulations/scenarios/__pycache__/__init__.cpython-310.pyc +0 -0
  40. bella_companion-0.0.45/bella_companion/simulations/scenarios/__pycache__/common.cpython-310.pyc +0 -0
  41. bella_companion-0.0.45/bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  42. bella_companion-0.0.45/bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-310.pyc +0 -0
  43. bella_companion-0.0.45/bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  44. bella_companion-0.0.45/bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-310.pyc +0 -0
  45. bella_companion-0.0.45/bella_companion/simulations/scenarios/__pycache__/scenario.cpython-310.pyc +0 -0
  46. bella_companion-0.0.44/bella_companion/simulations/summarize_logs.py → bella_companion-0.0.45/bella_companion/simulations/summarize.py +2 -2
  47. bella_companion-0.0.45/bella_companion/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  48. bella_companion-0.0.45/bella_companion/utils/__pycache__/beast.cpython-310.pyc +0 -0
  49. bella_companion-0.0.45/bella_companion/utils/__pycache__/explain.cpython-310.pyc +0 -0
  50. bella_companion-0.0.45/bella_companion/utils/__pycache__/slurm.cpython-310.pyc +0 -0
  51. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion.egg-info/PKG-INFO +2 -2
  52. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion.egg-info/SOURCES.txt +41 -3
  53. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion.egg-info/requires.txt +1 -1
  54. {bella_companion-0.0.44 → bella_companion-0.0.45}/pyproject.toml +2 -2
  55. bella_companion-0.0.44/bella_companion/platyrrhine/__init__.py +0 -5
  56. bella_companion-0.0.44/bella_companion/platyrrhine/results.py +0 -69
  57. {bella_companion-0.0.44 → bella_companion-0.0.45}/README.md +0 -0
  58. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/BELLA.jar +0 -0
  59. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/__init__.py +0 -0
  60. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/__init__.py +0 -0
  61. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/beast_configs/GLM.xml +0 -0
  62. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/beast_configs/MLP.xml +0 -0
  63. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/beast_configs/Nonparametric.xml +0 -0
  64. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/case_data.tsv +0 -0
  65. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/change_dates.tsv +0 -0
  66. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/msa.fasta +0 -0
  67. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/osi.tsv +0 -0
  68. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/closedborders_7e_nt.tsv +0 -0
  69. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/dist_7e_ls.tsv +0 -0
  70. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/flight_7e_ls.tsv +0 -0
  71. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/flight_pop_x_7e_ls.tsv +0 -0
  72. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/osi_x_7e_ls.tsv +0 -0
  73. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/osi_y_7e_ls.tsv +0 -0
  74. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/pop_x_7e_ls.tsv +0 -0
  75. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/pop_y_7e_ls.tsv +0 -0
  76. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/all/sharedborders_7e_nt.tsv +0 -0
  77. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/changetimes_all_7e.tsv +0 -0
  78. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/changetimes_flights_4e.tsv +0 -0
  79. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/data/predictors/flight_pop_x_4e_ls.tsv +0 -0
  80. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/eucovid/run_beast.py +0 -0
  81. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/platyrrhine/beast_config.xml +0 -0
  82. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/platyrrhine/data/change_times.csv +0 -0
  83. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/platyrrhine/data/traits.csv +0 -0
  84. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/platyrrhine/data/trees.nwk +0 -0
  85. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/platyrrhine/run_beast.py +0 -0
  86. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/epi-multitype/GLM.xml +0 -0
  87. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/epi-multitype/MLP.xml +0 -0
  88. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/epi-multitype/Nonparametric.xml +0 -0
  89. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/epi-skyline/GLM.xml +0 -0
  90. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/epi-skyline/MLP.xml +0 -0
  91. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/epi-skyline/Nonparametric.xml +0 -0
  92. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/fbd-2traits/GLM.xml +0 -0
  93. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/fbd-2traits/MLP.xml +0 -0
  94. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/fbd-2traits/Nonparametric.xml +0 -0
  95. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/fbd-no-traits/GLM.xml +0 -0
  96. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/fbd-no-traits/MLP.xml +0 -0
  97. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/beast_configs/fbd-no-traits/Nonparametric.xml +0 -0
  98. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/features.py +0 -0
  99. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/__init__.py +0 -0
  100. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/explain/__init__.py +0 -0
  101. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/explain/pdp.py +0 -0
  102. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/explain/shap.py +0 -0
  103. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/scenarios.py +0 -0
  104. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/figures/utils.py +0 -0
  105. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/generate_data.py +0 -0
  106. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/generate_figures.py +0 -0
  107. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/run_beast.py +0 -0
  108. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/scenarios/__init__.py +0 -0
  109. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/scenarios/common.py +0 -0
  110. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/scenarios/epi_multitype.py +0 -0
  111. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/scenarios/epi_skyline.py +0 -0
  112. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/scenarios/fbd_2traits.py +0 -0
  113. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/scenarios/fbd_no_traits.py +0 -0
  114. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/simulations/scenarios/scenario.py +0 -0
  115. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/utils/__init__.py +0 -0
  116. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/utils/beast.py +0 -0
  117. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/utils/explain.py +0 -0
  118. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/utils/slurm.py +0 -0
  119. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion/version.xml +0 -0
  120. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion.egg-info/dependency_links.txt +0 -0
  121. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion.egg-info/entry_points.txt +0 -0
  122. {bella_companion-0.0.44 → bella_companion-0.0.45}/bella_companion.egg-info/top_level.txt +0 -0
  123. {bella_companion-0.0.44 → bella_companion-0.0.45}/setup.cfg +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-companion
3
- Version: 0.0.44
3
+ Version: 0.0.45
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
7
7
  Requires-Dist: arviz>=0.22.0
8
8
  Requires-Dist: bella-lumiere>=0.0.14
9
9
  Requires-Dist: dotenv>=0.9.9
10
- Requires-Dist: phylogenie>=3.1.2
10
+ Requires-Dist: phylogenie>=3.1.3
11
11
  Requires-Dist: poetry>=2.2.1
12
12
  Requires-Dist: seaborn>=0.13.2
@@ -7,10 +7,10 @@ from dotenv import load_dotenv
7
7
  from bella_companion.eucovid import run_beast as run_eucovid_beast
8
8
  from bella_companion.platyrrhine import plot_platyrrhine_results
9
9
  from bella_companion.platyrrhine import run_beast as run_platyrrhine
10
- from bella_companion.platyrrhine import summarize_logs as summarize_platyrrhine
10
+ from bella_companion.platyrrhine import summarize as summarize_platyrrhine
11
11
  from bella_companion.simulations import generate_data, generate_figures, print_metrics
12
12
  from bella_companion.simulations import run_beast as run_simulations
13
- from bella_companion.simulations import summarize_logs as summarize_simulations
13
+ from bella_companion.simulations import summarize as summarize_simulations
14
14
 
15
15
 
16
16
  def main():
@@ -0,0 +1,5 @@
1
+ from bella_companion.platyrrhine.results import plot_platyrrhine_results
2
+ from bella_companion.platyrrhine.run_beast import run_beast
3
+ from bella_companion.platyrrhine.summarize import summarize
4
+
5
+ __all__ = ["plot_platyrrhine_results", "run_beast", "summarize"]
@@ -0,0 +1,109 @@
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import matplotlib.pyplot as plt
5
+ import numpy as np
6
+ import polars as pl
7
+ from numpy.typing import NDArray
8
+ from phylogenie import draw_tree, get_node_depths, load_newick, load_nexus
9
+
10
+
11
+ def _plot_tree(output_dir: Path, tree_file: str | Path):
12
+ sample_trees = load_nexus(tree_file)
13
+ trees = [sample_trees[f"STATE_{i*100_000}"] for i in range(11, 101)]
14
+
15
+ for tree in trees:
16
+ for node in tree:
17
+ if node.parent is not None and not node.branch_length:
18
+ node.parent.remove_child(node)
19
+
20
+ avg_tree = trees[0].copy()
21
+ for node in avg_tree:
22
+ node.clear()
23
+ for avg_node, nodes in zip(avg_tree, zip(*trees)):
24
+ avg_node.set("birthRateSP", np.mean([n["birthRateSP"] for n in nodes]))
25
+ avg_node.set("deathRateSP", np.mean([n["deathRateSP"] for n in nodes]))
26
+
27
+ avg_tree.ladderize()
28
+ for rate in ["birthRateSP", "deathRateSP"]:
29
+ ax = plt.gca()
30
+ draw_tree(
31
+ avg_tree,
32
+ ax,
33
+ color_by=rate,
34
+ hist_axes_kwargs={
35
+ "loc": "upper left",
36
+ "bbox_to_anchor": (0.06, 0, 1, 1),
37
+ "bbox_transform": ax.transAxes,
38
+ },
39
+ )
40
+ height = avg_tree.height
41
+ ticks = np.arange(height, 0, -10)
42
+ ax.set_xticks(ticks, [str(round(height - t)) for t in ticks]) # pyright: ignore
43
+ plt.xlabel("Time (mya)") # pyright: ignore
44
+ plt.savefig(output_dir / f"{rate}-tree.svg") # pyright: ignore
45
+ plt.close()
46
+
47
+
48
+ def _plot_predictions(output_dir: Path, log_summary_file: str | Path):
49
+ log_summary = pl.read_csv(log_summary_file)
50
+
51
+ data_dir = Path(__file__).parent / "data"
52
+ change_times = (
53
+ pl.read_csv(data_dir / "change_times.csv", has_header=False)
54
+ .to_series()
55
+ .to_list()
56
+ )
57
+ max_time = max(
58
+ max(get_node_depths(tree).values())
59
+ for tree in load_newick(data_dir / "trees.nwk")
60
+ )
61
+ time_bins = list(reversed([0.0, *change_times, max_time]))
62
+
63
+ gradient = np.linspace(0.4, 0.9, 4)
64
+ colors: dict[str, NDArray[np.floating]] = {
65
+ "birthRateSP": plt.cm.Blues(gradient), # pyright: ignore
66
+ "deathRateSP": plt.cm.Oranges(gradient), # pyright: ignore
67
+ "diversificationRateSP": plt.cm.Greens(gradient), # pyright: ignore
68
+ }
69
+ for rate in colors:
70
+ for type in [0, 1, 2, 3]:
71
+ if rate == "diversificationRateSP":
72
+ estimates = log_summary.select(
73
+ [
74
+ pl.col(f"birthRateSPi{i}_{type}_median")
75
+ - pl.col(f"deathRateSPi{i}_{type}_median")
76
+ for i in range(len(change_times) + 1)
77
+ ]
78
+ ).to_numpy()
79
+ else:
80
+ estimates = log_summary.select(
81
+ [
82
+ pl.col(f"{rate}i{i}_{type}_median")
83
+ for i in range(len(change_times) + 1)
84
+ ]
85
+ ).to_numpy()
86
+ median = np.median(estimates, axis=0)
87
+ color = colors[rate][type]
88
+ plt.step( # pyright: ignore
89
+ time_bins, [median[0], *median], color=color, label=type
90
+ )
91
+
92
+ plt.gca().invert_xaxis()
93
+ plt.legend(title="Body mass") # pyright: ignore
94
+ plt.xlabel("Time (mya)") # pyright: ignore
95
+ plt.ylabel( # pyright: ignore
96
+ r"$\lambda$"
97
+ if rate == "birthRateSP"
98
+ else r"$\mu$" if rate == "deathRateSP" else r"$d$"
99
+ )
100
+ plt.savefig(output_dir / f"{rate}-predictions.svg") # pyright: ignore
101
+ plt.close()
102
+
103
+
104
+ def plot_platyrrhine_results():
105
+ summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"]) / "platyrrhine"
106
+ output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "platyrrhine"
107
+ os.makedirs(output_dir, exist_ok=True)
108
+ _plot_predictions(output_dir, summaries_dir / "MLP.csv")
109
+ _plot_tree(output_dir, summaries_dir / "sample-trees.nexus")
@@ -5,13 +5,13 @@ from pathlib import Path
5
5
 
6
6
  import joblib
7
7
  import polars as pl
8
- from phylogenie import Tree, load_nexus
8
+ from phylogenie import Tree, dump_newick, load_nexus
9
9
  from tqdm import tqdm
10
10
 
11
11
  from bella_companion.utils import read_weights_dir, summarize_logs_dir
12
12
 
13
13
 
14
- def summarize_logs():
14
+ def summarize():
15
15
  data_dir = Path(__file__).parent / "data"
16
16
  change_times = pl.read_csv(data_dir / "change_times.csv", has_header=False)
17
17
  n_time_bins = len(change_times) + 1
@@ -28,14 +28,14 @@ def summarize_logs():
28
28
  )
29
29
  weights = read_weights_dir(logs_dir)
30
30
 
31
- summaries_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"], "platyrrhine")
31
+ summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"], "platyrrhine")
32
32
  os.makedirs(summaries_dir, exist_ok=True)
33
33
  summaries.write_csv(summaries_dir / "MLP.csv")
34
34
  joblib.dump(weights, summaries_dir / "MLP.weights.pkl")
35
35
 
36
36
  trees: list[Tree] = []
37
37
  for tree_file in tqdm(glob(str(logs_dir / "*.trees")), "Summarizing trees"):
38
- trees.extend(list(load_nexus(tree_file).values())[:-10])
39
- joblib.dump(trees, summaries_dir / "trees.pkl")
38
+ trees.extend(list(load_nexus(tree_file).values())[-10:])
39
+ dump_newick(trees, summaries_dir / "trees.nwk")
40
40
 
41
- shutil.copy(logs_dir / "0.trees", summaries_dir / "sample-tree.nexus")
41
+ shutil.copy(logs_dir / "0.trees", summaries_dir / "sample-trees.nexus")
@@ -2,12 +2,12 @@ from bella_companion.simulations.generate_data import generate_data
2
2
  from bella_companion.simulations.generate_figures import generate_figures
3
3
  from bella_companion.simulations.metrics import print_metrics
4
4
  from bella_companion.simulations.run_beast import run_beast
5
- from bella_companion.simulations.summarize_logs import summarize_logs
5
+ from bella_companion.simulations.summarize import summarize
6
6
 
7
7
  __all__ = [
8
8
  "generate_data",
9
9
  "generate_figures",
10
10
  "print_metrics",
11
11
  "run_beast",
12
- "summarize_logs",
12
+ "summarize",
13
13
  ]
@@ -58,10 +58,10 @@ def plot_epi_multitype_results():
58
58
  output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "epi-multitype"
59
59
  os.makedirs(output_dir, exist_ok=True)
60
60
 
61
- log_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"]) / "epi-multitype"
61
+ summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"]) / "epi-multitype"
62
62
  model = "MLP-32_16"
63
- log_summary = pl.read_csv(log_dir / f"{model}.csv")
64
- weights = joblib.load(log_dir / f"{model}.weights.pkl")
63
+ log_summary = pl.read_csv(summaries_dir / f"{model}.csv")
64
+ weights = joblib.load(summaries_dir / f"{model}.weights.pkl")
65
65
  weights = [w["migrationRate"] for w in weights]
66
66
 
67
67
  _plot_predictions(log_summary, output_dir)
@@ -17,7 +17,7 @@ def plot_epi_skyline_results():
17
17
  base_output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "epi-skyline"
18
18
 
19
19
  for i, reproduction_number in enumerate(REPRODUCTION_NUMBERS, start=1):
20
- summaries_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"]) / f"epi-skyline_{i}"
20
+ summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"]) / f"epi-skyline_{i}"
21
21
  logs_summaries = {
22
22
  "Nonparametric": pl.read_csv(summaries_dir / "Nonparametric.csv"),
23
23
  "GLM": pl.read_csv(summaries_dir / "GLM.csv"),
@@ -58,10 +58,10 @@ def _plot_predictions(log_summary: pl.DataFrame, output_dir: Path):
58
58
  def plot_fbd_2traits_results():
59
59
  output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "fbd-2traits"
60
60
 
61
- log_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"]) / "fbd-2traits"
61
+ summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"]) / "fbd-2traits"
62
62
  model = "MLP-32_16"
63
- log_summary = pl.read_csv(log_dir / f"{model}.csv")
64
- weights = joblib.load(log_dir / f"{model}.weights.pkl")
63
+ log_summary = pl.read_csv(summaries_dir / f"{model}.csv")
64
+ weights = joblib.load(summaries_dir / f"{model}.weights.pkl")
65
65
 
66
66
  for rate in RATES:
67
67
  os.makedirs(output_dir / rate, exist_ok=True)
@@ -17,9 +17,7 @@ def plot_fbd_no_traits_results():
17
17
  base_output = Path(os.environ["BELLA_FIGURES_DIR"]) / "fbd-no-traits"
18
18
 
19
19
  for i, rates in enumerate(RATES, start=1):
20
- summaries_dir = (
21
- Path(os.environ["BELLA_LOG_SUMMARIES_DIR"]) / f"fbd-no-traits_{i}"
22
- )
20
+ summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"]) / f"fbd-no-traits_{i}"
23
21
  logs_summaries = {
24
22
  "Nonparametric": pl.read_csv(summaries_dir / "Nonparametric.csv"),
25
23
  "GLM": pl.read_csv(summaries_dir / "GLM.csv"),
@@ -36,7 +36,7 @@ def _avg_ci_width(summary: pl.DataFrame, true_values: dict[str, float]) -> float
36
36
 
37
37
 
38
38
  def print_metrics():
39
- base_summaries_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"])
39
+ base_summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"])
40
40
  metrics = {}
41
41
  for name, scenario in SCENARIOS.items():
42
42
  summaries_dir = base_summaries_dir / name
@@ -8,13 +8,13 @@ from bella_companion.simulations.scenarios import SCENARIOS
8
8
  from bella_companion.utils import read_weights_dir, summarize_logs_dir
9
9
 
10
10
 
11
- def summarize_logs():
11
+ def summarize():
12
12
  output_dir = Path(os.environ["BELLA_BEAST_OUTPUT_DIR"])
13
13
  with open(output_dir / "simulations_job_ids.json", "r") as f:
14
14
  job_ids: dict[str, dict[str, dict[str, str]]] = json.load(f)
15
15
 
16
16
  for scenario_name, scenario in SCENARIOS.items():
17
- summaries_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"]) / scenario_name
17
+ summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"]) / scenario_name
18
18
  os.makedirs(summaries_dir, exist_ok=True)
19
19
  for model in job_ids[scenario_name]:
20
20
  logs_dir = output_dir / scenario_name / model
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-companion
3
- Version: 0.0.44
3
+ Version: 0.0.45
4
4
  Summary: Add your description here
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
7
7
  Requires-Dist: arviz>=0.22.0
8
8
  Requires-Dist: bella-lumiere>=0.0.14
9
9
  Requires-Dist: dotenv>=0.9.9
10
- Requires-Dist: phylogenie>=3.1.2
10
+ Requires-Dist: phylogenie>=3.1.3
11
11
  Requires-Dist: poetry>=2.2.1
12
12
  Requires-Dist: seaborn>=0.13.2
@@ -10,8 +10,12 @@ bella_companion.egg-info/dependency_links.txt
10
10
  bella_companion.egg-info/entry_points.txt
11
11
  bella_companion.egg-info/requires.txt
12
12
  bella_companion.egg-info/top_level.txt
13
+ bella_companion/__pycache__/__init__.cpython-310.pyc
14
+ bella_companion/__pycache__/cli.cpython-310.pyc
13
15
  bella_companion/eucovid/__init__.py
14
16
  bella_companion/eucovid/run_beast.py
17
+ bella_companion/eucovid/__pycache__/__init__.cpython-310.pyc
18
+ bella_companion/eucovid/__pycache__/run_beast.cpython-310.pyc
15
19
  bella_companion/eucovid/beast_configs/GLM.xml
16
20
  bella_companion/eucovid/beast_configs/MLP.xml
17
21
  bella_companion/eucovid/beast_configs/Nonparametric.xml
@@ -35,7 +39,12 @@ bella_companion/platyrrhine/__init__.py
35
39
  bella_companion/platyrrhine/beast_config.xml
36
40
  bella_companion/platyrrhine/results.py
37
41
  bella_companion/platyrrhine/run_beast.py
38
- bella_companion/platyrrhine/summarize_logs.py
42
+ bella_companion/platyrrhine/summarize.py
43
+ bella_companion/platyrrhine/__pycache__/__init__.cpython-310.pyc
44
+ bella_companion/platyrrhine/__pycache__/results.cpython-310.pyc
45
+ bella_companion/platyrrhine/__pycache__/run_beast.cpython-310.pyc
46
+ bella_companion/platyrrhine/__pycache__/summarize.cpython-310.pyc
47
+ bella_companion/platyrrhine/__pycache__/summarize_logs.cpython-310.pyc
39
48
  bella_companion/platyrrhine/data/change_times.csv
40
49
  bella_companion/platyrrhine/data/traits.csv
41
50
  bella_companion/platyrrhine/data/trees.nwk
@@ -45,7 +54,15 @@ bella_companion/simulations/generate_data.py
45
54
  bella_companion/simulations/generate_figures.py
46
55
  bella_companion/simulations/metrics.py
47
56
  bella_companion/simulations/run_beast.py
48
- bella_companion/simulations/summarize_logs.py
57
+ bella_companion/simulations/summarize.py
58
+ bella_companion/simulations/__pycache__/__init__.cpython-310.pyc
59
+ bella_companion/simulations/__pycache__/features.cpython-310.pyc
60
+ bella_companion/simulations/__pycache__/generate_data.cpython-310.pyc
61
+ bella_companion/simulations/__pycache__/generate_figures.cpython-310.pyc
62
+ bella_companion/simulations/__pycache__/metrics.cpython-310.pyc
63
+ bella_companion/simulations/__pycache__/run_beast.cpython-310.pyc
64
+ bella_companion/simulations/__pycache__/summarize.cpython-310.pyc
65
+ bella_companion/simulations/__pycache__/summarize_logs.cpython-310.pyc
49
66
  bella_companion/simulations/beast_configs/epi-multitype/GLM.xml
50
67
  bella_companion/simulations/beast_configs/epi-multitype/MLP.xml
51
68
  bella_companion/simulations/beast_configs/epi-multitype/Nonparametric.xml
@@ -65,9 +82,19 @@ bella_companion/simulations/figures/fbd_2traits.py
65
82
  bella_companion/simulations/figures/fbd_no_traits.py
66
83
  bella_companion/simulations/figures/scenarios.py
67
84
  bella_companion/simulations/figures/utils.py
85
+ bella_companion/simulations/figures/__pycache__/__init__.cpython-310.pyc
86
+ bella_companion/simulations/figures/__pycache__/epi_multitype.cpython-310.pyc
87
+ bella_companion/simulations/figures/__pycache__/epi_skyline.cpython-310.pyc
88
+ bella_companion/simulations/figures/__pycache__/fbd_2traits.cpython-310.pyc
89
+ bella_companion/simulations/figures/__pycache__/fbd_no_traits.cpython-310.pyc
90
+ bella_companion/simulations/figures/__pycache__/scenarios.cpython-310.pyc
91
+ bella_companion/simulations/figures/__pycache__/utils.cpython-310.pyc
68
92
  bella_companion/simulations/figures/explain/__init__.py
69
93
  bella_companion/simulations/figures/explain/pdp.py
70
94
  bella_companion/simulations/figures/explain/shap.py
95
+ bella_companion/simulations/figures/explain/__pycache__/__init__.cpython-310.pyc
96
+ bella_companion/simulations/figures/explain/__pycache__/pdp.cpython-310.pyc
97
+ bella_companion/simulations/figures/explain/__pycache__/shap.cpython-310.pyc
71
98
  bella_companion/simulations/scenarios/__init__.py
72
99
  bella_companion/simulations/scenarios/common.py
73
100
  bella_companion/simulations/scenarios/epi_multitype.py
@@ -75,7 +102,18 @@ bella_companion/simulations/scenarios/epi_skyline.py
75
102
  bella_companion/simulations/scenarios/fbd_2traits.py
76
103
  bella_companion/simulations/scenarios/fbd_no_traits.py
77
104
  bella_companion/simulations/scenarios/scenario.py
105
+ bella_companion/simulations/scenarios/__pycache__/__init__.cpython-310.pyc
106
+ bella_companion/simulations/scenarios/__pycache__/common.cpython-310.pyc
107
+ bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-310.pyc
108
+ bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-310.pyc
109
+ bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-310.pyc
110
+ bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-310.pyc
111
+ bella_companion/simulations/scenarios/__pycache__/scenario.cpython-310.pyc
78
112
  bella_companion/utils/__init__.py
79
113
  bella_companion/utils/beast.py
80
114
  bella_companion/utils/explain.py
81
- bella_companion/utils/slurm.py
115
+ bella_companion/utils/slurm.py
116
+ bella_companion/utils/__pycache__/__init__.cpython-310.pyc
117
+ bella_companion/utils/__pycache__/beast.cpython-310.pyc
118
+ bella_companion/utils/__pycache__/explain.cpython-310.pyc
119
+ bella_companion/utils/__pycache__/slurm.cpython-310.pyc
@@ -1,6 +1,6 @@
1
1
  arviz>=0.22.0
2
2
  bella-lumiere>=0.0.14
3
3
  dotenv>=0.9.9
4
- phylogenie>=3.1.2
4
+ phylogenie>=3.1.3
5
5
  poetry>=2.2.1
6
6
  seaborn>=0.13.2
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bella-companion"
3
- version = "0.0.44"
3
+ version = "0.0.45"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -8,7 +8,7 @@ dependencies = [
8
8
  "arviz>=0.22.0",
9
9
  "bella-lumiere>=0.0.14",
10
10
  "dotenv>=0.9.9",
11
- "phylogenie>=3.1.2",
11
+ "phylogenie>=3.1.3",
12
12
  "poetry>=2.2.1",
13
13
  "seaborn>=0.13.2",
14
14
  ]
@@ -1,5 +0,0 @@
1
- from bella_companion.platyrrhine.results import plot_platyrrhine_results
2
- from bella_companion.platyrrhine.run_beast import run_beast
3
- from bella_companion.platyrrhine.summarize_logs import summarize_logs
4
-
5
- __all__ = ["plot_platyrrhine_results", "run_beast", "summarize_logs"]
@@ -1,69 +0,0 @@
1
- import os
2
- from pathlib import Path
3
-
4
- import matplotlib.pyplot as plt
5
- import numpy as np
6
- import polars as pl
7
- from numpy.typing import NDArray
8
- from phylogenie import get_node_depths, load_newick
9
-
10
-
11
- def _plot_predictions(output_dir: Path):
12
- log_summaries_dir = Path(os.environ["BELLA_LOG_SUMMARIES_DIR"])
13
- log_summary = pl.read_csv(log_summaries_dir / "platyrrhine" / "MLP.csv")
14
-
15
- data_dir = Path(__file__).parent / "data"
16
- change_times = (
17
- pl.read_csv(data_dir / "change_times.csv", has_header=False)
18
- .to_series()
19
- .to_list()
20
- )
21
- max_time = max(
22
- max(get_node_depths(tree).values())
23
- for tree in load_newick(data_dir / "trees.nwk")
24
- )
25
- time_bins = list(reversed([0.0, *change_times, max_time]))
26
-
27
- colors: dict[str, NDArray[np.floating]] = {
28
- "birth": plt.cm.Blues(np.linspace(0.4, 0.9, 4)), # pyright: ignore
29
- "death": plt.cm.Oranges(np.linspace(0.4, 0.9, 4)), # pyright: ignore
30
- "diversification": plt.cm.Greens(np.linspace(0.4, 0.9, 4)), # pyright: ignore
31
- }
32
- for rate in ["birth", "death", "diversification"]:
33
- for type in [0, 1, 2, 3]:
34
- if rate == "diversification":
35
- estimates = log_summary.select(
36
- [
37
- pl.col(f"birthRateSPi{i}_{type}_median")
38
- - pl.col(f"deathRateSPi{i}_{type}_median")
39
- for i in range(len(change_times) + 1)
40
- ]
41
- ).to_numpy()
42
- else:
43
- estimates = log_summary.select(
44
- [
45
- pl.col(f"{rate}RateSPi{i}_{type}_median")
46
- for i in range(len(change_times) + 1)
47
- ]
48
- ).to_numpy()
49
- median = np.median(estimates, axis=0)
50
- color = colors[rate][type]
51
- plt.step( # pyright: ignore
52
- time_bins, [median[0], *median], color=color, label=type
53
- )
54
-
55
- ax = plt.gca()
56
- ax.invert_xaxis()
57
- plt.legend(title="Body mass") # pyright: ignore
58
- plt.xlabel("Time (mya)") # pyright: ignore
59
- plt.ylabel( # pyright: ignore
60
- r"$\lambda$" if rate == "birth" else r"$\mu$" if rate == "death" else r"$d$"
61
- )
62
- plt.savefig(output_dir / f"{rate}-predictions.svg") # pyright: ignore
63
- plt.close()
64
-
65
-
66
- def plot_platyrrhine_results():
67
- output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "platyrrhine"
68
- os.makedirs(output_dir, exist_ok=True)
69
- _plot_predictions(output_dir)