Dear All, I am trying to calculate the Hardy-Weinberg Equilibrium p-value for 42 SNPs. I am using the function HWE.exact from the package "genetics".
In order not to do a lot of coding "by hand", I have a for loop that goes through each column (each column is one SNP) and gives me the p.value for HWE.exact. Unfortunately some SNP have reached fixation and HWE.exact requires a 2 alleles scenario. So my problem is that my for loop: ################################################## for (i in 1:42){ xxx<-HWE.exact(genotype(laba.con[,i+3], sep="")) cat(colnames(laba)[i+3],xxx$p.value,"\n")} ################################################## bails out as soon as it hits a SNP at fixation for one allele, because HWE.exact fails. I have a lot of this game to play and checking things by hand is not idea, and I do not care about failed SNP, all I want is for the loop to carry on regardless of what's in xxx$p.value, even if HWE.exact failed to calculte it. Dump anything in there! Is there any way of forcing the loop to carry on? Cheers, Federico Calboli -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.com ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html