@@ -269,6 +269,7 @@ def infer(
269269 num_threads = 0 ,
270270 # Deliberately undocumented parameters below
271271 precision = None ,
272+ likelihood_threshold = None ,
272273 engine = constants .C_ENGINE ,
273274 progress_monitor = None ,
274275 time_units = None ,
@@ -349,6 +350,7 @@ def infer(
349350 recombination_rate = recombination_rate ,
350351 mismatch_ratio = mismatch_ratio ,
351352 precision = precision ,
353+ likelihood_threshold = likelihood_threshold ,
352354 path_compression = path_compression ,
353355 progress_monitor = progress_monitor ,
354356 time_units = time_units ,
@@ -362,6 +364,7 @@ def infer(
362364 recombination_rate = recombination_rate ,
363365 mismatch_ratio = mismatch_ratio ,
364366 precision = precision ,
367+ likelihood_threshold = likelihood_threshold ,
365368 post_process = post_process ,
366369 path_compression = path_compression ,
367370 progress_monitor = progress_monitor ,
@@ -457,6 +460,7 @@ def match_ancestors(
457460 recombination = None , # See :class:`Matcher`
458461 mismatch = None , # See :class:`Matcher`
459462 precision = None ,
463+ likelihood_threshold = None ,
460464 engine = constants .C_ENGINE ,
461465 progress_monitor = None ,
462466 extended_checks = False ,
@@ -514,6 +518,7 @@ def match_ancestors(
514518 path_compression = path_compression ,
515519 num_threads = num_threads ,
516520 precision = precision ,
521+ likelihood_threshold = likelihood_threshold ,
517522 extended_checks = extended_checks ,
518523 engine = engine ,
519524 progress_monitor = progress_monitor ,
@@ -639,6 +644,7 @@ def match_samples(
639644 recombination = None , # See :class:`Matcher`
640645 mismatch = None , # See :class:`Matcher`
641646 precision = None ,
647+ likelihood_threshold = None ,
642648 extended_checks = False ,
643649 engine = constants .C_ENGINE ,
644650 progress_monitor = None ,
@@ -723,6 +729,7 @@ def match_samples(
723729 path_compression = path_compression ,
724730 num_threads = num_threads ,
725731 precision = precision ,
732+ likelihood_threshold = likelihood_threshold ,
726733 extended_checks = extended_checks ,
727734 engine = engine ,
728735 progress_monitor = progress_monitor ,
@@ -1141,6 +1148,7 @@ def __init__(
11411148 recombination = None ,
11421149 mismatch = None ,
11431150 precision = None ,
1151+ likelihood_threshold = None ,
11441152 extended_checks = False ,
11451153 engine = constants .C_ENGINE ,
11461154 progress_monitor = None ,
@@ -1233,11 +1241,16 @@ def __init__(
12331241 if not (np .all (mismatch >= 0 ) and np .all (mismatch <= 1 )):
12341242 raise ValueError ("Underlying mismatch probabilities not between 0 & 1" )
12351243
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+
12381251 self .recombination [1 :] = recombination
12391252 self .mismatch [:] = mismatch
1240- self .precision = precision
1253+ self .likelihood_threshold = likelihood_threshold
12411254
12421255 if len (recombination ) == 0 :
12431256 logger .info ("Fewer than two inference sites: no recombination possible" )
@@ -1261,7 +1274,7 @@ def __init__(
12611274 f"mean={ np .mean (mismatch ):.5g} "
12621275 )
12631276 logger .info (
1264- f"Matching using { precision } digits of precision in likelihood calcs "
1277+ f"Matching using likelihood_threshold of { likelihood_threshold :.5g } "
12651278 )
12661279
12671280 if engine == constants .C_ENGINE :
@@ -1303,7 +1316,7 @@ def __init__(
13031316 self .tree_sequence_builder ,
13041317 recombination = self .recombination ,
13051318 mismatch = self .mismatch ,
1306- precision = precision ,
1319+ likelihood_threshold = likelihood_threshold ,
13071320 extended_checks = self .extended_checks ,
13081321 )
13091322 for _ in range (num_threads )
0 commit comments