bella-companion 0.0.10__py3-none-any.whl → 0.0.11__py3-none-any.whl

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.

@@ -1,5 +1,6 @@
1
1
  import json
2
2
  import os
3
+ from itertools import combinations
3
4
  from pathlib import Path
4
5
 
5
6
  import numpy as np
@@ -11,7 +12,19 @@ from tqdm import tqdm
11
12
  from bella_companion.utils import submit_job
12
13
 
13
14
 
15
+ def _get_migration_rates_init(types: list[str], init_rate: float = 1) -> str:
16
+ mus: list[float] = []
17
+ for t1, t2 in combinations(types, 2):
18
+ traits1 = np.array(list(map(int, t1.split("_"))))
19
+ traits2 = np.array(list(map(int, t2.split("_"))))
20
+ mus.append(init_rate if np.sum(np.abs(traits1 - traits2)) == 1 else 0)
21
+ return " ".join(map(str, mus))
22
+
23
+
14
24
  def run_beast():
25
+ from dotenv import load_dotenv
26
+
27
+ load_dotenv()
15
28
  base_output_dir = Path(os.environ["BELLA_BEAST_OUTPUT_DIR"])
16
29
  output_dir = base_output_dir / "fbd-empirical"
17
30
  os.makedirs(output_dir, exist_ok=True)
@@ -19,14 +32,28 @@ def run_beast():
19
32
  data_dir = Path(__file__).parent / "data"
20
33
  tree_file = data_dir / "trees.nwk"
21
34
  change_times_file = data_dir / "change_times.csv"
35
+ traits_file = data_dir / "traits.csv"
22
36
 
23
37
  trees = load_newick(str(tree_file))
24
38
  assert isinstance(trees, list)
39
+
40
+ traits = pl.read_csv(traits_file, separator="\t", null_values=["NA"])
41
+
25
42
  change_times = (
26
43
  pl.read_csv(change_times_file, has_header=False).to_series().to_numpy()
27
44
  )
28
- time_predictor = " ".join(list(map(str, np.repeat([0, *change_times], 4))))
29
- body_mass_predictor = " ".join(["0", "1", "2", "3"] * (len(change_times) + 1))
45
+
46
+ types: list[str] = sorted(traits["type"].unique())
47
+ types.remove("?")
48
+ N = len(types)
49
+
50
+ time_predictor = " ".join(list(map(str, np.repeat([0, *change_times], N))))
51
+ log10BM_predictor = " ".join(
52
+ [t.split("_")[0] for t in types] * (len(change_times) + 1)
53
+ )
54
+ midlat_predictor = " ".join(
55
+ [t.split("_")[1] for t in types] * (len(change_times) + 1)
56
+ )
30
57
 
31
58
  job_ids = {}
32
59
  for i, tree in enumerate(tqdm(trees)):
@@ -34,24 +61,24 @@ def run_beast():
34
61
  command = " ".join(
35
62
  [
36
63
  os.environ["BELLA_RUN_BEAST_CMD"],
37
- f"-D types=0,1,2,3",
38
- f'-D startTypePriorProbs="0.25 0.25 0.25 0.25"',
64
+ f'-D types="{",".join(types)}"',
65
+ f'-D startTypePriorProbs="{" ".join([str(1/N)] * N)}"',
39
66
  f"-D birthRateUpper=5",
40
67
  f"-D deathRateUpper=5",
41
68
  f"-D samplingRateUpper=5",
42
- f'-D samplingRateInit="2.5 2.5 2.5 2.5 2.5 2.5 2.5"',
69
+ f'-D samplingRateInit="{" ".join(["2.5"] * N)}"',
43
70
  f"-D migrationRateUpper=5",
44
- f'-D migrationRateInit="2.5 0 0 2.5 2.5 0 0 2.5 2.5 0 0 2.5"',
71
+ f'-D migrationRateInit="{_get_migration_rates_init(types, 2.5)}"',
45
72
  f'-D nodes="16 8"',
46
73
  f'-D layersRange="0,1,2"',
47
- f"-D treeFile={tree_file}",
74
+ f"-D tree_file={tree_file}",
48
75
  f"-D treeIndex={i}",
49
76
  f"-D changeTimesFile={change_times_file}",
50
- f"-D samplingChangeTimesFile={data_dir / 'sampling_change_times.csv'}",
51
- f"-D typeTraitFile={data_dir / 'body_mass.csv'}",
77
+ f"-D traitsFile={traits_file}",
52
78
  f"-D processLength={process_length}",
53
79
  f'-D timePredictor="{time_predictor}"',
54
- f'-D bodyMassPredictor="{body_mass_predictor}"',
80
+ f'-D log10BM_predictor="{log10BM_predictor}"',
81
+ f'-D midlat_predictor="{midlat_predictor}"',
55
82
  f"-prefix {output_dir}{os.sep}",
56
83
  str(Path(os.environ["BELLA_BEAST_CONFIGS_DIR"]) / "fbd-empirical.xml"),
57
84
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bella-companion
3
- Version: 0.0.10
3
+ Version: 0.0.11
4
4
  Summary:
5
5
  Author: gabriele-marino
6
6
  Author-email: gabmarino.8601@gmail.com
@@ -12,5 +12,5 @@ Classifier: Programming Language :: Python :: 3.12
12
12
  Requires-Dist: arviz (>=0.22.0,<0.23.0)
13
13
  Requires-Dist: bella-lumiere (>=0.0.13,<0.0.14)
14
14
  Requires-Dist: dotenv (>=0.9.9,<0.10.0)
15
- Requires-Dist: phylogenie (>=2.1.29,<3.0.0)
15
+ Requires-Dist: phylogenie (>=2.1.30,<3.0.0)
16
16
  Requires-Dist: seaborn (>=0.13.2,<0.14.0)
@@ -1,12 +1,11 @@
1
1
  bella_companion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  bella_companion/cli.py,sha256=D-kQuj0I-g5Vm5-mXdOZoio68mhOBpJ3jVG8B2Kwvn4,2190
3
3
  bella_companion/fbd_empirical/__init__.py,sha256=FgzjaEpwZImvBsJs17ghF0ltZvhFmgmkTGGF3HgdsGo,284
4
- bella_companion/fbd_empirical/data/body_mass.csv,sha256=-UkKNtm9m3g4PjY3BcfdP6z5nL_I6p9cq6cgZ-bWKI8,30360
5
- bella_companion/fbd_empirical/data/change_times.csv,sha256=zmc9_z91-XMwKyIoP9v9dVlLcf4MeIHkQiHLjoMriOo,120
6
- bella_companion/fbd_empirical/data/sampling_change_times.csv,sha256=Gwi9RcMFy89RyvfxKVZ_MoKVRHOZLuwB_3LEaq8asMQ,32
7
- bella_companion/fbd_empirical/data/trees.nwk,sha256=zhvLvPLZelhMThVmvOENkmi3p2aPAARb8KMdHTm6mss,4645318
4
+ bella_companion/fbd_empirical/data/change_times.csv,sha256=tedobHbaY7-6M3V6F6HSqGAU9dpeeajR5mu1XGJfp6w,68
5
+ bella_companion/fbd_empirical/data/traits.csv,sha256=cxNKYmgtBCKHsm9qnOpS29Rkx9cQKe0oxpgaXSIukJg,5422
6
+ bella_companion/fbd_empirical/data/trees.nwk,sha256=JAsdfGhTIzGmJz6g6-0s5SVfqNuxawOMc9gbt0srue4,539385
8
7
  bella_companion/fbd_empirical/results.py,sha256=0FENY5EpgNQ6rwPsEiOT2ZEO5oBbIAK6TzPvk11SDnk,3116
9
- bella_companion/fbd_empirical/run_beast.py,sha256=ZBTtBhSz3wDmPZQJZaY9_o56x_FkL9lKiopWVV_ItX8,2523
8
+ bella_companion/fbd_empirical/run_beast.py,sha256=Vvh0xognC92tAI7GhUyzU901N1x6t8UjUDccvB2JcVA,3309
10
9
  bella_companion/fbd_empirical/summarize_logs.py,sha256=OoT43DMjim9o4qsjYCgGKnBKp3dHXzVP6sVtzqR8lMQ,955
11
10
  bella_companion/simulations/__init__.py,sha256=ShYRdp1iSjnS_SzcsH-8jbqXz6P1nyRQZqAtPZJCMVE,454
12
11
  bella_companion/simulations/features.py,sha256=DZOBpJGlQ0UinqUZYbEtoemZ2eQGVLV_i-DfpW31qJI,104
@@ -36,7 +35,7 @@ bella_companion/utils/__init__.py,sha256=UtMwPK9dWf9NAl0ic8CSsgdW7aSm-5J49OqgvD7
36
35
  bella_companion/utils/beast.py,sha256=TBa0cLklX1_tXqoQE4LRYvds7mLg_9fS2-6U6OHENHo,2184
37
36
  bella_companion/utils/explain.py,sha256=uP7HPyn2YiykAI69BQV3RooDpC6qKoCLXfp3Uibp4zk,1475
38
37
  bella_companion/utils/slurm.py,sha256=v5DaG7YHVyK8KRFptgGDC6I8jxEhyJuMVK9N08pZSAI,1812
39
- bella_companion-0.0.10.dist-info/METADATA,sha256=gLQu59HiP0oxF5V7o3cehkcRwhcaDcIumiYIC7D0eXc,577
40
- bella_companion-0.0.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
41
- bella_companion-0.0.10.dist-info/entry_points.txt,sha256=rSeKoAhmjnQqAYFcXBv0gAM2ViJfJe0D8_dD-fWrXeg,50
42
- bella_companion-0.0.10.dist-info/RECORD,,
38
+ bella_companion-0.0.11.dist-info/METADATA,sha256=NQPoh1JxQYhkfvNRr_CrdJx1_t46j5o8P6lHlnEy83k,577
39
+ bella_companion-0.0.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
40
+ bella_companion-0.0.11.dist-info/entry_points.txt,sha256=rSeKoAhmjnQqAYFcXBv0gAM2ViJfJe0D8_dD-fWrXeg,50
41
+ bella_companion-0.0.11.dist-info/RECORD,,