-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge freq array function and new frequency dictionary builder #551
Conversation
Fix incorrect formatting
Correcting incorrect formatting again...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple suggestions
gnomad/utils/annotations.py
Outdated
AC=hl.case() | ||
.when(set_negatives_to_zero, hl.max(x.AC, 0)) | ||
.or_error(negative_value_error_msg), | ||
AN=hl.case() | ||
.when(set_negatives_to_zero, hl.max(x.AN, 0)) | ||
.or_error(negative_value_error_msg), | ||
homozygote_count=hl.case() | ||
.when(set_negatives_to_zero, hl.max(x.homozygote_count, 0)) | ||
.or_error(negative_value_error_msg), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**{
ann: hl.case()
.when(set_negatives_to_zero, hl.max(x[ann], 0))
.or_error(negative_value_error_msg)
for ann in callstat_ann
}
Co-authored-by: jkgoodrich <33063077+jkgoodrich@users.noreply.github.com>
gnomad/utils/annotations.py
Outdated
@@ -1106,7 +1108,7 @@ def region_flag_expr( | |||
:return: `region_flag` struct row annotation | |||
""" | |||
prob_flags_expr = ( | |||
{"non_par": (t.locus.in_x_nonpar() | t.locus.in_y_nonpar())} if non_par else {} | |||
{"non_par": t.locus.in_x_nonpar() | t.locus.in_y_nonpar()} if non_par else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to stop black from doing this...this format "correction" will not work with hail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh really? I didn't realize hail doesn't like that. Maybe add # fmt: skip
to the end of it?
Back to you @jkgoodrich ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more things
gnomad/utils/annotations.py
Outdated
@@ -1106,7 +1108,7 @@ def region_flag_expr( | |||
:return: `region_flag` struct row annotation | |||
""" | |||
prob_flags_expr = ( | |||
{"non_par": (t.locus.in_x_nonpar() | t.locus.in_y_nonpar())} if non_par else {} | |||
{"non_par": t.locus.in_x_nonpar() | t.locus.in_y_nonpar()} if non_par else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh really? I didn't realize hail doesn't like that. Maybe add # fmt: skip
to the end of it?
gnomad/utils/annotations.py
Outdated
:param fmeta: List of frequency metadata for arrays being merged. | ||
:param operation: Merge operation to perform. Options are "sum" and "diff". If "diff" is passed, the first freq array in the list will have the other arrays subtracted from it. | ||
:param set_negatives_to_zero: If True, set negative array values to 0 for AC, AN, AF, and homozygote_count. If False, raise a ValueError. Default is True. | ||
:return: Tuple of merged frequency array and its freq index dictionary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the freq meta list no instead of freq index dictionary right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😶🌫️
Co-authored-by: jkgoodrich <33063077+jkgoodrich@users.noreply.github.com>
@@ -1106,7 +1108,8 @@ def region_flag_expr( | |||
:return: `region_flag` struct row annotation | |||
""" | |||
prob_flags_expr = ( | |||
{"non_par": (t.locus.in_x_nonpar() | t.locus.in_y_nonpar())} if non_par else {} | |||
{"non_par": (t.locus.in_x_nonpar() | t.locus.in_y_nonpar()) | |||
} if non_par else {} # fmt: skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha the extra note made the line long enough that black wants parentheses there now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh boy. I'm surprised it was even removing the parentheses, mine doesn't do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -1106,7 +1108,8 @@ def region_flag_expr( | |||
:return: `region_flag` struct row annotation | |||
""" | |||
prob_flags_expr = ( | |||
{"non_par": (t.locus.in_x_nonpar() | t.locus.in_y_nonpar())} if non_par else {} | |||
{"non_par": (t.locus.in_x_nonpar() | t.locus.in_y_nonpar()) | |||
} if non_par else {} # fmt: skip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh boy. I'm surprised it was even removing the parentheses, mine doesn't do that
This adds the ability to merge multiple frequency arrays that are on the same table. The merge supports addition or subtraction of arrays. For subtraction, all freq arrays are subtracted from the first freq array in the list. This also adds a new function to build frequency array dictionaries from the frequency metadata.