Chi Square Test
Dear Biostars,
I have two populations, POP1 and POP2. Each with 6 samples. Each sample having a number of variants as given in column POP1 and POP2 in below table. I want to calculate p-value for each sample.
No. of Variants
No. of Samples POP1 POP2 P-value (chi-square)
1 50 67 ?
2 47 62 ?
3 50 70 ?
4 2 6 ?
5 17 17 ?
6 38 55 ?
• 915 views
•
link
1 answer
There are countless ways to compute a ChiSquare value, what is more, important is to compute the correct value (the one that captures the hypothesis that you wish to make). Assuming that what you want is that the expected frequencies should be equal and where each sample is independent you could do it in Python like so (and you can do it much simpler in R)
from scipy.stats import chisquare
data = [
(50, 67),
(47, 62),
(50, 70),
(2, 6),
(17, 17),
(38, 55),
]
for vals in data:
res = chisquare(vals)
print (vals, res.pvalue
)
will print:
(50, 67) 0.11603161487098193
(47, 62) 0.15079204729985687
(50, 70) 0.06788915486182893
(2, 6) 0.15729920705028105
(17, 17) 1.0
(38, 55) 0.07793121061256247
I am providing this answer primarily as a closure to an otherwise slightly off topic post.
• 0 views
•
link
Log in to answer this question.