@@ -104,7 +104,7 @@ def test_basic(
104
104
mu = sim_mutations_parameters ["rate" ]
105
105
106
106
dts , posteriors = tsdate .date (
107
- ts , Ne = Ne , mutation_rate = mu , return_posteriors = True
107
+ ts , population_size = Ne , mutation_rate = mu , return_posteriors = True
108
108
)
109
109
# make sure we can read node metadata - old tsdate versions didn't set a schema
110
110
if dts .table_metadata_schemas .node .schema is None :
@@ -139,6 +139,38 @@ def test_scaling(self, Ne):
139
139
Test that we are in the right theoretical ballpark given known Ne
140
140
"""
141
141
ts = tskit .Tree .generate_comb (2 ).tree_sequence
142
- dts = tsdate .date (ts , Ne = Ne , mutation_rate = None )
142
+ dts = tsdate .date (ts , population_size = Ne , mutation_rate = None )
143
143
# Check the date is within 10% of the expected
144
144
assert 0.9 < dts .node (dts .first ().root ).time / (2 * Ne ) < 1.1
145
+
146
+ @pytest .mark .parametrize (
147
+ "bkwd_rate, trio_tmrca" ,
148
+ [ # calculated from simulations
149
+ (- 1.0 , 0.76 ),
150
+ (- 0.9 , 0.79 ),
151
+ (- 0.8 , 0.82 ),
152
+ (- 0.7 , 0.85 ),
153
+ (- 0.6 , 0.89 ),
154
+ (- 0.5 , 0.94 ),
155
+ (- 0.4 , 0.99 ),
156
+ (- 0.3 , 1.05 ),
157
+ (- 0.2 , 1.12 ),
158
+ (- 0.1 , 1.21 ),
159
+ (0.0 , 1.32 ),
160
+ ],
161
+ )
162
+ def test_piecewise_scaling (self , bkwd_rate , trio_tmrca ):
163
+ """
164
+ Test that we are in the right theoretical ballpark given known Ne,
165
+ under exponential growth.
166
+
167
+ Check coalescence time of a trio instead of a pair, because of
168
+ https://github.com/tskit-dev/tsdate/issues/230
169
+ """
170
+ time = np .linspace (0 , 10 , 100 )
171
+ ne = 0.5 * np .exp (bkwd_rate * time )
172
+ ts = tskit .Tree .generate_comb (3 ).tree_sequence
173
+ demo = tsdate .demography .PopulationSizeHistory (ne , time [1 :])
174
+ dts = tsdate .date (ts , population_size = demo , mutation_rate = None )
175
+ # Check the date is within 10% of the expected
176
+ assert 0.9 < dts .node (dts .first ().root ).time / trio_tmrca < 1.1
0 commit comments