HWChisq  R Documentation 
HWChisq
performs the chisquare test for HardyWeinberg
equilibrium both for autosomal and Xchromosomal markers; it can dealt both with biallelic and multiallelic variants.
HWChisq(X, cc = 0.5, verbose = TRUE, x.linked = FALSE, phifixed = NULL)
X 
For biallelic variants, 
cc 

verbose 

x.linked 

phifixed 
(For Xchromosomal markers only)

HWChisq
does a chisquare test for HardyWeinberg equilibrium,
and by default applies a continuity correction. For extreme allele
frequencies, the continuity correction can lead to excessive type 1
error rates, and is better turned off in that case. The continuity
correction can be turned off by specifying cc=0
.
HWChisq
can do the chisquare test for both autosomal and
Xchrosomal markers. By setting x.linked = TRUE
the marker
will be assumed to be on the Xchromosome, and the count vector
supplied should have 5 elements instead of 3 elements for an
autosomal marker. For Xchromsomal markers argument phifixed
is in general best left to its default value (NULL
). Only in
specific situations where the theoretical population sex ratio is known (e.g. in
simulation studies where a universe with known gender ratio is
sampled) phifixed
could be set to the theoretical ratio of interest.
With biallelic variants, when alternative
is set to less
, a onesided test for
against a negative inbreeding coefficient (heterozygote excess) is
performed. When alternative
is set to greater
a onesided test for
against a positive inbreeding coefficient (lack of heterozygotes) is
performed.
For multiallelic variants, which typically do have some rare alleles and rare genotypes, the asymptotic chisquare test is in
general not recommended, and exact test procedures or permutation tests are recommended (see HWExact
or HWPerm.mult
).
HWChisq
returns a list with the components:
chisq 
value of the chisquare statistic. NA is returned if the marker is monomorphic. 
pval 
pvalue of the chisquare test for HardyWeinberg equilibrium. 
D 
Half the deviation from HardyWeinberg equilibrium for the AB genotype. 
p 
the allele frequency of A. 
f 
the inbreeding coefficient. 
expected 
the expected counts under HardyWeinberg equilibrium. 
chi.contrib 
the contributions of the different genotypes to the chisquare statistic. 
Jan Graffelman jan.graffelman@upc.edu
Weir, B.S. (1996) Genetic data analysis II. Sinauer Associates, Massachusetts. See Chapter3.
For the chisquare test for Xlinked markers:
Graffelman, J. & Weir, B.S. (2016) Testing for HardyWeinberg equilibrium at biallelic genetic markers on the X chromosome. Heredity 116(6) pp. 558–568. doi: 10.1038/hdy.2016.20
HWLratio
, HWChisqStats
# # Test for an autosomal blood group marker # x < c(MM=298,MN=489,NN=213) HW.test < HWChisq(x,verbose=TRUE) # # Same test without continuity correction # HW.test < HWChisq(x,cc=0,verbose=TRUE) # # Test for an Xchromsomal SNP. # rs5968922 < c(A=392, B=212, AA=275, AB=296, BB=80) HW.test < HWChisq(rs5968922,cc=0,x.linked=TRUE,verbose=TRUE) # # Test a multiallelic microsatellite # data(NistSTRs) A1 < NistSTRs[,1] A2 < NistSTRs[,2] GC < AllelesToTriangular(A1,A2) HW.test < HWChisq(GC) # # retaining only the three most common alleles # ii < (A1 == 10  A1 == 11  A1 == 12) & (A2 == 10  A2 == 11  A2 == 12) A1s < A1[ii] A2s < A2[ii] GC < AllelesToTriangular(A1s,A2s) HW.test < HWChisq(GC)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.