4
$\begingroup$

I have 7000 2x4 contingency tables with count data. They represent a particular position in a genome and the number of times each dna nucleotide is observed at that position in 2 different environments. an example contingency table would be

position X  A      C      G      T 
condition1  0      2      20     70000
condition2  3      15     0      95000

or
position Y  A      C     G       T 
condition1  80146  0     5       0
condition2  26821  2     4       0

The data can only be positive integers. Minimum counts are 0 and maximum can be >150,000. One count is generally nearly all of the total counts for that row and column (e.g. the same in both conditions, for example cell T in the first case above and cell A in the second), and then 1 or 2 other cells will have low counts... it is in these other cells where the difference, if any, should be observed.

The goal is to identify the positions which are significantly different between these 2 environmental conditions to further analyze. Our measurement method is estimated to have an error rate of 10^-6.

Problems/doubts I have:

  1. I cannot do a fisher's test on numbers this large using a 2x4 table. I can run the 2x2 table but its lots of tests so its a big correction for multiple testing AND the result seems to be influenced by total sum of the row (for example, condition2 may have generally lower total counts), which is something about the fisher test I don't understand.

2.I am getting a warning from the chi square test using R that the Chi-squared approximation may be incorrect and I am not sure about this test when there are cells with small or 0 values.

Any suggestions on what test would be good in this case? I am using R to do all the stats.

Thanks in advance,

Ron

$\endgroup$
1
$\begingroup$

It's not the observed values that R is generating the objection to, but the expected values; it's possible to have a mix of high and low observed without triggering that warning.

Note that one possibility is to simulate the distribution of the chi-square statistic (i.e. fix the margins and randomly generate tables from the set of tables with the same margin).

(R will do that automatically with the argument simulate.p.value=TRUE, though you'll very likely also want to increase the value of B - the number of simulations - from the default value as well, since the lowest p-value estimate possible is 1/B)

In addition, it appears you have the possibility of some columns being all-zero. Your best bet would be to drop the offending column from the calculation when that happens.

$\endgroup$
  • $\begingroup$ What is a reasonable B value? I will give it a try with higher B and drop the empty columns. $\endgroup$ – Ron Sep 14 '14 at 16:42
  • $\begingroup$ It depends on your needs (if you don't care much about accurately rendering very small p-values, it doesn't matter much if you don't increase it much, but I expect with so many tests and numbers like that you might actually care about accuracy with pretty small values) as well as how much time you have to spare. I wouldn't do it with less than 10000 in any case, but if you can afford the time to do more, do more. How many more depends on how far down you need how much accuracy. If you only care to see when $p<.05$ then 2000 might almost be enough (that gets an estimated p-value $\pm$ 0.01). $\endgroup$ – Glen_b Sep 14 '14 at 17:06
  • $\begingroup$ One more question... are zeros non-informative for fisher's or chi square, to where its ok to drop columns that are all zero (is a zero when the total count is 50,000 equivalent to a zero in the other condition where the total count is 10,000) ? This is surprising to me. $\endgroup$ – Ron Sep 15 '14 at 17:02
  • $\begingroup$ I suspect we're talking at cross purposes. I'm referring to cases where all the expected counts in a column are zero (which happens when all observed's are zero, unless I misunderstand your situation). In such cases $(O-E)^2/E$ is undefined. The effect of collapsing a column into an another column is the same as dropping the column. What other actions could be taken? $\endgroup$ – Glen_b Sep 15 '14 at 22:39
  • $\begingroup$ To respond to the part about Fisher's test: since you condition on the margins, a column with all-zeros will be certain to be all-zeros in every other table with the same margins, so it shouldn't affect the relative probabilities of the tables to drop it from the beginning; it may make it a bit faster to compute and otherwise does no harm to drop it. But for the chi-square you can't keep the all-zeros columns in as is. $\endgroup$ – Glen_b Sep 15 '14 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.