Add option to make scans inclusive

Hi hail team!

Would it be possible to add an option to make scans inclusive?

With this toy example ht:

locus    transcript    observed
1:1    'test'    0
1:2    'test'    1
1:3    'test'    1
1:4    'test2'    1

if I run

ht = ht.annotate(obs_scan=hl.scan.group_by(ht.transcript, hl.scan.sum(ht.observed))

I’d get something like:

locus    transcript    observed    obs_scan
1:1    'test'    0    {}
1:2    'test'    1    {'test': 0}
1:3    'test'    1    {'test': 1}
1:4    'test2'    1   {'test': 2}

would it be possible to add a flag or something similar to make this scan inclusive? Something like:

ht = ht.annotate(obs_scan=hl.scan.group_by(ht.transcript, hl.scan.sum(ht.observed, inclusive=True))

which would produce:

locus    transcript    observed    obs_scan
1:1    'test'    0    {'test': 0}
1:2    'test'    1    {'test': 1}
1:3    'test'    1    {'test': 2}
1:4    'test2'    1   {'test': 2, 'test2': 1}

Thanks in advance!

It would be quite easy to make a change that makes all scans inclusive, but it’s not easy to mix and match inclusive and exclusive, unfortunately. It’s going to be hard to find time to make this change in the immediate future.

thanks for the context! no rush, just wanted to have the feature request logged somewhere :slight_smile: