Skip to content

Commit

Permalink
[hail][bugfix] Fix divide by zero error in hl.concordance (#7976)
Browse files Browse the repository at this point in the history
Fixes #7974
  • Loading branch information
tpoterba authored and danking committed Jan 27, 2020
1 parent 27f99ce commit bea829d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hail/python/hail/methods/qc.py
Expand Up @@ -459,7 +459,8 @@ def n_discordant(counter):
total_conc = [x[1:] for x in glob[1:]]
on_diag = sum(total_conc[i][i] for i in range(len(total_conc)))
total_obs = sum(sum(x) for x in total_conc)
info(f"concordance: total concordance {on_diag/total_obs * 100:.2f}%")
pct = on_diag/total_obs * 100 if total_obs > 0 else float('nan')
info(f"concordance: total concordance {pct:.2f}%")

per_variant = joined.annotate_rows(concordance=aggr)
per_variant = per_variant.select_rows(concordance=concordance_array(per_variant.concordance),
Expand Down
7 changes: 7 additions & 0 deletions hail/python/test/hail/methods/test_qc.py
Expand Up @@ -212,6 +212,13 @@ def make_mt(rows):
n_discordant=0),
]

def test_concordance_no_values_doesnt_error(self):
dataset = get_dataset().filter_rows(False)
_, cols_conc, rows_conc = hl.concordance(dataset, dataset)
cols_conc._force_count()
rows_conc._force_count()


def test_filter_alleles(self):
# poor man's Gen
paths = [resource('sample.vcf'),
Expand Down

0 comments on commit bea829d

Please sign in to comment.