pegas (version 0.12)

hw.test: Test of Hardy--Weinberg Equilibrium

Description

This function tests, for a series of loci, the hypothesis that genotype frequencies follow the Hardy--Weinberg equilibrium. hw.test is a generic with methods for the classes "loci" and '>genind. Note that the latter replaces HWE.test.genind in the adegenet package.

Usage

hw.test(x, B = 1000, …)
# S3 method for loci
hw.test(x, B = 1000, …)
# S3 method for genind
hw.test(x, B = 1000, …)

Arguments

x

an object of class "loci" or '>genind.

B

the number of replicates for the Monte Carlo procedure; for the regular HW test, set B = 0 (see details).

further arguments to be passed.

Value

A matrix with three or four columns with the \(\chi^2\)-value, the number of degrees of freedom, the associated P-value, and possibly the P-value from the Monte Carlo test. The rows of this matrix are the different loci in x.

Details

This test can be performed with any level of ploidy. Two versions of the test are available: the classical \(\chi^2\)-test based on the expected genotype frequencies calculated from the allelic frequencies, and an exact test based on Monte Carlo permutations of alleles (Guo and Thompson 1992). For the moment, the latter version is available only for diploids. Set B = 0 if you want to skip the second test.

References

Guo, S. W. and Thompson, E. A. (1992) Performing the exact test of Hardy--Weinberg proportion for multiple alleles. Biometrics, 48, 361--372.

Examples

Run this code
# NOT RUN {
require(adegenet)

## load data
data(nancycats)

## test on genind object, no permutation
hw.test(nancycats, B=0)

## test on loci object
x <- as.loci(nancycats)
hw.test(x)
# }
# NOT RUN {
data(jaguar)
hw.test(jaguar)
# }

Run the code above in your browser using DataCamp Workspace