X a vector containg the genotypic counts (AA,AB,BB for
autosomal markers c(A,B,AA,AB,BB) for X-chromosomal markers).
cc
cc the continuity correction parameter (default
cc = 0.5).
verbose
verbose = TRUE prints 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.
phifixed
(For X-chromosomal markers only)
phifixed=NULL indicates that the fraction of males
(females) should be estimated from the data (default). If set to any
other value (e.g. phifixed=0.5) then the sample is assumed to
come from a population with the specified fraction of males.
Details
HWChisq does a chi-square test for Hardy-Weinberg 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 chi-square test for both autosomal and
X-chrosomal markers. By setting x.linked = TRUE the marker
will be assumed to be on the X-chromosome, and the count vector
supplied should have 5 elements instead of 3 elements for an
autosomal marker. For X-chromsomal 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.
When alternative is set to less, a one-sided test for
against a negative inbreeding coefficient (heterozygote excess) is
performed. When alternative is set to greater a one-sided test for
against a positive inbreeding coefficient (lack of heterozygotes) is
performed.
Value
HWChisq returns a list with the components:
chisq
value of the chi-square statistic. NA is returned if the marker is monomorphic.
pval
p-value of the chi-square test for Hardy-Weinberg equilibrium.
D
Half the deviation from Hardy-Weinberg equilibrium for the AB genotype.
Weir, B.S. (1996) Genetic data analysis II. Sinauer
Associates, Massachusetts. See Chapter3.
See Also
HWLratio, HWChisqStats
Examples
#
# 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 X-chromsomal SNP.
#
rs5968922 <- c(A=392, B=212, AA=275, AB=296, BB=80)
HW.test <- HWChisq(rs5968922,cc=0,x.linked=TRUE,verbose=TRUE)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(HardyWeinberg)
Loading required package: mice
Loading required package: Rcpp
mice 2.25 2015-11-09
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HardyWeinberg/HWChisq.Rd_%03d_medium.png", width=480, height=480)
> ### Name: HWChisq
> ### Title: Chi square tests for Hardy Weinberg equilibrium
> ### Aliases: HWChisq
> ### Keywords: htest
>
> ### ** Examples
>
> #
> # Test for an autosomal blood group marker
> #
> x <- c(MM=298,MN=489,NN=213)
> HW.test <- HWChisq(x,verbose=TRUE)
Chi-square test with continuity correction for Hardy-Weinberg equilibrium (autosomal)
Chi2 = 0.1789563 DF = 1 p-value = 0.6722717 D = -3.69375 f = 0.01488253
> #
> # Same test without continuity correction
> #
> HW.test <- HWChisq(x,cc=0,verbose=TRUE)
Chi-square test for Hardy-Weinberg equilibrium (autosomal)
Chi2 = 0.2214896 DF = 1 p-value = 0.6379073 D = -3.69375 f = 0.01488253
> #
> # Test for an X-chromsomal SNP.
> #
> rs5968922 <- c(A=392, B=212, AA=275, AB=296, BB=80)
> HW.test <- HWChisq(rs5968922,cc=0,x.linked=TRUE,verbose=TRUE)
Chi-square test for Hardy-Weinberg equilibrium (X-chromosomal)
Chi2 = 0.00170001 DF = 2 p-value = 0.9991504 D = NA f = 0.0009953963
>
>
>
>
>
> dev.off()
null device
1
>