Skip to content

Commit 017edd2

Browse files
committed
Remove minimum denominator for weight calculations
1 parent 3c6a546 commit 017edd2

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

python/tests/beagle.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ def get_weights(genotyped_pos, ungenotyped_pos, genetic_map=None):
8080
m = len(genotyped_pos)
8181
x = len(ungenotyped_pos)
8282
assert len(np.union1d(genotyped_pos, ungenotyped_pos)) == m + x
83-
# Set min genetic distance.
84-
MIN_CM_DIST = 0.005
8583
if genetic_map is None:
8684
genotyped_cm = convert_to_genetic_map_position(genotyped_pos)
8785
ungenotyped_cm = convert_to_genetic_map_position(ungenotyped_pos)
@@ -105,7 +103,8 @@ def get_weights(genotyped_pos, ungenotyped_pos, genetic_map=None):
105103
# Ungenotyped marker is between genotyped markers k and k + 1.
106104
k = np.max(np.where(ungenotyped_pos[i] > genotyped_pos)[0]) # Inefficient
107105
cm_mP1_x = genotyped_cm[k + 1] - ungenotyped_cm[i]
108-
cm_mP1_m = np.max([genotyped_cm[k + 1] - genotyped_cm[k], MIN_CM_DIST])
106+
cm_mP1_m = genotyped_cm[k + 1] - genotyped_cm[k]
107+
assert cm_mP1_m > 0, "Division by zero in weight calculation."
109108
weights[i] = cm_mP1_x / cm_mP1_m
110109
marker_interval_start[i] = k
111110
assert 0 <= np.min(weights)

python/tests/beagle_numba.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def get_weights(genotyped_pos, ungenotyped_pos, genotyped_cm, ungenotyped_cm):
4646
:return: Weights and marker interval start indices.
4747
:rtype: tuple(numpy.ndarray, numpy.ndarray)
4848
"""
49-
_MIN_CM = 0.005
5049
m = len(genotyped_pos)
5150
x = len(ungenotyped_pos)
5251
# Calculate weights for ungenotyped markers.
@@ -67,9 +66,7 @@ def get_weights(genotyped_pos, ungenotyped_pos, genotyped_cm, ungenotyped_cm):
6766
else:
6867
# Between two genotyped markers.
6968
cm_mP1_x = genotyped_cm[idx_m + 1] - ungenotyped_cm[idx_x]
70-
cm_mP1_m = max(
71-
genotyped_cm[idx_m + 1] - genotyped_cm[idx_m], _MIN_CM
72-
) # Set min.
69+
cm_mP1_m = genotyped_cm[idx_m + 1] - genotyped_cm[idx_m]
7370
weights[idx_x] = cm_mP1_x / cm_mP1_m
7471
marker_interval_start[idx_x] = idx_m
7572
return (weights, marker_interval_start)

0 commit comments

Comments
 (0)