Skip to content

Commit

Permalink
add minimum number of iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
LaraFuhrmann committed Nov 26, 2024
1 parent 8dc0545 commit 987ab13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def haplotypes_to_fasta(state_curr_dict, output_dir):
ave_reads = state_curr_dict["weight" + str(k)]
if ave_reads==0:
# this haplotype will not be reported as there are no reads
# supporting it.
# supporting it.
continue

head = (
Expand Down
5 changes: 3 additions & 2 deletions viloca/local_haplotype_inference/use_quality_scores/cavi.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ def run_cavi(
iter = 0
converged = False
elbo = 0
min_number_iterations = 10
state_curr_dict = state_init_dict
while converged is False:
while (converged is False) or (iter < min_number_iterations):

if iter <= 1:
digamma_alpha_sum = digamma(state_curr_dict["alpha"].sum(axis=0))
Expand Down Expand Up @@ -155,7 +156,7 @@ def run_cavi(
break
elif (history_elbo[-2] > elbo) and np.abs(elbo - history_elbo[-2]) > 1e-08:
exit_message = "Error: ELBO is decreasing."
break
#break
elif np.abs(elbo - history_elbo[-2]) < convergence_threshold:
converged = True
exit_message = "ELBO converged."
Expand Down

0 comments on commit 987ab13

Please sign in to comment.