Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions gnomad/utils/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,14 +1312,17 @@ def _sum_or_diff_fields(

# Iterate through the groups and their freq lists to merge callstats.
callstat_ann = ["AC", "AN", "homozygote_count"]
callstat_ann_af = ["AC", "AF", "AN", "homozygote_count"]
new_freq = freq_meta_idx.map(
lambda x: hl.bind(
lambda y: y.annotate(AF=hl.if_else(y.AN > 0, y.AC / y.AN, 0)),
lambda y: y.annotate(AF=hl.if_else(y.AN > 0, y.AC / y.AN, 0)).select(
*callstat_ann_af
),
hl.fold(
lambda i, j: hl.struct(
**{ann: _sum_or_diff_fields(i[ann], j[ann]) for ann in callstat_ann}
),
x[0].select("AC", "AN", "homozygote_count"),
x[0].select(*callstat_ann),
x[1:],
),
)
Expand Down