Hi,
I am trying to test for pairwise associations between genotypes (
Rows=individuals, Columns =genes, data are up to 4 genotypes per gene, some
with 2,3 or 4) where each chisquare comparison is different depending on the
genes tested. The test is the observed multilocus (across columns for each
individual) genotypes vs the expectation, which is the product of the
individual frequency for each genotype times the total number of
individuals. Simple test.
I have set up a loop that pairs each gene together in a 2 column array, but
there are a number of different RxC tests based on how many genotypes (e.g.
2 genotypes vs 4 gives 8 cells, 2 by 2 gives you a 4 cell test etc.).
Instead of writing a series of if then statements for the chi-square test
on the obs-exp numbers for each possible gene pair (i've started to do
this....2x2, 2x3, 3x2, 2x4, 3x4,etc) is there a generic way to pass the
number of unique elements for each gene (which would define the number of
genotypes for that gene) into a calculation of the obs-exp and then the
chisquare test?
Here is some example code to illustrate what I am trying to work with.
###example dataset####
lets<-c("ac","ad","bc","bd")
epis<-cbind("m1"=sample(lets[1:3],25,
replace=TRUE),"m2"=sample(lets,25,replace=TRUE),"m3"=sample(lets[1:2],25,
replace=TRUE))
###the loop that binds all possible combinations of columns (genes)
pairwise###
for (i in 1:2){
for (j in (i+1):3){
epi2=cbind(epis[,i], epis[,j])
print(epi2)
}
}
Thanks in advance for any help.
Louis
[[alternative HTML version deleted]]