# Hl.agg.fraction missing values question

**URL:** <https://discuss.hail.is/t/hl-agg-fraction-missing-values-question/1099>\
**Category:** Hail Query & hailctl\
**Created:** [September 27, 2019, 2:06pm UTC](https://discuss.hail.is/t/hl-agg-fraction-missing-values-question/1099 "2019-09-27T14:06:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ch-kr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/ch-kr/32/317_2.png) [@ch-kr](https://discuss.hail.is/u/ch-kr)\
**Post date:** [September 27, 2019, 2:06pm UTC](https://discuss.hail.is/t/hl-agg-fraction-missing-values-question/1099/1 "2019-09-27T14:06:20Z")

</div>

Hi hail team,

I’m running this code:

```auto
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:

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

```

Changing the definition of `callrate` to

```auto
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?

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [September 27, 2019, 2:09pm UTC](https://discuss.hail.is/t/hl-agg-fraction-missing-values-question/1099/2 "2019-09-27T14:09:24Z")

</div>

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](https://hail.is/docs/0.2/hail.MatrixTable.html#hail.MatrixTable.filter_entries)

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [September 27, 2019, 2:09pm UTC](https://discuss.hail.is/t/hl-agg-fraction-missing-values-question/1099/3 "2019-09-27T14:09:35Z")

</div>

Let me know if this doesn’t answer the question
