monarch-initiative / gpsea

A Python library for discovery of genotype-phenotype associations
https://monarch-initiative.github.io/gpsea/stable
MIT License
5 stars 1 forks source link

float division by zero #201

Closed pnrobinson closed 3 months ago

pnrobinson commented 4 months ago

After assembling a cohort and showing all the stats and pictures successfully, the following analysis has a bug

feature = analysis.compare_by_variant_key(variant_key="12_114385521_114385521_C_T")
feature.summarize(hpo, PatientCategories.YES)

this is the error:

# TODO: Check compare_by_variant_key parameters and/or variables
feature = analysis.compare_by_variant_key(variant_key="12_114385521_114385521_C_T")
feature.summarize(hpo, PatientCategories.YES)
-> [156](https://file+.vscode-resource.vscode-cdn.net/Users/robin/PycharmProjects/gpc-cs/notebooks/ACBD6/~/PycharmProjects/gpc-cs/gpcvenv/lib/python3.12/site-packages/statsmodels/stats/multitest.py:156) alphacSidak = 1 - np.power((1. - alphaf), 1./ntests)
    [157](https://file+.vscode-resource.vscode-cdn.net/Users/robin/PycharmProjects/gpc-cs/notebooks/ACBD6/~/PycharmProjects/gpc-cs/gpcvenv/lib/python3.12/site-packages/statsmodels/stats/multitest.py:157) alphacBonf = alphaf / float(ntests)
    [158](https://file+.vscode-resource.vscode-cdn.net/Users/robin/PycharmProjects/gpc-cs/notebooks/ACBD6/~/PycharmProjects/gpc-cs/gpcvenv/lib/python3.12/site-packages/statsmodels/stats/multitest.py:158) if method.lower() in ['b', 'bonf', 'bonferroni']:

ZeroDivisionError: float division by zero
lnrekerle commented 3 months ago

I recreated this bug and discovered that the variant you are testing is not in the cohort. I'm going to add an error that will be more clear why we are getting a division by 0 error (AKA- will get a valueError sooner stating that we can't test for a variant that is not in the cohort), let me know if we want any other error around this.

pnrobinson commented 3 months ago

definitely just a message that the variant is not in the cohort would be better. I never would have guess from the divide by zero message! thanks