autumnrustle
autumnrustle

Reputation: 663

Differences between two groups in molecular genetic

Usually I have some variable in 3 conditions in 2 groups. How can I find, is there are any statistic differences between this two groups?

For example short csv:

genotype,group,gene
5g/5g,1,PAI
5g/5g,1,PAI
4g/5g,1,PAI
4g/5g,1,PAI
4g/5g,1,PAI
4g/5g,1,PAI
5g/5g,1,PAI
4g/4g,1,PAI
4g/4g,1,PAI
4g/4g,2,PAI
4g/5g,2,PAI
4g/4g,2,PAI
4g/4g,2,PAI
4g/4g,2,PAI
4g/5g,2,PAI
5g/5g,2,PAI
4g/4g,2,PAI
5g/5g,2,PAI
5g/5g,2,PAI
5g/5g,2,PAI
4g/5g,2,PAI

gene PAI have 3 genotypes: 5g/5g, 4g/5g and 4g/4g.

If present this data in table format:

enter image description here

So, how can I find one p-value like there - picture below? picture below

Upvotes: 0

Views: 108

Answers (1)

Matt Tyers
Matt Tyers

Reputation: 2215

Might this be what you're looking for?

## simulating some data
df <- data.frame(genotype=sample(c("5g/5g","4g/5g","4g/4g"),16,replace=T), group=c(rep(1,8), rep(2,8)))

df
##    genotype group
## 1     4g/5g     1
## 2     4g/5g     1
## 3     4g/5g     1
## 4     5g/5g     1
## 5     5g/5g     1
## 6     4g/4g     1
## 7     4g/4g     1
## 8     4g/5g     1
## 9     4g/4g     2
## 10    4g/4g     2
## 11    4g/4g     2
## 12    4g/5g     2
## 13    5g/5g     2
## 14    5g/5g     2
## 15    4g/5g     2
## 16    4g/4g     2

## first a table
with(df, table(group, genotype))
##      genotype
## group 4g/4g 4g/5g 5g/5g
##     1     2     4     2
##     2     4     2     2

## and maybe a chi-squared test is what you want?
with(df, chisq.test(table(group,genotype)))
##    Pearson's Chi-squared test

## data:  table(group, genotype)
## X-squared = 1.3333, df = 2, p-value = 0.5134

Note that this isn't with your real data, but you could do the same thing.

Upvotes: 1

Related Questions