Hl.agg.fraction missing values question

Hi hail team,

I’m running this code:

intervals_ht = intervals_ht.annotate(_interval_key=intervals_ht.key)
callrate_mt = callrate_mt.annotate_rows(**intervals_ht[callrate_mt.locus]._interval_key)
callrate_mt = callrate_mt.filter_rows(hl.is_defined(callrate_mt.interval))
callrate_mt = callrate_mt.select_entries(GT_not_called=hl.or_missing(hl.is_missing(callrate_mt.GT), hl.struct()))
callrate_mt = callrate_mt.group_rows_by(*list(intervals_ht.key)).aggregate(callrate=hl.agg.fraction(hl.is_missing(callrate_mt.GT_not_called)))
intervals_ht = intervals_ht.drop('_interval_key')
callrate_mt = callrate_mt.annotate_rows(interval_info=hl.struct(**intervals_ht[callrate_mt.row_key]))

When I try to plot callrate, I get this error:

Error summary: HailException: 'hist': start=1.00000e+00 end=1.00000e+00 bins=50 requires positive bin size.

Changing the definition of callrate to

callrate_mt = callrate_mt.group_rows_by(*list(interval_ht.key)).aggregate(callrate=hl.agg.count_where(
    hl.is_missing(callrate_mt.GT_not_called)) / callrate_mt.count_rows())

produces a normal plot. Why does fraction have different behavior from the aggregation in this case?

Did you use filter_entries upstream? This removes the entire entry from the matrix table – so it won’t be included in aggregation. See the full doc here: https://hail.is/docs/0.2/hail.MatrixTable.html#hail.MatrixTable.filter_entries

Let me know if this doesn’t answer the question