Learn R Programming

DEMEtics (version 0.8.1)

Hardy.Weinberg: Test for Hardy Weinberg Equilibrium (HWE)

Description

This function investigates if all sampled populations are in HWE for a given locus. Thereby, for each of these populations, the numbers of genotypes that were found empirically are compared to the ones that are expected under HWE using a Chi-square test.

Usage

Hardy.Weinberg(tab2, l)

Arguments

tab2
A list of tables containing the inputdata which are splitted according to the different loci and ordered alphabetically. The data table that has to be splitted equals the output of the function inputformat
l
(Lower-case character l). A number that equals the place of the locus that has to be investigated in the alphabetical order of all loci included in table 'tab2'.

Value

  • HWE, the object returned, is a logical value. It is assigned to the workspace (.GlobalEnv). If HWE = 'TRUE', all populations are in HWE for the actual locus. If HWE = 'FALSE', at least one of the populations is not in HWE for the actual locus.

Details

Based on the different alleles that were found for the actual locus, the empirical frequency of each allele and the empirical number of each possible genotype are calculated. If p is the frequency of one allele and q the frequency of another allele, then the frequencies of the several genotypes that are expected under HWE are calculated by p squared for homozygotes and by 2xpxq for heterozygotes. The estimated numbers of genotypes are obtained by multiplying the number of sampled individuals by the genotype frequencies. Finally, the empirical numbers of genotypes and those expected under HWE are compared using the function chisq.test with the arguments: simulate.p.value=TRUE, b=10000. This means, that the p-value is obtained from a Monte Carlo method with 10000-fold resampling. The null hypothesis of HWE is rejected when p < 0.05.

See Also

Bootstrapping.Dest, chisq.test, all.pops.D, all.pops.Dest, all.pops.Dest.Chao, all.pops.Gst, all.pops.Gst.est, pair.pops.D, pair.pops.Dest, pair.pops.Dest.Chao, pair.pops.Gst, pair.pops.Gst.est

Examples

Run this code
data(Example.transformed)
Example1 <- Example.transformed
tab2 <- split(Example1,Example1$locus)

Hardy.Weinberg(tab2,1)
HWE

Hardy.Weinberg(tab2,2)
HWE

Run the code above in your browser using DataLab