bella-companion 0.0.45__tar.gz → 0.0.47__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 (126) hide show
  1. {bella_companion-0.0.45 → bella_companion-0.0.47}/PKG-INFO +3 -3
  2. bella_companion-0.0.47/bella_companion/__pycache__/cli.cpython-310.pyc +0 -0
  3. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/cli.py +7 -2
  4. bella_companion-0.0.47/bella_companion/eucovid/run_beast.py +118 -0
  5. bella_companion-0.0.47/bella_companion/platyrrhine/__pycache__/results.cpython-310.pyc +0 -0
  6. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/__pycache__/run_beast.cpython-310.pyc +0 -0
  7. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/__pycache__/summarize.cpython-310.pyc +0 -0
  8. bella_companion-0.0.47/bella_companion/platyrrhine/results.py +191 -0
  9. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/run_beast.py +12 -11
  10. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/__pycache__/generate_data.cpython-310.pyc +0 -0
  11. bella_companion-0.0.47/bella_companion/simulations/__pycache__/generate_figures.cpython-310.pyc +0 -0
  12. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  13. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/__pycache__/epi_skyline.cpython-310.pyc +0 -0
  14. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  15. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/__pycache__/fbd_no_traits.cpython-310.pyc +0 -0
  16. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/__pycache__/scenarios.cpython-310.pyc +0 -0
  17. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/__pycache__/utils.cpython-310.pyc +0 -0
  18. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/explain/__pycache__/pdp.cpython-310.pyc +0 -0
  19. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/explain/__pycache__/shap.cpython-310.pyc +0 -0
  20. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/generate_figures.py +0 -9
  21. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/run_beast.py +5 -1
  22. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/utils/__pycache__/beast.cpython-310.pyc +0 -0
  23. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion.egg-info/PKG-INFO +3 -3
  24. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion.egg-info/requires.txt +1 -1
  25. {bella_companion-0.0.45 → bella_companion-0.0.47}/pyproject.toml +4 -3
  26. bella_companion-0.0.45/bella_companion/__pycache__/cli.cpython-310.pyc +0 -0
  27. bella_companion-0.0.45/bella_companion/eucovid/run_beast.py +0 -111
  28. bella_companion-0.0.45/bella_companion/platyrrhine/__pycache__/results.cpython-310.pyc +0 -0
  29. bella_companion-0.0.45/bella_companion/platyrrhine/results.py +0 -109
  30. bella_companion-0.0.45/bella_companion/simulations/__pycache__/generate_figures.cpython-310.pyc +0 -0
  31. {bella_companion-0.0.45 → bella_companion-0.0.47}/README.md +0 -0
  32. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/BELLA.jar +0 -0
  33. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/__init__.py +0 -0
  34. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/__pycache__/__init__.cpython-310.pyc +0 -0
  35. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/__init__.py +0 -0
  36. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/__pycache__/__init__.cpython-310.pyc +0 -0
  37. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/__pycache__/run_beast.cpython-310.pyc +0 -0
  38. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/beast_configs/GLM.xml +0 -0
  39. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/beast_configs/MLP.xml +0 -0
  40. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/beast_configs/Nonparametric.xml +0 -0
  41. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/case_data.tsv +0 -0
  42. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/change_dates.tsv +0 -0
  43. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/msa.fasta +0 -0
  44. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/osi.tsv +0 -0
  45. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/closedborders_7e_nt.tsv +0 -0
  46. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/dist_7e_ls.tsv +0 -0
  47. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/flight_7e_ls.tsv +0 -0
  48. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/flight_pop_x_7e_ls.tsv +0 -0
  49. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/osi_x_7e_ls.tsv +0 -0
  50. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/osi_y_7e_ls.tsv +0 -0
  51. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/pop_x_7e_ls.tsv +0 -0
  52. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/pop_y_7e_ls.tsv +0 -0
  53. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/all/sharedborders_7e_nt.tsv +0 -0
  54. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/changetimes_all_7e.tsv +0 -0
  55. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/changetimes_flights_4e.tsv +0 -0
  56. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/eucovid/data/predictors/flight_pop_x_4e_ls.tsv +0 -0
  57. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/__init__.py +0 -0
  58. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/__pycache__/__init__.cpython-310.pyc +0 -0
  59. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/__pycache__/summarize_logs.cpython-310.pyc +0 -0
  60. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/beast_config.xml +0 -0
  61. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/data/change_times.csv +0 -0
  62. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/data/traits.csv +0 -0
  63. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/data/trees.nwk +0 -0
  64. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/platyrrhine/summarize.py +0 -0
  65. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/__init__.py +0 -0
  66. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/__pycache__/__init__.cpython-310.pyc +0 -0
  67. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/__pycache__/features.cpython-310.pyc +0 -0
  68. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/__pycache__/metrics.cpython-310.pyc +0 -0
  69. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/__pycache__/run_beast.cpython-310.pyc +0 -0
  70. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/__pycache__/summarize.cpython-310.pyc +0 -0
  71. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/__pycache__/summarize_logs.cpython-310.pyc +0 -0
  72. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/epi-multitype/GLM.xml +0 -0
  73. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/epi-multitype/MLP.xml +0 -0
  74. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/epi-multitype/Nonparametric.xml +0 -0
  75. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/epi-skyline/GLM.xml +0 -0
  76. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/epi-skyline/MLP.xml +0 -0
  77. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/epi-skyline/Nonparametric.xml +0 -0
  78. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/fbd-2traits/GLM.xml +0 -0
  79. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/fbd-2traits/MLP.xml +0 -0
  80. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/fbd-2traits/Nonparametric.xml +0 -0
  81. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/fbd-no-traits/GLM.xml +0 -0
  82. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/fbd-no-traits/MLP.xml +0 -0
  83. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/beast_configs/fbd-no-traits/Nonparametric.xml +0 -0
  84. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/features.py +0 -0
  85. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/__init__.py +0 -0
  86. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/__pycache__/__init__.cpython-310.pyc +0 -0
  87. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/epi_multitype.py +0 -0
  88. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/epi_skyline.py +0 -0
  89. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/explain/__init__.py +0 -0
  90. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/explain/__pycache__/__init__.cpython-310.pyc +0 -0
  91. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/explain/pdp.py +0 -0
  92. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/explain/shap.py +0 -0
  93. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/fbd_2traits.py +0 -0
  94. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/fbd_no_traits.py +0 -0
  95. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/scenarios.py +0 -0
  96. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/figures/utils.py +0 -0
  97. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/generate_data.py +0 -0
  98. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/metrics.py +0 -0
  99. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/__init__.py +0 -0
  100. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/__pycache__/__init__.cpython-310.pyc +0 -0
  101. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/__pycache__/common.cpython-310.pyc +0 -0
  102. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  103. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-310.pyc +0 -0
  104. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  105. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-310.pyc +0 -0
  106. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/__pycache__/scenario.cpython-310.pyc +0 -0
  107. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/common.py +0 -0
  108. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/epi_multitype.py +0 -0
  109. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/epi_skyline.py +0 -0
  110. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/fbd_2traits.py +0 -0
  111. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/fbd_no_traits.py +0 -0
  112. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/scenarios/scenario.py +0 -0
  113. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/simulations/summarize.py +0 -0
  114. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/utils/__init__.py +0 -0
  115. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  116. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/utils/__pycache__/explain.cpython-310.pyc +0 -0
  117. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/utils/__pycache__/slurm.cpython-310.pyc +0 -0
  118. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/utils/beast.py +0 -0
  119. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/utils/explain.py +0 -0
  120. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/utils/slurm.py +0 -0
  121. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion/version.xml +0 -0
  122. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion.egg-info/SOURCES.txt +0 -0
  123. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion.egg-info/dependency_links.txt +0 -0
  124. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion.egg-info/entry_points.txt +0 -0
  125. {bella_companion-0.0.45 → bella_companion-0.0.47}/bella_companion.egg-info/top_level.txt +0 -0
  126. {bella_companion-0.0.45 → bella_companion-0.0.47}/setup.cfg +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-companion
3
- Version: 0.0.45
4
- Summary: Add your description here
3
+ Version: 0.0.47
4
+ Summary: Bayesian Evolutionary Layered Learning Architectures (BELLA) companion
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.3
10
+ Requires-Dist: phylogenie>=3.1.4
11
11
  Requires-Dist: poetry>=2.2.1
12
12
  Requires-Dist: seaborn>=0.13.2
@@ -2,6 +2,7 @@ import argparse
2
2
  import os
3
3
  from pathlib import Path
4
4
 
5
+ import matplotlib.pyplot as plt
5
6
  from dotenv import load_dotenv
6
7
 
7
8
  from bella_companion.eucovid import run_beast as run_eucovid_beast
@@ -21,12 +22,16 @@ def main():
21
22
  os.getenv("JAVA_OPTIONS", ""),
22
23
  f"-jar {Path(__file__).parent / 'BELLA.jar'}",
23
24
  f"-version_file {Path(__file__).parent / 'version.xml'}",
24
- "-seed 42",
25
25
  "-overwrite",
26
26
  "-statefile /tmp/state",
27
- "-DFout /dev/null",
28
27
  ]
29
28
  )
29
+ plt.rcParams["pdf.fonttype"] = 42
30
+ plt.rcParams["xtick.labelsize"] = 14
31
+ plt.rcParams["ytick.labelsize"] = 14
32
+ plt.rcParams["font.size"] = 14
33
+ plt.rcParams["figure.constrained_layout.use"] = True
34
+ plt.rcParams["lines.linewidth"] = 3
30
35
 
31
36
  parser = argparse.ArgumentParser(
32
37
  prog="bella",
@@ -0,0 +1,118 @@
1
+ import os
2
+ from glob import glob
3
+ from pathlib import Path
4
+
5
+ from bella_companion.utils import submit_job
6
+
7
+
8
+ def run_beast():
9
+ base_output_dir = Path(os.environ["BELLA_BEAST_OUTPUT_DIR"])
10
+ output_dir = base_output_dir / "eucovid"
11
+ os.makedirs(output_dir, exist_ok=True)
12
+
13
+ base_log_dir = Path(os.environ["BELLA_SBATCH_LOG_DIR"]) / "eucovid"
14
+
15
+ data_dir = Path(__file__).parent / "data"
16
+ beast_configs_dir = Path(__file__).parent / "beast_configs"
17
+ msa_file = data_dir / "msa.fasta"
18
+
19
+ predictors_dir = data_dir / "predictors"
20
+ all_predictor_files = ",".join(glob(str(predictors_dir / "all" / "*.tsv")))
21
+ all_predictors_data = " ".join(
22
+ [
23
+ f"-D msa_file={msa_file}",
24
+ f"-D changeTimesFile={predictors_dir / 'changetimes_all_7e.tsv'}",
25
+ f"-D predictorFiles={all_predictor_files}",
26
+ ]
27
+ )
28
+ flight_predictor_data = " ".join(
29
+ [
30
+ f"-D msa_file={msa_file}",
31
+ f"-D changeTimesFile={predictors_dir / 'changetimes_flights_4e.tsv'}",
32
+ f"-D predictorFiles={predictors_dir / 'flight_pop_x_4e_ls.tsv'}",
33
+ ]
34
+ )
35
+
36
+ for seed in range(1, 3):
37
+ run_beast_cmd = [os.environ["BELLA_RUN_BEAST_CMD"], f"-seed {42 + seed}"]
38
+
39
+ """
40
+ os.makedirs(output_dir / "Nonparametric", exist_ok=True)
41
+ submit_job(
42
+ " ".join(
43
+ [
44
+ *run_beast_cmd,
45
+ f"-D aligned_fasta={msa_file}",
46
+ f"-prefix {output_dir / 'Nonparametric'}{os.sep}{seed}-",
47
+ str(beast_configs_dir / "Nonparametric.xml"),
48
+ ]
49
+ ),
50
+ base_log_dir / "Nonparametric" / str(seed),
51
+ cpus=128,
52
+ mem_per_cpu=12000,
53
+ )
54
+ """
55
+
56
+ os.makedirs(output_dir / "all-predictors-GLM", exist_ok=True)
57
+ submit_job(
58
+ " ".join(
59
+ [
60
+ *run_beast_cmd,
61
+ all_predictors_data,
62
+ f"-prefix {output_dir / 'all-predictors-GLM'}{os.sep}{seed}-",
63
+ str(beast_configs_dir / "GLM.xml"),
64
+ ]
65
+ ),
66
+ base_log_dir / "all-predictors-GLM" / str(seed),
67
+ cpus=128,
68
+ mem_per_cpu=12000,
69
+ )
70
+ """
71
+ os.makedirs(output_dir / "flights-GLM", exist_ok=True)
72
+ submit_job(
73
+ " ".join(
74
+ [
75
+ *run_beast_cmd,
76
+ flight_predictor_data,
77
+ f"-prefix {output_dir / 'flights-GLM'}{os.sep}{seed}-",
78
+ str(beast_configs_dir / "GLM.xml"),
79
+ ]
80
+ ),
81
+ base_log_dir / "flights-GLM" / str(seed),
82
+ cpus=128,
83
+ mem_per_cpu=12000,
84
+ )
85
+ """
86
+
87
+ os.makedirs(output_dir / "all-predictors-MLP", exist_ok=True)
88
+ submit_job(
89
+ " ".join(
90
+ [
91
+ *run_beast_cmd,
92
+ '-D layersRange="0,1,2",nodes="16 8"',
93
+ all_predictors_data,
94
+ f"-prefix {output_dir / 'all-predictors-MLP'}{os.sep}{seed}-",
95
+ str(beast_configs_dir / "MLP.xml"),
96
+ ]
97
+ ),
98
+ base_log_dir / "all-predictors-MLP" / str(seed),
99
+ cpus=128,
100
+ mem_per_cpu=12000,
101
+ )
102
+ """
103
+ os.makedirs(output_dir / "flights-MLP", exist_ok=True)
104
+ submit_job(
105
+ " ".join(
106
+ [
107
+ *run_beast_cmd,
108
+ '-D layersRange="0,1,2",nodes="16 8"',
109
+ flight_predictor_data,
110
+ f"-prefix {output_dir / 'flights-MLP'}{os.sep}{seed}-",
111
+ str(beast_configs_dir / "MLP.xml"),
112
+ ]
113
+ ),
114
+ base_log_dir / "flights-MLP" / str(seed),
115
+ cpus=128,
116
+ mem_per_cpu=12000,
117
+ )
118
+ """
@@ -0,0 +1,191 @@
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 matplotlib.colors import LinearSegmentedColormap, ListedColormap
8
+ from numpy.typing import NDArray
9
+ from phylogenie import draw_tree, get_node_depths, load_newick, load_nexus
10
+
11
+ DATA_DIR = Path(__file__).parent / "data"
12
+ CHANGE_TIMES = (
13
+ pl.read_csv(DATA_DIR / "change_times.csv", has_header=False).to_series().to_list()
14
+ )
15
+
16
+
17
+ def _plot_marginal_rates(output_dir: Path, trees_file: str | Path):
18
+ trees = load_newick(trees_file)
19
+ all_node_depths = [get_node_depths(tree) for tree in trees]
20
+ max_time = max(max(node_depths.values()) for node_depths in all_node_depths)
21
+ time_bins = np.array(list(reversed([0.0, *CHANGE_TIMES, max_time])))
22
+ for tree in trees:
23
+ for node in tree:
24
+ node["diversificationRateSP"] = node["birthRateSP"] - node["deathRateSP"]
25
+
26
+ for i, rate in enumerate(["birthRateSP", "deathRateSP", "diversificationRateSP"]):
27
+ marginal_rates: list[list[float]] = [[] for _ in range(len(CHANGE_TIMES) + 1)]
28
+ for tree, node_depths in zip(trees, all_node_depths):
29
+ root_age = tree.height
30
+ for node in tree:
31
+ if node.parent is None:
32
+ marginal_rates[0].append(node[rate])
33
+ continue
34
+ parent_age = root_age - node_depths[node.parent] # pyright: ignore
35
+ node_age = root_age - node_depths[node]
36
+ t1 = np.where(time_bins >= parent_age)[0][-1]
37
+ t2 = np.where(time_bins > node_age)[0][-1]
38
+ for t in range(t1, t2 + 1):
39
+ marginal_rates[t].append(node[rate])
40
+
41
+ median = [float(np.median(rates)) for rates in marginal_rates]
42
+ lower = [float(np.percentile(rates, 2.5)) for rates in marginal_rates]
43
+ upper = [float(np.percentile(rates, 97.5)) for rates in marginal_rates]
44
+ plt.step( # pyright: ignore
45
+ time_bins, [median[0], *median], color=f"C{i}", label=type
46
+ )
47
+ plt.fill_between( # pyright: ignore
48
+ time_bins,
49
+ [lower[0], *lower],
50
+ [upper[0], *upper],
51
+ color=f"C{i}",
52
+ alpha=0.2,
53
+ step="pre",
54
+ )
55
+
56
+ plt.gca().invert_xaxis()
57
+ plt.xlabel("Time (mya)") # pyright: ignore
58
+ plt.ylabel( # pyright: ignore
59
+ r"$\lambda$"
60
+ if rate == "birthRateSP"
61
+ else r"$\mu$"
62
+ if rate == "deathRateSP"
63
+ else r"$d$"
64
+ )
65
+ plt.savefig(output_dir / f"marginal-{rate}.svg") # pyright: ignore
66
+ plt.close()
67
+
68
+
69
+ def _plot_tree(output_dir: Path, tree_file: str | Path):
70
+ sample_trees = load_nexus(tree_file)
71
+ trees = [sample_trees[f"STATE_{i * 100_000}"] for i in range(11, 101)]
72
+
73
+ for tree in trees:
74
+ for node in tree:
75
+ if node.parent is not None and not node.branch_length:
76
+ node.parent.remove_child(node)
77
+
78
+ avg_tree = trees[0].copy()
79
+ for node in avg_tree:
80
+ node.clear()
81
+ for avg_node, nodes in zip(avg_tree, zip(*trees)):
82
+ avg_node["birthRateSP"] = np.mean([n["birthRateSP"] for n in nodes])
83
+ avg_node["deathRateSP"] = np.mean([n["deathRateSP"] for n in nodes])
84
+ avg_node["diversificationRateSP"] = (
85
+ avg_node["birthRateSP"] - avg_node["deathRateSP"]
86
+ )
87
+ avg_node["type"] = int(np.median([int(n["type"]) for n in nodes]))
88
+
89
+ avg_tree.ladderize()
90
+ cmaps: dict[str, LinearSegmentedColormap] = {
91
+ "birthRateSP": plt.cm.Blues, # pyright: ignore
92
+ "deathRateSP": plt.cm.Oranges, # pyright: ignore
93
+ "diversificationRateSP": plt.cm.Greens, # pyright: ignore
94
+ "type": plt.cm.Purples, # pyright: ignore
95
+ }
96
+ for color_by, cm in cmaps.items():
97
+ ax = plt.gca()
98
+ if color_by == "type":
99
+ cmap = ListedColormap(cm(np.linspace(0.3, 1, 4))) # pyright: ignore
100
+ draw_tree(
101
+ avg_tree,
102
+ ax,
103
+ color_by=color_by,
104
+ legend_kwargs={"title": "Body mass", "loc": "upper left"},
105
+ colormap=cmap,
106
+ )
107
+ else:
108
+ cmap = LinearSegmentedColormap.from_list(
109
+ "cmap",
110
+ cm(np.linspace(0.2, 1, 256)), # pyright: ignore
111
+ )
112
+ draw_tree(
113
+ avg_tree,
114
+ ax,
115
+ color_by=color_by,
116
+ hist_axes_kwargs={
117
+ "loc": "upper left",
118
+ "bbox_to_anchor": (0.06, 0, 1, 1),
119
+ "bbox_transform": ax.transAxes,
120
+ },
121
+ colormap=cmap,
122
+ )
123
+ height = avg_tree.height
124
+ ticks = np.arange(height, 0, -10)
125
+ ax.set_xticks(ticks, [str(round(height - t)) for t in ticks]) # pyright: ignore
126
+ ax.set_xlabel("Time (mya)") # pyright: ignore
127
+ plt.savefig(output_dir / f"{color_by}-tree.svg") # pyright: ignore
128
+ plt.close()
129
+
130
+
131
+ def _plot_predictions(output_dir: Path, log_summary_file: str | Path):
132
+ log_summary = pl.read_csv(log_summary_file)
133
+
134
+ max_time = max(
135
+ max(get_node_depths(tree).values())
136
+ for tree in load_newick(DATA_DIR / "trees.nwk")
137
+ )
138
+ time_bins = list(reversed([0.0, *CHANGE_TIMES, max_time]))
139
+
140
+ gradient = np.linspace(0.4, 0.9, 4)
141
+ colors: dict[str, NDArray[np.floating]] = {
142
+ "birthRateSP": plt.cm.Blues(gradient), # pyright: ignore
143
+ "deathRateSP": plt.cm.Oranges(gradient), # pyright: ignore
144
+ "diversificationRateSP": plt.cm.Greens(gradient), # pyright: ignore
145
+ }
146
+ for rate in colors:
147
+ for type in [0, 1, 2, 3]:
148
+ if rate == "diversificationRateSP":
149
+ estimates = log_summary.select(
150
+ [
151
+ pl.col(f"birthRateSPi{i}_{type}_median")
152
+ - pl.col(f"deathRateSPi{i}_{type}_median")
153
+ for i in range(len(CHANGE_TIMES) + 1)
154
+ ]
155
+ ).to_numpy()
156
+ else:
157
+ estimates = log_summary.select(
158
+ [
159
+ pl.col(f"{rate}i{i}_{type}_median")
160
+ for i in range(len(CHANGE_TIMES) + 1)
161
+ ]
162
+ ).to_numpy()
163
+ median = np.median(estimates, axis=0)
164
+ color = colors[rate][type]
165
+ plt.step( # pyright: ignore
166
+ time_bins, [median[0], *median], color=color, label=type
167
+ )
168
+
169
+ plt.gca().invert_xaxis()
170
+ plt.legend(title="Body mass") # pyright: ignore
171
+ plt.xlabel("Time (mya)") # pyright: ignore
172
+ plt.ylabel( # pyright: ignore
173
+ r"$\lambda$"
174
+ if rate == "birthRateSP"
175
+ else r"$\mu$"
176
+ if rate == "deathRateSP"
177
+ else r"$d$"
178
+ )
179
+ if rate in ["birthRateSP", "deathRateSP"]:
180
+ plt.ylim(0, 0.4) # pyright: ignore
181
+ plt.savefig(output_dir / f"{rate}-predictions.svg") # pyright: ignore
182
+ plt.close()
183
+
184
+
185
+ def plot_platyrrhine_results():
186
+ summaries_dir = Path(os.environ["BELLA_SUMMARIES_DIR"]) / "platyrrhine"
187
+ output_dir = Path(os.environ["BELLA_FIGURES_DIR"]) / "platyrrhine"
188
+ os.makedirs(output_dir, exist_ok=True)
189
+ _plot_predictions(output_dir, summaries_dir / "MLP.csv")
190
+ _plot_tree(output_dir, summaries_dir / "sample-trees.nexus")
191
+ _plot_marginal_rates(output_dir, summaries_dir / "trees.nwk")
@@ -39,22 +39,23 @@ def run_beast():
39
39
  command = " ".join(
40
40
  [
41
41
  os.environ["BELLA_RUN_BEAST_CMD"],
42
+ "-seed 42",
42
43
  f'-D types="{",".join(types)}"',
43
- f'-D startTypePriorProbs="0.25 0.25 0.25 0.25"',
44
- f"-D birthRateUpper=5",
45
- f"-D deathRateUpper=5",
46
- f'-D samplingChangeTimes="2.58 5.333 23.03"',
47
- f"-D samplingRateUpper=5",
48
- f'-D samplingRateInit="2.5 2.5 2.5 2.5"',
49
- f"-D migrationRateUpper=5",
50
- f'-D migrationRateInit="2.5 0 0 2.5 2.5 0 0 2.5 2.5 0 0 2.5"',
51
- f'-D nodes="16 8"',
52
- f'-D layersRange="0,1,2"',
44
+ '-D startTypePriorProbs="0.25 0.25 0.25 0.25"',
45
+ "-D birthRateUpper=5",
46
+ "-D deathRateUpper=5",
47
+ '-D samplingChangeTimes="2.58 5.333 23.03"',
48
+ "-D samplingRateUpper=5",
49
+ '-D samplingRateInit="2.5 2.5 2.5 2.5"',
50
+ "-D migrationRateUpper=5",
51
+ '-D migrationRateInit="2.5 0 0 2.5 2.5 0 0 2.5 2.5 0 0 2.5"',
52
+ '-D nodes="16 8"',
53
+ '-D layersRange="0,1,2"',
53
54
  f"-D treeFile={tree_file}",
54
55
  f"-D treeIndex={i}",
55
56
  f"-D changeTimesFile={change_times_file}",
56
57
  f"-D traitsFile={traits_file}",
57
- f"-D traitValueCol=3",
58
+ "-D traitValueCol=3",
58
59
  f"-D processLength={process_length}",
59
60
  f'-D timePredictor="{time_predictor}"',
60
61
  f'-D log10BMPredictor="{log10BM_predictor}"',
@@ -1,5 +1,3 @@
1
- import matplotlib.pyplot as plt
2
-
3
1
  from bella_companion.simulations.figures import (
4
2
  plot_epi_multitype_results,
5
3
  plot_epi_skyline_results,
@@ -10,13 +8,6 @@ from bella_companion.simulations.figures import (
10
8
 
11
9
 
12
10
  def generate_figures():
13
- plt.rcParams["pdf.fonttype"] = 42
14
- plt.rcParams["xtick.labelsize"] = 14
15
- plt.rcParams["ytick.labelsize"] = 14
16
- plt.rcParams["font.size"] = 14
17
- plt.rcParams["figure.constrained_layout.use"] = True
18
- plt.rcParams["lines.linewidth"] = 3
19
-
20
11
  plot_scenarios()
21
12
  plot_epi_skyline_results()
22
13
  plot_epi_multitype_results()
@@ -56,7 +56,11 @@ def run_beast():
56
56
  f"-D lastSampleTime={max(get_node_depths(tree).values())}"
57
57
  )
58
58
 
59
- base_command = [os.environ["BELLA_RUN_BEAST_CMD"], *beast_args]
59
+ base_command = [
60
+ os.environ["BELLA_RUN_BEAST_CMD"],
61
+ "-seed 42",
62
+ *beast_args,
63
+ ]
60
64
  if model in ["Nonparametric", "GLM"]:
61
65
  command = " ".join(
62
66
  [*base_command, str(inference_configs_dir / f"{model}.xml")]
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bella-companion
3
- Version: 0.0.45
4
- Summary: Add your description here
3
+ Version: 0.0.47
4
+ Summary: Bayesian Evolutionary Layered Learning Architectures (BELLA) companion
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.3
10
+ Requires-Dist: phylogenie>=3.1.4
11
11
  Requires-Dist: poetry>=2.2.1
12
12
  Requires-Dist: seaborn>=0.13.2
@@ -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.3
4
+ phylogenie>=3.1.4
5
5
  poetry>=2.2.1
6
6
  seaborn>=0.13.2
@@ -1,14 +1,14 @@
1
1
  [project]
2
2
  name = "bella-companion"
3
- version = "0.0.45"
4
- description = "Add your description here"
3
+ version = "0.0.47"
4
+ description = "Bayesian Evolutionary Layered Learning Architectures (BELLA) companion"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
7
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.3",
11
+ "phylogenie>=3.1.4",
12
12
  "poetry>=2.2.1",
13
13
  "seaborn>=0.13.2",
14
14
  ]
@@ -16,6 +16,7 @@ dependencies = [
16
16
  [dependency-groups]
17
17
  dev = [
18
18
  "joblib-stubs>=1.5.2.0.20250831",
19
+ "pyright>=1.1.407",
19
20
  ]
20
21
 
21
22
  [tool.pyright]
@@ -1,111 +0,0 @@
1
- import os
2
- from glob import glob
3
- from pathlib import Path
4
-
5
- from bella_companion.utils import submit_job
6
-
7
-
8
- def run_beast():
9
- base_output_dir = Path(os.environ["BELLA_BEAST_OUTPUT_DIR"])
10
- output_dir = base_output_dir / "eucovid"
11
- os.makedirs(output_dir, exist_ok=True)
12
-
13
- base_log_dir = Path(os.environ["BELLA_SBATCH_LOG_DIR"]) / "eucovid"
14
-
15
- data_dir = Path(__file__).parent / "data"
16
- beast_configs_dir = Path(__file__).parent / "beast_configs"
17
- msa_file = data_dir / "msa.fasta"
18
-
19
- predictors_dir = data_dir / "predictors"
20
- all_predictor_files = ",".join(glob(str(predictors_dir / "all" / "*.tsv")))
21
- all_predictors_data = " ".join(
22
- [
23
- f"-D msa_file={msa_file}",
24
- f"-D changeTimesFile={predictors_dir / 'changetimes_all_7e.tsv'}",
25
- f"-D predictorFiles={all_predictor_files}",
26
- ]
27
- )
28
- flight_predictor_data = " ".join(
29
- [
30
- f"-D msa_file={msa_file}",
31
- f"-D changeTimesFile={predictors_dir / 'changetimes_flights_4e.tsv'}",
32
- f"-D predictorFiles={predictors_dir / 'flight_pop_x_4e_ls.tsv'}",
33
- ]
34
- )
35
-
36
- os.makedirs(output_dir / "Nonparametric", exist_ok=True)
37
- submit_job(
38
- " ".join(
39
- [
40
- os.environ["BELLA_RUN_BEAST_CMD"],
41
- f"-D aligned_fasta={msa_file}",
42
- f"-prefix {output_dir / 'Nonparametric'}{os.sep}",
43
- str(beast_configs_dir / "Nonparametric.xml"),
44
- ]
45
- ),
46
- base_log_dir / "Nonparametric",
47
- cpus=128,
48
- mem_per_cpu=12000,
49
- )
50
-
51
- os.makedirs(output_dir / "all-predictors-GLM", exist_ok=True)
52
- submit_job(
53
- " ".join(
54
- [
55
- os.environ["BELLA_RUN_BEAST_CMD"],
56
- all_predictors_data,
57
- f"-prefix {output_dir / 'all-predictors-GLM'}{os.sep}",
58
- str(beast_configs_dir / "GLM.xml"),
59
- ]
60
- ),
61
- base_log_dir / "all-predictors-GLM",
62
- cpus=128,
63
- mem_per_cpu=12000,
64
- )
65
-
66
- os.makedirs(output_dir / "flights-GLM", exist_ok=True)
67
- submit_job(
68
- " ".join(
69
- [
70
- os.environ["BELLA_RUN_BEAST_CMD"],
71
- flight_predictor_data,
72
- f"-prefix {output_dir / 'flights-GLM'}{os.sep}",
73
- str(beast_configs_dir / "GLM.xml"),
74
- ]
75
- ),
76
- base_log_dir / "flights-GLM",
77
- cpus=128,
78
- mem_per_cpu=12000,
79
- )
80
-
81
- os.makedirs(output_dir / "all-predictors-MLP", exist_ok=True)
82
- submit_job(
83
- " ".join(
84
- [
85
- os.environ["BELLA_RUN_BEAST_CMD"],
86
- f'-D layersRange="0,1,2",nodes="16 8"',
87
- all_predictors_data,
88
- f"-prefix {output_dir / 'all-predictors-MLP'}{os.sep}",
89
- str(beast_configs_dir / "MLP.xml"),
90
- ]
91
- ),
92
- base_log_dir / "all-predictors-MLP",
93
- cpus=128,
94
- mem_per_cpu=12000,
95
- )
96
-
97
- os.makedirs(output_dir / "flights-MLP", exist_ok=True)
98
- submit_job(
99
- " ".join(
100
- [
101
- os.environ["BELLA_RUN_BEAST_CMD"],
102
- f'-D layersRange="0,1,2",nodes="16 8"',
103
- flight_predictor_data,
104
- f"-prefix {output_dir / 'flights-MLP'}{os.sep}",
105
- str(beast_configs_dir / "MLP.xml"),
106
- ]
107
- ),
108
- base_log_dir / "flights-MLP",
109
- cpus=128,
110
- mem_per_cpu=12000,
111
- )
@@ -1,109 +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 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")