@@ -269,6 +269,7 @@ def infer(
269
269
num_threads = 0 ,
270
270
# Deliberately undocumented parameters below
271
271
precision = None ,
272
+ likelihood_threshold = None ,
272
273
engine = constants .C_ENGINE ,
273
274
progress_monitor = None ,
274
275
time_units = None ,
@@ -349,6 +350,7 @@ def infer(
349
350
recombination_rate = recombination_rate ,
350
351
mismatch_ratio = mismatch_ratio ,
351
352
precision = precision ,
353
+ likelihood_threshold = likelihood_threshold ,
352
354
path_compression = path_compression ,
353
355
progress_monitor = progress_monitor ,
354
356
time_units = time_units ,
@@ -362,6 +364,7 @@ def infer(
362
364
recombination_rate = recombination_rate ,
363
365
mismatch_ratio = mismatch_ratio ,
364
366
precision = precision ,
367
+ likelihood_threshold = likelihood_threshold ,
365
368
post_process = post_process ,
366
369
path_compression = path_compression ,
367
370
progress_monitor = progress_monitor ,
@@ -457,6 +460,7 @@ def match_ancestors(
457
460
recombination = None , # See :class:`Matcher`
458
461
mismatch = None , # See :class:`Matcher`
459
462
precision = None ,
463
+ likelihood_threshold = None ,
460
464
engine = constants .C_ENGINE ,
461
465
progress_monitor = None ,
462
466
extended_checks = False ,
@@ -514,6 +518,7 @@ def match_ancestors(
514
518
path_compression = path_compression ,
515
519
num_threads = num_threads ,
516
520
precision = precision ,
521
+ likelihood_threshold = likelihood_threshold ,
517
522
extended_checks = extended_checks ,
518
523
engine = engine ,
519
524
progress_monitor = progress_monitor ,
@@ -639,6 +644,7 @@ def match_samples(
639
644
recombination = None , # See :class:`Matcher`
640
645
mismatch = None , # See :class:`Matcher`
641
646
precision = None ,
647
+ likelihood_threshold = None ,
642
648
extended_checks = False ,
643
649
engine = constants .C_ENGINE ,
644
650
progress_monitor = None ,
@@ -723,6 +729,7 @@ def match_samples(
723
729
path_compression = path_compression ,
724
730
num_threads = num_threads ,
725
731
precision = precision ,
732
+ likelihood_threshold = likelihood_threshold ,
726
733
extended_checks = extended_checks ,
727
734
engine = engine ,
728
735
progress_monitor = progress_monitor ,
@@ -1141,6 +1148,7 @@ def __init__(
1141
1148
recombination = None ,
1142
1149
mismatch = None ,
1143
1150
precision = None ,
1151
+ likelihood_threshold = None ,
1144
1152
extended_checks = False ,
1145
1153
engine = constants .C_ENGINE ,
1146
1154
progress_monitor = None ,
@@ -1233,11 +1241,16 @@ def __init__(
1233
1241
if not (np .all (mismatch >= 0 ) and np .all (mismatch <= 1 )):
1234
1242
raise ValueError ("Underlying mismatch probabilities not between 0 & 1" )
1235
1243
1236
- if precision is None :
1237
- precision = 13
1244
+ if precision is not None and likelihood_threshold is not None :
1245
+ raise ValueError ("Cannot specify likelihood_threshold and precision" )
1246
+ if precision is not None :
1247
+ likelihood_threshold = pow (10 , - precision )
1248
+ if likelihood_threshold is None :
1249
+ likelihood_threshold = 1e-13 # ~Same as previous precision default.
1250
+
1238
1251
self .recombination [1 :] = recombination
1239
1252
self .mismatch [:] = mismatch
1240
- self .precision = precision
1253
+ self .likelihood_threshold = likelihood_threshold
1241
1254
1242
1255
if len (recombination ) == 0 :
1243
1256
logger .info ("Fewer than two inference sites: no recombination possible" )
@@ -1261,7 +1274,7 @@ def __init__(
1261
1274
f"mean={ np .mean (mismatch ):.5g} "
1262
1275
)
1263
1276
logger .info (
1264
- f"Matching using { precision } digits of precision in likelihood calcs "
1277
+ f"Matching using likelihood_threshold of { likelihood_threshold :.5g } "
1265
1278
)
1266
1279
1267
1280
if engine == constants .C_ENGINE :
@@ -1303,7 +1316,7 @@ def __init__(
1303
1316
self .tree_sequence_builder ,
1304
1317
recombination = self .recombination ,
1305
1318
mismatch = self .mismatch ,
1306
- precision = precision ,
1319
+ likelihood_threshold = likelihood_threshold ,
1307
1320
extended_checks = self .extended_checks ,
1308
1321
)
1309
1322
for _ in range (num_threads )
0 commit comments