NewUsr_stat
NewUsr_stat

Reputation: 2583

prop.test on single observations

I have a situation like this: I produced 1000 random lists (here only 4 random lists are reported) composed of genes. I checked how many genes in this lists are mutated. Here the mutated genes are reported in the column Mutated_genes. It is simply a count. The expected is p = 0.02 (p column).

DFR

Mutated_genes    Tot         p
      29         1600        0.02
      27         1600        0.02
      30         1600        0.02
      8          1600        0.02

I would like to perform a chi squared test. To do that I used the following code:

prop.test(DFR$Mutated_genes, p = DFR$p, DFR$Tot, alternative="two.sided", conf.level=.99)

The problem is that it performs chi.squared on the entire matrix. As a matter of fact the output is:

X-squared = 10009.67, df = 1000, p-value < 2.2e-16
alternative hypothesis: two.sided

I would like to have the chi squared value for each row, so for each observation. How this can be done?

Thanks in advance.

Upvotes: 2

Views: 250

Answers (1)

Ali
Ali

Reputation: 9850

Try this:

apply(DFR$Mutated_genes, 1, function(x) prop.test(x[1], p = x[3], x[2], 
      alternative="two.sided", conf.level=.99))

I hope this works good.

Upvotes: 1

Related Questions