Skip to content

Conversation

@patrick-schultz
Copy link
Member

Change Description

Add a flag _pvalue_only to fisher_exact_test. This makes the result struct only contain the pvalue, and uses an optimized method in that case. I've left the flag underscored and undocumented for now, as ideally the PruneDeadFields pass should be able to recognize when only the pvalue field is used, and switch to the optimized implementation. However, that would need some nontrivial changes to PruneDeadFields.

The motivation for this is for use cases calling fisher_exact_test inside a loop performing a permutation test, where this might run 100k to 1m times per row.

The optimized implementation is inspired by SciPy, see https://github.com/scipy/scipy/blob/v1.16.2/scipy/stats/_stats_py.py#L5055. I've also added some extra tests to be sure of the correctness of the new algorithm, including copying test cases from SciPy.

Security Assessment

  • This change cannot impact the Hail Batch instance as deployed by Broad Institute in GCP

@patrick-schultz patrick-schultz changed the title Add fisher_exact_test pvalue_only [query] Add fisher_exact_test pvalue_only Sep 12, 2025
@patrick-schultz patrick-schultz force-pushed the ps/push-yyslnqmryskq branch 2 times, most recently from beeb4ff to 0abf732 Compare September 12, 2025 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants