Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

HWPerm

Permutation test for Hardy-Weinberg equilibrium


Description

Function HWPerm does a permutation test for Hardy-Weinberg equilibrium using a user-supplied test statistic.

Usage

HWPerm(x, nperm = 17000, verbose = TRUE, x.linked = FALSE,
FUN = ifelse(x.linked,Chisquare.x,Chisquare), eps=1e-10, ...)

Arguments

x

A vector of genotype counts (AA,AB,BB)

nperm

The number of permutations

verbose

verbose = TRUE will print results, verbose = FALSE is silent.

x.linked

x.linked=FALSE indicates the marker is autosomal (default), and x.linked=TRUE indicates it resides on the X-chromosome.

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 FUN

Details

The set of alleles for the observed sample is permuted. Consequently, the test is conditional on allele frequency.

Value

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.

Author(s)

Jan Graffelman jan.graffelman@upc.edu

References

Ziegler, A. & K\"onig, I.R. (2006) A statistical approach to genetic epidemiology. Wiley.

See Also

Examples

x <- c(MM=298,MN=489,NN=213)
## Not run: 
HW.test <- HWPerm(x,nperm=10000,verbose=TRUE) # uses default chi-square statistic
HW.test <- HWPerm(x,nperm=10000,verbose=TRUE,function(z)
HWChisq(z)$chisq,cc=0.5) # uses chi-square statistic with continuity correction.
HW.test <- HWPerm(x,nperm=10000,verbose=TRUE,function(y) HWLratio(y)$G2)
# uses likelihood ratio statistic.
HWPerm(x,nperm=10000,verbose=TRUE,function(y) 1-HWExact(y)$pval)
# uses exact test p-value
#
# 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)

HardyWeinberg

Statistical Tests and Graphics for Hardy-Weinberg Equilibrium

v1.7.2
GPL (>= 2)
Authors
Jan Graffelman [aut, cre], Christopher Chang [ctb], Xavi Puig [ctb], Jan Wigginton [ctb], Leonardo Ortoleva [ctb], William R. Engels [ctb]
Initial release
2021-04-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.