phylogenie 1.0.5__py3-none-any.whl → 1.0.6__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.
@@ -17,15 +17,16 @@ from phylogenie.skyline import (
17
17
  DEFAULT_POPULATION = "X"
18
18
  INFECTIOUS_POPULATION = "I"
19
19
  EXPOSED_POPULATION = "E"
20
+ SUPERSPREADER_POPULATION = "S"
20
21
 
21
22
 
22
23
  @dataclass
23
24
  class TreeParams:
24
- populations: str | list[str] = DEFAULT_POPULATION
25
+ populations: str | list[str]
26
+ transmission_rates: SkylineMatrixCoercible
27
+ removal_rates: SkylineVectorCoercible
28
+ sampling_proportions: SkylineVectorCoercible
25
29
  transition_rates: SkylineMatrixCoercible = 0
26
- transmission_rates: SkylineMatrixCoercible = 0
27
- removal_rates: SkylineVectorCoercible = 0
28
- sampling_proportions: SkylineVectorCoercible = 0
29
30
 
30
31
 
31
32
  def generate_tree(
@@ -137,3 +138,25 @@ def get_BDEI_params(
137
138
  removal_rates=removal_rates,
138
139
  sampling_proportions=sampling_proportions,
139
140
  )
141
+
142
+
143
+ def get_BDSS_params(
144
+ reproduction_number: SkylineParameterLike,
145
+ infectious_period: SkylineParameterLike,
146
+ superspreading_ratio: SkylineParameterLike,
147
+ superspreaders_proportion: SkylineParameterLike,
148
+ sampling_proportion: SkylineParameterLike,
149
+ ) -> TreeParams:
150
+ gamma = 1 / infectious_period
151
+ f_SS = superspreaders_proportion
152
+ r_SS = superspreading_ratio
153
+ lambda_IS = reproduction_number * gamma * f_SS / (1 + r_SS * f_SS - f_SS)
154
+ lambda_SI = (reproduction_number * gamma - r_SS * lambda_IS) * r_SS
155
+ lambda_SS = r_SS * lambda_IS
156
+ lambda_II = lambda_SI / r_SS
157
+ return TreeParams(
158
+ populations=[INFECTIOUS_POPULATION, SUPERSPREADER_POPULATION],
159
+ transmission_rates=[[lambda_II, lambda_IS], [lambda_SI, lambda_SS]],
160
+ removal_rates=gamma,
161
+ sampling_proportions=sampling_proportion,
162
+ )
@@ -13,6 +13,7 @@ from phylogenie.backend.treesimulator import (
13
13
  generate_tree,
14
14
  get_BD_params,
15
15
  get_BDEI_params,
16
+ get_BDSS_params,
16
17
  )
17
18
  from phylogenie.core.factories import (
18
19
  int_factory,
@@ -28,6 +29,7 @@ class ParameterizationType(str, Enum):
28
29
  MTBD = "MTBD"
29
30
  BD = "BD"
30
31
  BDEI = "BDEI"
32
+ BDSS = "BDSS"
31
33
 
32
34
 
33
35
  class TreeSimulatorGenerator(TreesGenerator):
@@ -73,10 +75,10 @@ class TreeSimulatorGenerator(TreesGenerator):
73
75
  class MTBDTreeSimulatorGenerator(TreeSimulatorGenerator):
74
76
  parameterization: Literal[ParameterizationType.MTBD] = ParameterizationType.MTBD
75
77
  populations: str | list[str] = DEFAULT_POPULATION
78
+ transmission_rates: cfg.SkylineMatrixCoercibleConfig
79
+ removal_rates: cfg.SkylineVectorCoercibleConfig
76
80
  transition_rates: cfg.SkylineMatrixCoercibleConfig = 0
77
- transmission_rates: cfg.SkylineMatrixCoercibleConfig = 0
78
- removal_rates: cfg.SkylineVectorCoercibleConfig = 0
79
- sampling_proportions: cfg.SkylineVectorCoercibleConfig = 0
81
+ sampling_proportions: cfg.SkylineVectorCoercibleConfig = 1
80
82
 
81
83
  def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
82
84
  self._generate_one_from_params(
@@ -103,9 +105,9 @@ class MTBDTreeSimulatorGenerator(TreeSimulatorGenerator):
103
105
 
104
106
  class BDTreeSimulatorGenerator(TreeSimulatorGenerator):
105
107
  parameterization: Literal[ParameterizationType.BD] = ParameterizationType.BD
106
- reproduction_number: cfg.SkylineParameterLikeConfig = 0
107
- infectious_period: cfg.SkylineParameterLikeConfig = 0
108
- sampling_proportion: cfg.SkylineParameterLikeConfig = 0
108
+ reproduction_number: cfg.SkylineParameterLikeConfig
109
+ infectious_period: cfg.SkylineParameterLikeConfig
110
+ sampling_proportion: cfg.SkylineParameterLikeConfig = 1
109
111
 
110
112
  def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
111
113
  self._generate_one_from_params(
@@ -128,10 +130,10 @@ class BDTreeSimulatorGenerator(TreeSimulatorGenerator):
128
130
 
129
131
  class BDEITreeSimulatorGenerator(TreeSimulatorGenerator):
130
132
  parameterization: Literal[ParameterizationType.BDEI] = ParameterizationType.BDEI
131
- reproduction_number: cfg.SkylineParameterLikeConfig = 0
132
- infectious_period: cfg.SkylineParameterLikeConfig = 0
133
- incubation_period: cfg.SkylineParameterLikeConfig = 0
134
- sampling_proportion: cfg.SkylineParameterLikeConfig = 0
133
+ reproduction_number: cfg.SkylineParameterLikeConfig
134
+ infectious_period: cfg.SkylineParameterLikeConfig
135
+ incubation_period: cfg.SkylineParameterLikeConfig
136
+ sampling_proportion: cfg.SkylineParameterLikeConfig = 1
135
137
 
136
138
  def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
137
139
  self._generate_one_from_params(
@@ -155,7 +157,43 @@ class BDEITreeSimulatorGenerator(TreeSimulatorGenerator):
155
157
  )
156
158
 
157
159
 
160
+ class BDSSTreeSimulatorGenerator(TreeSimulatorGenerator):
161
+ parameterization: Literal[ParameterizationType.BDSS] = ParameterizationType.BDSS
162
+ reproduction_number: cfg.SkylineParameterLikeConfig
163
+ infectious_period: cfg.SkylineParameterLikeConfig
164
+ superspreading_ratio: cfg.SkylineParameterLikeConfig
165
+ superspreaders_proportion: cfg.SkylineParameterLikeConfig
166
+ sampling_proportion: cfg.SkylineParameterLikeConfig = 1
167
+
168
+ def _generate_one(self, filename: str, rng: Generator, data: pgt.Data) -> None:
169
+ self._generate_one_from_params(
170
+ filename,
171
+ rng,
172
+ data,
173
+ get_BDSS_params(
174
+ reproduction_number=skyline_parameter_like_factory(
175
+ self.reproduction_number, data
176
+ ),
177
+ infectious_period=skyline_parameter_like_factory(
178
+ self.infectious_period, data
179
+ ),
180
+ superspreading_ratio=skyline_parameter_like_factory(
181
+ self.superspreading_ratio, data
182
+ ),
183
+ superspreaders_proportion=skyline_parameter_like_factory(
184
+ self.superspreaders_proportion, data
185
+ ),
186
+ sampling_proportion=skyline_parameter_like_factory(
187
+ self.sampling_proportion, data
188
+ ),
189
+ ),
190
+ )
191
+
192
+
158
193
  TreeSimulatorGeneratorConfig = Annotated[
159
- MTBDTreeSimulatorGenerator | BDTreeSimulatorGenerator | BDEITreeSimulatorGenerator,
194
+ MTBDTreeSimulatorGenerator
195
+ | BDTreeSimulatorGenerator
196
+ | BDEITreeSimulatorGenerator
197
+ | BDSSTreeSimulatorGenerator,
160
198
  Field(discriminator="parameterization"),
161
199
  ]
phylogenie/typings.py CHANGED
@@ -21,4 +21,3 @@ Vector2D = list[Vector1D]
21
21
  Vector3D = list[Vector2D]
22
22
 
23
23
  Data = dict[str, str | Scalar | Vector1D | Vector2D | Vector3D]
24
- Size = int | tuple[int, int] | tuple[int, int, int]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phylogenie
3
- Version: 1.0.5
3
+ Version: 1.0.6
4
4
  Summary: Generate phylogenetic datasets with minimal setup effort
5
5
  Author: Gabriele Marino
6
6
  Author-email: gabmarino.8601@gmail.com
@@ -46,7 +46,7 @@ Phylogenie comes packed with useful features, including:
46
46
  Simply specify the number of cores to use, and Phylogenie handles multiprocessing automatically.
47
47
 
48
48
  - **Pre-implemented parameterizations** 🎯
49
- Include canonical, fossilized birth-death, epidemiological, birth-death with exposed-infectious (BDEI), contact-tracing (CT), and more.
49
+ Include canonical, fossilized birth-death, epidemiological, birth-death with exposed-infectious (BDEI), birth-death with superspreading (BDSS), contact-tracing (CT), and more.
50
50
 
51
51
  - **Skyline parameter support** 🪜
52
52
  Support for piece-wise constant parameters.
@@ -3,7 +3,7 @@ phylogenie/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
3
3
  phylogenie/backend/remaster/__init__.py,sha256=g1oMKi6SX60Geq_e2AjBlf7-pDvLfrsT3gW6AORdbMo,509
4
4
  phylogenie/backend/remaster/generate.py,sha256=Sb5izUQO0GmUcIEMoXtHWLsh9c4vIeyNIUm7u4RVLdw,6100
5
5
  phylogenie/backend/remaster/reactions.py,sha256=oc2ZY9WtTajbOWjARDmA0JnS255tbVeMt1DmyCUp95M,5904
6
- phylogenie/backend/treesimulator.py,sha256=wvN7WZwUKGPWt7AetumQz1ZrUc4k_D6lftSaYG1hNBg,4587
6
+ phylogenie/backend/treesimulator.py,sha256=6yoOnVXcNatw3jBfuTgOrJ56out9-dNRlcTH83iiqZ0,5440
7
7
  phylogenie/configs.py,sha256=HtRUWZ-zNq1--zTBWL3QFXX27Ybw5x1qSWcmx7Sz8YA,125
8
8
  phylogenie/core/__init__.py,sha256=pvQMohKFAPaSvujw7H5sQJn7SOSqENQUHECuVfUBVNg,402
9
9
  phylogenie/core/configs.py,sha256=9tUYWrmdDn_Gg6xnywCDcGDEk0gne0vYqFH9dXixJbM,1042
@@ -22,7 +22,7 @@ phylogenie/core/trees/remaster/__init__.py,sha256=FfgXYjkeosb22Anbp78re2NssWtNcN
22
22
  phylogenie/core/trees/remaster/configs.py,sha256=d4EqowYMb5I2TfBTgNf9H_X1t8aNCYJbh1RQmFoDxs4,362
23
23
  phylogenie/core/trees/remaster/factories.py,sha256=qla4pg4OgfE5lwQZuP3bEaMt7xIF4P6fQ1Z0IPpFxUs,812
24
24
  phylogenie/core/trees/remaster/generator.py,sha256=LZTnNHZej6E1QakTBaBwRQQRaeb6rfG61U61bGbgE5Y,7260
25
- phylogenie/core/trees/treesimulator.py,sha256=cr5Xod_OR6QQ-Lej86aXDYn_6J-tBIusXlqUTiKGSN4,5897
25
+ phylogenie/core/trees/treesimulator.py,sha256=RpyRvXAHLHEOU9Ub9Yg61au7xP_rnbC7N0va43gbbx8,7319
26
26
  phylogenie/core/typeguards.py,sha256=wEBYJZZ_Q_bY7ZJSh00AXJeyc1X8ZoysoOiLwo24N1w,990
27
27
  phylogenie/main.py,sha256=n_joau3dWJIq0ZMHe4a_1_2GigTFagkfzUFuQEMlyRI,1158
28
28
  phylogenie/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -31,9 +31,9 @@ phylogenie/skyline/matrix.py,sha256=T2g_MtfrqXVVGug40Nka1Q0YrpIi4KKx72Z573J-V18,
31
31
  phylogenie/skyline/parameter.py,sha256=CJ5OEyRQG2Tg1WJWQ1IpfX-6hjJv80Zj8lMoRke5nnQ,4648
32
32
  phylogenie/skyline/vector.py,sha256=Zh6HWoziXQFKDz-XvVE2e_Tw1706NrbwcvBpyPpw_cc,7120
33
33
  phylogenie/typeguards.py,sha256=WBOSJSaOC8VDtrYoA2w_AYEXTpyKdCfmsM29KaKXl3A,1350
34
- phylogenie/typings.py,sha256=cW0WEQEKmjuz_KcRsOfE7aQH5QLM1i55R-2DDWJG8xM,617
35
- phylogenie-1.0.5.dist-info/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
36
- phylogenie-1.0.5.dist-info/METADATA,sha256=0gil5OBrrH5SUNvF5zyogVe3mZh3KdT5K84Tc1YHi78,6251
37
- phylogenie-1.0.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
38
- phylogenie-1.0.5.dist-info/entry_points.txt,sha256=Rt6_usN0FkBX1ZfiqCirjMN9FKOgFLG8rydcQ8kugeE,51
39
- phylogenie-1.0.5.dist-info/RECORD,,
34
+ phylogenie/typings.py,sha256=93VRedBxrpzXkT4uaNu_1JiMzsOjp7fUy4kLv_eYxUE,565
35
+ phylogenie-1.0.6.dist-info/LICENSE.txt,sha256=NUrDqElK-eD3I0WqC004CJsy6cs0JgsAoebDv_42-pw,1071
36
+ phylogenie-1.0.6.dist-info/METADATA,sha256=zJP0tUUe17qjUcUVSeM8y3-7ng9e9R54W_phEVIGpgE,6291
37
+ phylogenie-1.0.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
38
+ phylogenie-1.0.6.dist-info/entry_points.txt,sha256=Rt6_usN0FkBX1ZfiqCirjMN9FKOgFLG8rydcQ8kugeE,51
39
+ phylogenie-1.0.6.dist-info/RECORD,,