bella-companion 0.0.6__tar.gz → 0.0.7__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 (80) hide show
  1. {bella_companion-0.0.6 → bella_companion-0.0.7}/PKG-INFO +1 -1
  2. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/cli.py +9 -7
  3. bella_companion-0.0.7/bella_companion/fbd_empirical/__init__.py +3 -0
  4. bella_companion-0.0.7/bella_companion/fbd_empirical/run_beast.py +68 -0
  5. {bella_companion-0.0.6 → bella_companion-0.0.7}/pyproject.toml +1 -1
  6. bella_companion-0.0.6/bella_companion/fbd_empirical/params.json +0 -11
  7. bella_companion-0.0.6/bella_companion/fbd_empirical/run_beast.py +0 -54
  8. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/__init__.py +0 -0
  9. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/__pycache__/run_beast.cpython-311.pyc +0 -0
  10. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/__pycache__/run_mlp.cpython-311.pyc +0 -0
  11. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/__pycache__/run_nonparametric.cpython-311.pyc +0 -0
  12. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/__pycache__/summarize_logs.cpython-311.pyc +0 -0
  13. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/data/body_mass.csv +0 -0
  14. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/data/change_times.csv +0 -0
  15. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/data/sampling_change_times.csv +0 -0
  16. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/data/trees.nwk +0 -0
  17. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/figure.py +0 -0
  18. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/notbooks.ipynb +0 -0
  19. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/fbd_empirical/summarize_logs.py +0 -0
  20. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__init__.py +0 -0
  21. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__pycache__/__init__.cpython-310.pyc +0 -0
  22. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__pycache__/__init__.cpython-311.pyc +0 -0
  23. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__pycache__/features.cpython-310.pyc +0 -0
  24. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__pycache__/features.cpython-311.pyc +0 -0
  25. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__pycache__/generate_data.cpython-310.pyc +0 -0
  26. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__pycache__/generate_data.cpython-311.pyc +0 -0
  27. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__pycache__/run_beast.cpython-311.pyc +0 -0
  28. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/__pycache__/summarize_logs.cpython-311.pyc +0 -0
  29. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/features.py +0 -0
  30. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__init__.py +0 -0
  31. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/__init__.cpython-311.pyc +0 -0
  32. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/epi_explainations.cpython-311.pyc +0 -0
  33. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/epi_predictions.cpython-311.pyc +0 -0
  34. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/epi_simulations.cpython-311.pyc +0 -0
  35. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/fbd_explainations.cpython-311.pyc +0 -0
  36. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/fbd_predictions.cpython-311.pyc +0 -0
  37. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/fbd_simulations.cpython-311.pyc +0 -0
  38. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/figure1.cpython-311.pyc +0 -0
  39. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/plot.cpython-311.pyc +0 -0
  40. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/scenarios.cpython-311.pyc +0 -0
  41. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/__pycache__/utils.cpython-311.pyc +0 -0
  42. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/epi_multitype_results.py +0 -0
  43. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/epi_skyline_results.py +0 -0
  44. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/explain/__init__.py +0 -0
  45. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/explain/pdp.py +0 -0
  46. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/explain/shap.py +0 -0
  47. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/fbd_2traits_results.py +0 -0
  48. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/fbd_no_traits_results.py +0 -0
  49. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/figures/scenarios.py +0 -0
  50. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/generate_data.py +0 -0
  51. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/generate_figures.py +0 -0
  52. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/run_beast.py +0 -0
  53. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__init__.py +0 -0
  54. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/__init__.cpython-310.pyc +0 -0
  55. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/__init__.cpython-311.pyc +0 -0
  56. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/common.cpython-310.pyc +0 -0
  57. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/common.cpython-311.pyc +0 -0
  58. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-310.pyc +0 -0
  59. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/epi_multitype.cpython-311.pyc +0 -0
  60. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-310.pyc +0 -0
  61. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/epi_skyline.cpython-311.pyc +0 -0
  62. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-310.pyc +0 -0
  63. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/fbd_2traits.cpython-311.pyc +0 -0
  64. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-310.pyc +0 -0
  65. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/fbd_no_traits.cpython-311.pyc +0 -0
  66. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/scenario.cpython-310.pyc +0 -0
  67. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/scenario.cpython-311.pyc +0 -0
  68. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/__pycache__/utils.cpython-311.pyc +0 -0
  69. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/common.py +0 -0
  70. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/epi_multitype.py +0 -0
  71. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/epi_skyline.py +0 -0
  72. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/fbd_2traits.py +0 -0
  73. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/fbd_no_traits.py +0 -0
  74. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/scenarios/scenario.py +0 -0
  75. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/simulations/summarize_logs.py +0 -0
  76. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/utils/__init__.py +0 -0
  77. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/utils/beast.py +0 -0
  78. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/utils/explain.py +0 -0
  79. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/utils/plots.py +0 -0
  80. {bella_companion-0.0.6 → bella_companion-0.0.7}/bella_companion/utils/slurm.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bella-companion
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary:
5
5
  Author: gabriele-marino
6
6
  Author-email: gabmarino.8601@gmail.com
@@ -4,12 +4,10 @@ from pathlib import Path
4
4
 
5
5
  from dotenv import load_dotenv
6
6
 
7
- from bella_companion.simulations import (
8
- generate_data,
9
- generate_figures,
10
- run_beast,
11
- summarize_logs,
12
- )
7
+ from bella_companion.fbd_empirical import run_beast as run_fbd_empirical
8
+ from bella_companion.simulations import generate_data, generate_figures
9
+ from bella_companion.simulations import run_beast as run_simulations
10
+ from bella_companion.simulations import summarize_logs
13
11
 
14
12
 
15
13
  def main():
@@ -28,7 +26,7 @@ def main():
28
26
 
29
27
  subparsers.add_parser(
30
28
  "sim-run", help="Run BEAST2 analyses on simulation datasets."
31
- ).set_defaults(func=run_beast)
29
+ ).set_defaults(func=run_simulations)
32
30
 
33
31
  subparsers.add_parser(
34
32
  "sim-summary", help="Summarize BEAST2 log outputs for simulations."
@@ -38,5 +36,9 @@ def main():
38
36
  "sim-figures", help="Generate plots and figures from simulation results."
39
37
  ).set_defaults(func=generate_figures)
40
38
 
39
+ subparsers.add_parser(
40
+ "fbd-empirical-run", help="Run BEAST2 analyses on empirical FBD datasets."
41
+ ).set_defaults(func=run_fbd_empirical)
42
+
41
43
  args = parser.parse_args()
42
44
  args.func()
@@ -0,0 +1,3 @@
1
+ from bella_companion.fbd_empirical.run_beast import run_beast
2
+
3
+ __all__ = ["run_beast"]
@@ -0,0 +1,68 @@
1
+ import json
2
+ import os
3
+ from pathlib import Path
4
+
5
+ import numpy as np
6
+ import polars as pl
7
+ from phylogenie import load_newick
8
+ from phylogenie.utils import get_node_depths
9
+ from tqdm import tqdm
10
+
11
+ from bella_companion.utils import submit_job
12
+
13
+ THIS_DIR = Path(__file__).parent
14
+
15
+
16
+ def run_beast():
17
+ base_output_dir = Path(os.environ["BELLA_BEAST_OUTPUT_DIR"])
18
+ output_dir = base_output_dir / "fbd-empirical"
19
+ os.makedirs(output_dir, exist_ok=True)
20
+
21
+ data_dir = THIS_DIR / "data"
22
+ tree_file = data_dir / "trees.nwk"
23
+ change_times_file = data_dir / "change_times.csv"
24
+
25
+ trees = load_newick(str(tree_file))
26
+ assert isinstance(trees, list)
27
+ change_times = (
28
+ pl.read_csv(change_times_file, has_header=False).to_series().to_numpy()
29
+ )
30
+ time_predictor = " ".join(list(map(str, np.repeat([0, *change_times], 4))))
31
+ body_mass_predictor = " ".join(["0", "1", "2", "3"] * (len(change_times) + 1))
32
+
33
+ job_ids = {}
34
+ for i, tree in enumerate(tqdm(trees)):
35
+ process_length = max(get_node_depths(tree).values())
36
+ command = " ".join(
37
+ [
38
+ os.environ["BELLA_RUN_BEAST_CMD"],
39
+ f"-D types=0,1,2,3",
40
+ f'-D startTypePriorProbs="0.25 0.25 0.25 0.25"',
41
+ f"-D birthRateUpper=2",
42
+ f"-D deathRateUpper=2",
43
+ f"-D samplingRateUpper=10",
44
+ f'-D samplingRateInit="5 5 5 5 5 5 5"',
45
+ f"-D migrationRateUpper=10",
46
+ f'-D migrationRateInit="0.5 0 0 0.5 0.5 0 0 0.5 0.5 0 0 0.5"',
47
+ f'-D nodes="16 8"',
48
+ f'-D layersRange="0,1,2"',
49
+ f"-D treeFile={tree_file}",
50
+ f"-D treeIndex={i}",
51
+ f"-D changeTimesFile={change_times_file}",
52
+ f"-D samplingChangeTimesFile={data_dir / 'sampling_change_times.csv'}",
53
+ f"-D typeTraitFile={data_dir / 'body_mass.csv'}",
54
+ f"-D processLength={process_length}",
55
+ f'-D timePredictor="{time_predictor}"',
56
+ f'-D bodyMassPredictor="{body_mass_predictor}"',
57
+ f"-prefix {output_dir}{os.sep}",
58
+ str(Path(os.environ["BELLA_BEAST_CONFIGS_DIR"]) / "fbd-empirical.xml"),
59
+ ]
60
+ )
61
+ job_ids[i] = submit_job(
62
+ command,
63
+ Path(os.environ["BELLA_SBATCH_LOG_DIR"]) / "fbd-empirical" / str(i),
64
+ mem_per_cpu="12000",
65
+ )
66
+
67
+ with open(base_output_dir / "fbd_empirical_job_ids.json", "w") as f:
68
+ json.dump(job_ids, f)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "bella-companion"
3
- version = "0.0.6"
3
+ version = "0.0.7"
4
4
  description = ""
5
5
  authors = ["gabriele-marino <gabmarino.8601@gmail.com>"]
6
6
 
@@ -1,11 +0,0 @@
1
- {
2
- "types": "0,1,2,3",
3
- "startTypePriorProbs": "0.25 0.25 0.25 0.25",
4
- "birthRateUpper": 2,
5
- "deathRateUpper": 2,
6
- "samplingRateUpper": 10,
7
- "samplingRateInit": "5 5 5 5 5 5 5",
8
- "migrationRateUpper": 10,
9
- "migrationRateInit": "0.5 0 0 0.5 0.5 0 0 0.5 0.5 0 0 0.5",
10
- "nodes": "16 8"
11
- }
@@ -1,54 +0,0 @@
1
- import os
2
- from pathlib import Path
3
-
4
- import numpy as np
5
- import polars as pl
6
- from phylogenie import load_newick
7
- from phylogenie.utils import get_node_depths
8
- from tqdm import tqdm
9
-
10
- import src.config as cfg
11
- from src.utils import run_sbatch
12
-
13
- THIS_DIR = Path(__file__).parent
14
- AADD LAYERS RANGE
15
-
16
- def main():
17
- output_dir = cfg.BEAST_OUTPUTS_DIR / "fbd-empirical"
18
- os.makedirs(output_dir, exist_ok=True)
19
-
20
- tree_file = THIS_DIR / "data" / "trees.nwk"
21
- change_times_file = THIS_DIR / "data" / "change_times.csv"
22
- sampling_change_times_file = THIS_DIR / "data" / "sampling_change_times.csv"
23
-
24
- change_times = (
25
- pl.read_csv(change_times_file, has_header=False).to_series().to_numpy()
26
- )
27
- time_predictor = " ".join(
28
- list(map(str, np.repeat(np.insert(change_times, 0, 0), 4)))
29
- )
30
- body_mass_predictor = " ".join(["0", "1", "2", "3"] * (len(change_times) + 1))
31
-
32
- trees = load_newick(str(tree_file))
33
- assert isinstance(trees, list)
34
- for i, tree in enumerate(tqdm(trees)):
35
- process_length = max(get_node_depths(tree).values())
36
- for model in ["hidden-relu", "hidden-tanh"]:
37
- command = " ".join(
38
- [
39
- cfg.RUN_BEAST,
40
- f'-D treeFile={tree_file},treeIndex={i},typeTraitFile={THIS_DIR / "data" / "body_mass.csv"},changeTimesFile={change_times_file},samplingChangeTimesFile={sampling_change_times_file},processLength={process_length},timePredictor="{time_predictor}",bodyMassPredictor="{body_mass_predictor}"',
41
- f"-DF {THIS_DIR / 'params.json'}",
42
- f"-prefix {output_dir / model}",
43
- str(cfg.BEAST_CONFIGS_DIR / "fbd-empirical" / f"{model}.xml"),
44
- ]
45
- )
46
- run_sbatch(
47
- command,
48
- cfg.SBATCH_LOGS_DIR / "fbd-empirical" / model / str(i),
49
- mem_per_cpu="12000",
50
- )
51
-
52
-
53
- if __name__ == "__main__":
54
- main()