bella-companion 0.0.10__py3-none-any.whl → 0.0.12__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.
- bella_companion/fbd_empirical/data/change_times.csv +0 -10
- bella_companion/fbd_empirical/data/traits.csv +122 -0
- bella_companion/fbd_empirical/data/trees.nwk +100 -100
- bella_companion/fbd_empirical/run_beast.py +31 -9
- {bella_companion-0.0.10.dist-info → bella_companion-0.0.12.dist-info}/METADATA +2 -2
- {bella_companion-0.0.10.dist-info → bella_companion-0.0.12.dist-info}/RECORD +8 -9
- bella_companion/fbd_empirical/data/body_mass.csv +0 -1378
- bella_companion/fbd_empirical/data/sampling_change_times.csv +0 -6
- {bella_companion-0.0.10.dist-info → bella_companion-0.0.12.dist-info}/WHEEL +0 -0
- {bella_companion-0.0.10.dist-info → bella_companion-0.0.12.dist-info}/entry_points.txt +0 -0
|
@@ -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,6 +12,15 @@ 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():
|
|
15
25
|
base_output_dir = Path(os.environ["BELLA_BEAST_OUTPUT_DIR"])
|
|
16
26
|
output_dir = base_output_dir / "fbd-empirical"
|
|
@@ -19,14 +29,26 @@ def run_beast():
|
|
|
19
29
|
data_dir = Path(__file__).parent / "data"
|
|
20
30
|
tree_file = data_dir / "trees.nwk"
|
|
21
31
|
change_times_file = data_dir / "change_times.csv"
|
|
32
|
+
traits_file = data_dir / "traits.csv"
|
|
22
33
|
|
|
23
34
|
trees = load_newick(str(tree_file))
|
|
24
35
|
assert isinstance(trees, list)
|
|
36
|
+
|
|
37
|
+
traits = pl.read_csv(traits_file, separator="\t", null_values=["NA"])
|
|
38
|
+
|
|
25
39
|
change_times = (
|
|
26
40
|
pl.read_csv(change_times_file, has_header=False).to_series().to_numpy()
|
|
27
41
|
)
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
time_bins = [0, *change_times]
|
|
43
|
+
T = len(time_bins)
|
|
44
|
+
|
|
45
|
+
types: list[str] = sorted(traits["type"].unique())
|
|
46
|
+
types.remove("?")
|
|
47
|
+
N = len(types)
|
|
48
|
+
|
|
49
|
+
time_predictor = " ".join(list(map(str, np.repeat(time_bins, N))))
|
|
50
|
+
log10BM_predictor = " ".join([t.split("_")[0] for t in types] * T)
|
|
51
|
+
midlat_predictor = " ".join([t.split("_")[1] for t in types] * T)
|
|
30
52
|
|
|
31
53
|
job_ids = {}
|
|
32
54
|
for i, tree in enumerate(tqdm(trees)):
|
|
@@ -34,24 +56,24 @@ def run_beast():
|
|
|
34
56
|
command = " ".join(
|
|
35
57
|
[
|
|
36
58
|
os.environ["BELLA_RUN_BEAST_CMD"],
|
|
37
|
-
f
|
|
38
|
-
f'-D startTypePriorProbs="
|
|
59
|
+
f'-D types="{",".join(types)}"',
|
|
60
|
+
f'-D startTypePriorProbs="{" ".join([str(1/N)] * N)}"',
|
|
39
61
|
f"-D birthRateUpper=5",
|
|
40
62
|
f"-D deathRateUpper=5",
|
|
41
63
|
f"-D samplingRateUpper=5",
|
|
42
|
-
f'-D samplingRateInit="
|
|
64
|
+
f'-D samplingRateInit="{" ".join(["2.5"] * T)}"',
|
|
43
65
|
f"-D migrationRateUpper=5",
|
|
44
|
-
f'-D migrationRateInit="
|
|
66
|
+
f'-D migrationRateInit="{_get_migration_rates_init(types, 2.5)}"',
|
|
45
67
|
f'-D nodes="16 8"',
|
|
46
68
|
f'-D layersRange="0,1,2"',
|
|
47
69
|
f"-D treeFile={tree_file}",
|
|
48
70
|
f"-D treeIndex={i}",
|
|
49
71
|
f"-D changeTimesFile={change_times_file}",
|
|
50
|
-
f"-D
|
|
51
|
-
f"-D typeTraitFile={data_dir / 'body_mass.csv'}",
|
|
72
|
+
f"-D traitsFile={traits_file}",
|
|
52
73
|
f"-D processLength={process_length}",
|
|
53
74
|
f'-D timePredictor="{time_predictor}"',
|
|
54
|
-
f'-D
|
|
75
|
+
f'-D log10BMPredictor="{log10BM_predictor}"',
|
|
76
|
+
f'-D midlatPredictor="{midlat_predictor}"',
|
|
55
77
|
f"-prefix {output_dir}{os.sep}",
|
|
56
78
|
str(Path(os.environ["BELLA_BEAST_CONFIGS_DIR"]) / "fbd-empirical.xml"),
|
|
57
79
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bella-companion
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.12
|
|
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.
|
|
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/
|
|
5
|
-
bella_companion/fbd_empirical/data/
|
|
6
|
-
bella_companion/fbd_empirical/data/
|
|
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=
|
|
8
|
+
bella_companion/fbd_empirical/run_beast.py,sha256=MPW4A10NiXc8y3JS3ZN17DL-Oh8IoIdTv1Y5QLLrcxo,3229
|
|
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.
|
|
40
|
-
bella_companion-0.0.
|
|
41
|
-
bella_companion-0.0.
|
|
42
|
-
bella_companion-0.0.
|
|
38
|
+
bella_companion-0.0.12.dist-info/METADATA,sha256=0XKEli6E-1urNh-LiUEm9nqBm5FR6CWqZHXo4ow4rK4,577
|
|
39
|
+
bella_companion-0.0.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
40
|
+
bella_companion-0.0.12.dist-info/entry_points.txt,sha256=rSeKoAhmjnQqAYFcXBv0gAM2ViJfJe0D8_dD-fWrXeg,50
|
|
41
|
+
bella_companion-0.0.12.dist-info/RECORD,,
|