Chi Square Test
1
0
Entering edit mode
3.1 years ago
Aftab • 0

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          ?               
ChiSquareTest • 572 views
ADD COMMENT
0
Entering edit mode
3.1 years ago

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.

ADD COMMENT

Login before adding your answer.

Traffic: 2011 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6