Skip to content
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

Add generic constraint functions: oe_aggregation_expr(), compute_pli(), oe_confidence_interval(), calculate_raw_z_score(), calculate_raw_z_score_sd() #505

Merged
merged 44 commits into from
Apr 14, 2023

Conversation

averywpx
Copy link
Contributor

@averywpx averywpx commented Nov 9, 2022

Add generic constraint functions used to compute constraint metrics.

@averywpx averywpx requested a review from klaricch November 9, 2022 21:32
@averywpx averywpx self-assigned this Nov 9, 2022
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
averywpx and others added 2 commits November 29, 2022 10:31
Co-authored-by: klaricch <kristen@broadinstitute.org>
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
:param prefix: Prefix of upper and lower bounds, defaults to 'oe'.
:param alpha: The significance level used to compute the confidence interval.
Default is 0.05.
:param select_only_ci_metrics: Whether to return only upper and lower bounds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will we ever need this to be false or can we just remove this?

gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved

:param ht: Input Table with pLoF variants, missense variants, or synonymous
variants.
:param annotation_name: Annotation name used for constraint metrics to distinguish
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe should provide some examples here

gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
Comment on lines 895 to 896
over a range of lambda (`lamb` in `dpois`) values, which are given by the expected
number of variants times a varying parameter ranging between 0 and 2. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why between 0 and 2?

"""
ht = ht.annotate(_obs=obs, _exp=exp)
# Set up range between 0 and 2.
oe_ht = ht.annotate(_range=hl.range(0, 2000).map(lambda x: hl.float64(x) / 1000))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be parameters, why 1000?

oe_ht = oe_ht.transmute(
**{
f"{prefix}_lower": hl.if_else(
oe_ht._obs > 0, oe_ht._range[oe_ht._lower_idx], 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to docstring that we cut this off

gnomad/utils/constraint.py Outdated Show resolved Hide resolved
jkgoodrich and others added 3 commits March 3, 2023 15:46
Co-authored-by: klaricch <kristen@broadinstitute.org>
… into constraint_finalize_datasets

� Conflicts:
�	gnomad/utils/constraint.py
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
Co-authored-by: klaricch <kristen@broadinstitute.org>
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
gnomad/utils/constraint.py Outdated Show resolved Hide resolved
…ets_jkg

Suggested changes to the Add generic constraint functions: compute_oe_per_transcript(), compute_all_pLI_scores(), pLI(), oe_confidence_interval(), calculate_z(), calculate_z_scores() PR
Copy link
Contributor

@jkgoodrich jkgoodrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@jkgoodrich jkgoodrich changed the title Add generic constraint functions: compute_oe_per_transcript(), compute_all_pLI_scores(), pLI(), oe_confidence_interval(), calculate_z(), calculate_z_scores() Add generic constraint functions: oe_aggregation_expr(), compute_pli(), oe_confidence_interval(), calculate_raw_z_score(), calculate_raw_z_score_sd() Apr 14, 2023
@jkgoodrich jkgoodrich merged commit b30165f into main Apr 14, 2023
@jkgoodrich jkgoodrich deleted the constraint_finalize_datasets branch April 14, 2023 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants