From: Louis Plough <lplough_at_usc.edu>

Date: Fri, 22 Apr 2011 09:31:56 -0700

*}
*

*}
*

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 22 Apr 2011 - 16:33:51 GMT

Date: Fri, 22 Apr 2011 09:31:56 -0700

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]]

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 22 Apr 2011 - 16:33:51 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Fri 22 Apr 2011 - 17:10:32 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*