Skip to content

Commit

Permalink
Modify how to classify transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Jul 3, 2024
1 parent 9d8132b commit 61406a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lshmm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@ def get_emission_matrix_haploid_tstv(mu, kappa=None):
np.zeros((num_sites, num_alleles, num_alleles), dtype=np.float64) - 1
)

# Define transitions: A <-> G and C <-> T.
transitions = [(0, 2), (2, 0), (1, 3), (3, 1)]

for i in range(num_sites):
for j in range(num_alleles):
for k in range(num_alleles):
Expand All @@ -346,7 +343,10 @@ def get_emission_matrix_haploid_tstv(mu, kappa=None):
else:
mu_over_two_plus_kappa = mu[i] / (2.0 + kappa)
emission_matrix[i, j, k] = mu_over_two_plus_kappa
if (j, k) in transitions:
# Transitions: A <-> G and C <-> T.
is_transition_AG = j in [0, 2] and k in [0, 2]
is_transition_CT = j in [1, 3] and k in [1, 3]
if is_transition_AG or is_transition_CT:
emission_matrix[i, j, k] *= kappa

row_sum = np.sum(emission_matrix[i, j, :])
Expand Down

0 comments on commit 61406a5

Please sign in to comment.