Skip to content

Instantly share code, notes, and snippets.

@andreas-wilm
Created November 18, 2015 09:10
Show Gist options
  • Save andreas-wilm/8382586743c6abd8ac60 to your computer and use it in GitHub Desktop.
Save andreas-wilm/8382586743c6abd8ac60 to your computer and use it in GitHub Desktop.
Fisher's method for combining p-values
from math import log
from scipy import stats
def fisher_comb(pv1, pv2):
"""
Fisher's method for combining p-values:
https://en.wikipedia.org/wiki/Fisher's_method
See for example breseq-0.18b:polymorphism_statistics.r
For CDF use see http://stackoverflow.com/questions/11725115/p-value-from-chi-sq-test-statistic-in-python
"""
comb_log = -2.0 * (log(pv1) + log(pv2))
comb_pv = 1.0 - stats.chi2.cdf(comb_log, 4)
return comb_pv
@andreas-wilm
Copy link
Author

  • This function is limited to two pvalues
  • just use scipy.stats.combine_pvalues()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment