HWPerm | R Documentation |
Function HWPerm
does a permutation test for Hardy-Weinberg
equilibrium using a user-supplied test statistic.
HWPerm(x, nperm = 17000, verbose = TRUE, x.linked = FALSE,
FUN = ifelse(x.linked,Chisquare.x,Chisquare), eps=1e-10, ...)
x |
A vector of genotype counts (AA,AB,BB) |
nperm |
The number of permutations |
verbose |
|
x.linked |
|
FUN |
An function call for calculating the test statistic for HWE (see examples below) |
eps |
Tolerance for comparison of floating point numbers (1e-10 by default) |
... |
Additional parameters for the function call argument |
The set of alleles for the observed sample is permuted. Consequently, the test is conditional on allele frequency.
HWPerm
returns a list with the components:
stat |
value of the chosen test statistic for the observed sample. |
pval |
p-value of the permutation test. |
Jan Graffelman jan.graffelman@upc.edu
Ziegler, A. & Konig, I.R. (2006) A statistical approach to genetic epidemiology. Wiley.
HWChisq
,HWExact
,HWLratio
x <- c(MM=298,MN=489,NN=213)
## Not run:
#
# use a default chi-square statistic
#
HW.test <- HWPerm(x,nperm=10000,verbose=TRUE)
#
# use a chi-square statistic with continuity correction.
#
HW.test <- HWPerm(x,nperm=10000,verbose=TRUE,
FUN=function(z) HWChisq(z,verbose=FALSE)$chisq,cc=0.5) #
#
# use a likelihood ratio statistic.
#
HW.test <- HWPerm(x,nperm=10000,verbose=TRUE,
FUN=function(y) HWLratio(y,verbose=FALSE)$G2)
#
# use an exact test p-value
#
HWPerm(x,nperm=10000,verbose=TRUE,FUN=function(y) 1-HWExact(y,verbose=FALSE)$pval)
#
#
# Permutation test for a marker on the X chromosome
#
rs5968922 <- c(A=392, B=212, AA=275, AB=296, BB=80)
HW.test <- HWPerm(rs5968922,nperm=10000,x.linked=TRUE,verbose=TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.