I'm really new to R, so please bear with me. I'm using a chi-squared test to compare nucleotide frequencies at a given position, and I counted up the number of A,C,G,T in two different data sets:
x1 <- c(272003,310418,201601,237168)
x2 <- c(239614,316515,182070,198025)
I can think of two ways to ask for a two-sample chi-squared test:
> chisq.test(x1,x2)
Pearson's Chi-squared test
data: x1 and x2
X-squared = 12, df = 9, p-value = 0.2133
Warning message:
In chisq.test(x1, x2) : Chi-squared approximation may be incorrect
or
> chisq.test(cbind(x1,x2))
Pearson's Chi-squared test
data: cbind(x1, x2)
X-squared = 2942.065, df = 3, p-value < 2.2e-16
I suspect that the second version is correct, because I can also do this:
> chisq.test(x1,x1)
Pearson's Chi-squared test
data: x1 and x1
X-squared = 12, df = 9, p-value = 0.2133
Warning message:
In chisq.test(x1, x1) : Chi-squared approximation may be incorrect
with an identical and obviously incorrect result.
What is actually being calculated in this case?
Thanks!