# combining p-values for averaging technical protein quantification replicates in python

I have some data about protein expression levels in a cell. For each identified protein, there is an expression level and an associated p-value indicating the confidence that the protein was identified correctly. Two of the samples were technical replicates (i.e. a single sample was split into two parts and analysed separately). I now need to average the expression levels of the two technical replicates, and their corresponding p-values. I thought to use Fisher's method to combine them, which seems to me like the right thing to do. The problem is that I need to convert the result from a $\chi^2$ value into a p-value. Excel has a CHIDIST function which seems to do the trick, but, since I'm likely to be doing this sort of thing a lot in the near future, I thought to write a script to do it to plug into our analysis pipeline. I'm using python to write it, but can't find an equivalent function to CHIDIST. I realize that the process is basically finding the probability of getting the given $\chi^2$ score, so I'd like to check my thinking.

1. Am I doing the right thing combining the p-values?
2. Is Fisher's Method the appropriate process for combining the p-values correct?
3. How many degrees of freedom? I'm thinking 2, as per the wikipedia page.
4. The final p-value is one minus the integral from negative infinity to the $\chi^2$ score over the $\chi^2$ probability density function with one degree of freedom.

Thanks

-
(1) Where does the one degree of freedom in (4) come from? (2) The complementary CDF for $\chi^2(2)$ is simply $x\to \exp(-x/2)$. –  whuber Jan 5 '12 at 13:31
With respect to Python and finding the analog to Excel's CHIDIST function, Scipy has what you need in the scipy.stats.chi2 class. For example, 1 - chi2.cdf(5, 3) = CHIDIST(5, 3) = 0.171797 –  Josh Hemann Jan 5 '12 at 14:53
@whuber, sorry the 1 was a typo, and the replacement (2) was a misreading of the formula for fisher's method. DF should be 2k where k is the number of tests combined (in my case 2), so it should be 4 –  sirlark Jan 5 '12 at 15:00
@JoshHemann, thanks, this is what I'm looking for. –  sirlark Jan 5 '12 at 15:01
With four df, Fisher's Method gives $p_1 p_2 (1 - \log(p_1 p_2))$. In general, for other (even) degrees of freedom, the result does not require calculating chi-squared distributions; it is a polynomial in the product of the $p_i$ and its logarithm. For $n$ tests, instead of 2, the formula is $x\sum_{k=0}^{n-1}(-\log(x))^k/k!$ for $x=p_1p_2\ldots p_n$. –  whuber Jan 5 '12 at 15:12
show 1 more comment