two.sided (default) will perform a two-sided
test where both an excess and a dearth of heterozygotes count as
evidence against HWE. less is a one-sided test where only
dearth of heterozygotes counts a evidence against HWE,
greater is a one-sided test where only excess of
heterozygotes counts as evidence against HWE.
pvaluetype
if pvaluetype is set to dost
then the p-value of a two-sided test is computed as twice the tail area
of a one-sided test. When set to selome, the p-value
is computed as the sum of the probabilities of all samples less or
equally likely as the current sample. When set to midp, the
p-value is computed as half the probability of the current sample +
the probabilities of all samples that are more extreme.
x.linked
x.linked=FALSE indicates the marker is
autosomal (default), and x.linked=TRUE indicates it resides
on the X-chromosome.
verbose
print results or not.
Details
HWExactPrevious uses the recursion equations described by Wigginton
et. al.
For large samples, HWExactPrevious may give the error message:
"evaluation nested too deeply: infinite recursion". This can usually
be resolved by increasing R's limit on nested expressions with
options(expressions=10000) or a higher limit. With higher
limits, the error message "protect(): protection stack overflow" can
occur. This error can usually be resolved by increasing R's
protection stack with the command line option
--max-ppsize 100000 or higer values. However, with such large
samples the exact test will give virtually the same result as a
chi-square test, and it may be easier to use HWChisq in these
circumstances.
Value
pval
p-value of the exact test
prob
probabilities of all possible samples with the same
sample size and minor allele count
pofthesample
probability of the observed sample
Author(s)
Jan Graffelman (jan.graffelman@upc.edu)
References
Weir, B.S. (1996) Genetic data analysis II. Sinauer
Associates, Massachusetts. See Chapter3.
Wigginton, J.E., Cutler, D.J. and Abecasis, G.R. (2005) A note on exact
tests of Hardy-Weinberg equilibrium, American Journal of Human
Genetics (76) pp. 887-893.
See Also
HWLratio, HWChisq
Examples
#
# Example autosomal marker
#
x <- c(298,489,213)
names(x) <- c("MM","MN","NN")
HW.test <- HWExactPrevious(x,verbose=TRUE)
#
# Example x-linked marker
#
rs5968922 <- c(A=392, B=212, AA=275, AB=296, BB=80 )
HWExactPrevious(rs5968922,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/HWExactPrevious.Rd_%03d_medium.png", width=480, height=480)
> ### Name: HWExactPrevious
> ### Title: Exact test for Hardy-Weinberg equilibrium
> ### Aliases: HWExactPrevious
> ### Keywords: htest
>
> ### ** Examples
>
> #
> # Example autosomal marker
> #
> x <- c(298,489,213)
> names(x) <- c("MM","MN","NN")
> HW.test <- HWExactPrevious(x,verbose=TRUE)
Haldane's Exact test for Hardy-Weinberg equilibrium
using SELOME p-value
sample counts: nMM = 298 nMN = 489 nNN = 213
H0: HWE (D==0), H1: D <> 0
D = -3.69375 p = 0.6556635
> #
> # Example x-linked marker
> #
> rs5968922 <- c(A=392, B=212, AA=275, AB=296, BB=80 )
> HWExactPrevious(rs5968922,x.linked=TRUE,verbose=TRUE)
Graffelman-Weir exact test for Hardy-Weinberg equilibrium on the X-chromosome
using SELOME p-value
Sample probability 0.002818315 p = 1
>
>
>
>
>
> dev.off()
null device
1
>