Version: | 0.67-3 |
Date: | 2023-08-21 |
Title: | Models and Tests for Departure from Hardy-Weinberg Equilibrium and Independence Between Loci |
Author: | John Maindonald, with \code{hwexact()} from Randall Johnson. |
Maintainer: | John Maindonald <jhmaindonald@gmail.com> |
Depends: | R (≥ 2.0) |
Description: | Fits models for genotypic disequilibria, as described in Huttley and Wilson (2000) <doi:10.1093/genetics/156.4.2127>, Weir (1996) and Weir and Wilson (1986). Contrast terms are available that account for first order interactions between loci. Also implements, for a single locus in a single population, a conditional exact test for Hardy-Weinberg equilibrium. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Copyright: | (c) John Curtin Research School of Medical Sciences and Centre for Mathematics and Its Applications, The Australian National University |
URL: | https://github.com/jhmaindonald/hwde |
LazyLoad: | yes |
LazyData: | yes |
NeedsCompilation: | no |
Packaged: | 2023-08-21 07:48:02 UTC; johnm1 |
Repository: | CRAN |
Date/Publication: | 2023-08-21 08:12:40 UTC |
Observed genotype frequencies at MN and S loci, for 2 populations
Description
The IndianIrish
data frame has 18 rows and 4 columns.
The data are genotype frequencies for two locations, for
Xavante Indian and Irish populations respectively
Usage
data(IndianIrish)
Format
This data frame contains the following columns:
- Population
Factor with levels:
Indian
andIrish
- locus1
Factor with levels:
MM
,MN
andNN
- locus2
Factor with levels:
SS
,Ss
andss
- Observed
a numeric vector giving the frequency for each category of the tale
Source
Mourant et al (1977) and Huttley and Wilson (2000).
References
1. Huttley, G.A. and Wilson, S.R. 2000. Testing for concordant
equilibria between population samples. Genetics 156, 2127-2135.
2. Mourant, A.E., Kopec, A.C. and Domaniewska-Sobczak, K. 1976.
The Distribution of the Human Blood Groups and Other Polymorphisms.
Oxford University Press.
3. Weir, B.S. 1996. Genetic Data Analysis II. Sinauer.
See Also
Examples
data(IndianIrish)
hwde(data=IndianIrish)
Creates contrasts that relate to a single locus
Description
Vectors ma, maa and oset (offset) are returned.
Usage
decode.genotypes(genotype)
Arguments
genotype |
The vector |
Value
oset |
The offset values that would be appropriate, in the multiplicative version of the model, if there was just this one locus. |
ma |
A contrast for the Hardy-Weinberg model, at this locus. |
maa |
A contrast that measures departure from the Hardy-Weinberg model, at this locus. |
types |
A vector of length three whose elements are the two-letter codes used for the three genotypes. |
Note
Called by make.contrasts
Author(s)
J.H. Maindonald
See Also
hwde
Examples
decode.genotypes(rep(c("AA","Aa","aa"),2))
Fit relevant models, and test for various types of departure from Hardy-Weinberg equilibrium. Allows only 2 alleles per locus. The number of loci is arbitrary.
Description
Fits models for genotypic disequilibria, as described in Huttley and Wilson (2000), Weir (1996) and Weir and Wilson (1986).
Usage
hwde(data = hwde::IndianIrish, gp = "Population", termlist = NULL, refmodel = NULL,
loci = paste("locus", 1:(dim(data)[2] - 1), sep = ""), observed = "Observed",
keep.models = FALSE, aovtable.print = TRUE, group.terms = TRUE, allele.chars = letters)
Arguments
data |
Must have a column of frequencies, by default called
|
gp |
Gives the name of the column, if any, that has information on groups within the data. |
termlist |
Use to specify a user-defined sequence of models. See the vignette hwde.pdf or hwde.html |
refmodel |
For each model in |
loci |
Gives name(s) of columns that hold information on
genotypes. By default, these are taken to be |
observed |
Name (by default |
keep.models |
Should a list be returned that holds the full sequence of models that were fitted? |
aovtable.print |
Should the anova table be printed? |
group.terms |
Should model terms be grouped according to hierarchy, for the anova table? |
allele.chars |
A sequence of letters used to code for the loci. By default a, b, c, ... are used |
Details
See the document hwde.pdf or hwde.html for details. See the references (below) for information on the interpretation of model parameters.
Value
anovatab |
anova (analysis of deviance) table |
data.df |
Data, and contrasts used in fitting the various models. |
aovtab.terms |
This string holds, for each model that is fitted. the terms that have appeared in the model formula. The text strings for the distinct models are concatenated. |
models |
Optionally, this holds the complete sequence of qmodel objects that were fitted |
Author(s)
J.H. Maindonald
References
1. Huttley, G.A. and Wilson, S.R. 2000. Testing for concordant
equilibria between population samples. Genetics 156:2127-2135.
2. Weir, B.S. 1996. Genetic Data Analysis II. Sinauer.
3. Weir, B.S. and Wilson, S.R. 1986. Log-linear models for
linked loci. Biometrics 42:665-670.
See Also
make.contrasts
, decode.genotypes
Examples
data(IndianIrish)
hwde(data=IndianIrish)
data(mendelABC)
hwde(data=mendelABC, loci=c("seedshape", "cotylcolor", "coatcolor"))
Exact test of HWE
Description
This function implements an exact SNP test of
Hardy-Weinberg equilibrium. It is a wrapper for snphwe
Usage
hwexact(obs.hom1, obs.hets, obs.hom2, data, loci, observed)
Arguments
obs.hom1 |
Observed number of individuals homozygous for the common allele. |
obs.hets |
Observed number of heterozygous individuals. |
obs.hom2 |
Observed number of individuals homozygous for the rare allele. |
data |
If not |
loci |
If |
observed |
Column that holds the frequencies, if |
Value
The exact p-value testing departure from Hardy-Weinberg Equilibrium, conditional on the observed relative numbers of alleles of the two types
Author(s)
Randall Johnson – adapted from code by Wigginton et al
References
Wigginton, J.E.; Cutler, D.J. & Abecasis, G.R.; A Note on exact tests of Hardy-Weinberg equilibrium; American Journal of Human Genetics, 2005, 76, 887-93
Examples
hwexact(68, 28, 4)
Calculate contrasts required by the function
Description
Calculates the contrasts that hwde
uses in fitting models
for genotypic disequilibrium. At present these are limited to
first order interaction terms between the distinct loci,
possibly with distinct values foe each different level of a
grouping factor.
Usage
make.contrasts(data = data[, loci], allele.chars = letters)
Arguments
data |
Data frame, with one column per locus, and as many rows as there are observations. Genotypes are represented using a two-letter code, e.g., AA, Aa, aa |
allele.chars |
By default the letters "a", "b", ..., one for each locus, are used. |
Details
Any pair of letters can be used for the two alleles. The setting
of allele.chars
determines the coding used in the model
formulae. This function is called by hwde
Value
contrasts.df |
Data frame whose columns hold the contrasts that will be explanatory variables for the Poisson regression model. |
oset |
Offset vector for the GLM model. |
list.columns |
List in which each element is a text string that holds the codes for a sequence of model terms. |
Author(s)
J.H. Maindonald
See Also
identify.genotypes
, called by make.contrasts
Examples
make.contrasts(data=c("AA","Aa","aa"))
Mendel's F2 trifactorial data for seed shape (A: round or wrinkled), cotyledon color (B: albumen yellow or green), and seed coat color (C: grey-brown or white)
Description
The mendel3
data frame has 27 rows and 4 columns. Data are
from Mendel (1886), and are reproduced in Fisher (1936) and Weir (1996).
Usage
data(mendelABC)
Format
This data frame contains the following columns:
- seedshape
Factor with levels:
AA
,Aa
andaa
- cotylcolor
Factor with levels:
BB
,Bb
andbb
- coatcolor
Factor with levels:
CC
,Cc
andcc
- Observed
a numeric vector that holds the frequencies.
Details
The data are reviewed in detail in Fisher (1936). For a brief discussion, and references to work that revisits Fisher's conclusions, see Weir (1996).
Source
Data are from Mendel (1886), and are reproduced in Fisher (1936) and Weir (1996).
References
1. Fisher, R.A. 1936. Has Mendel's work been rediscovered? Annals of Science 1:115-137.
2. Mendel, G. 1886. Versuche uber Pflanzen-Hybriden. Verhandlugen des Naturforschenden Vereines in Brunn 4:3-47. (An English translation. with annotations, is available from http://www.esp.org/foundations/genetics/classical/gm-65.pdf NB also the English translation by Royal Horticultural Society of London, reprinted in Peters, J.A. 1959. Classic Papers in Genetics. Prentice-Hall.)
3. Weir, B.S. 1996. Genetic Data Analysis II. Sinauer.
Examples
## Lay table out as a 3D array, as in Fisher (1936)
abc <- aperm(array(mendelABC[,4], dim=c(3,3,3)), c(1,3,2))
dimnames(abc) <- list(B=c('BB','Bb','bb'),
A=c('AA','Aa','aa'),
C=c('CC','Cc','cc'))
abc
## Fit Hardy-Weinberg disequilibium model
hwde(mendelABC, loci=c("seedshape","cotylcolor","coatcolor"))