Title: | Models and Tests for Departure from Hardy-Weinberg Equilibrium and Independence Between Loci |
---|---|
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. |
Authors: | John Maindonald, with \code{hwexact()} from Randall Johnson. |
Maintainer: | John Maindonald <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.67-3 |
Built: | 2024-11-07 06:12:34 UTC |
Source: | https://github.com/jhmaindonald/hwde |
Vectors ma, maa and oset (offset) are returned.
decode.genotypes(genotype)
decode.genotypes(genotype)
genotype |
The vector |
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. |
Called by make.contrasts
J.H. Maindonald
hwde
decode.genotypes(rep(c("AA","Aa","aa"),2))
decode.genotypes(rep(c("AA","Aa","aa"),2))
Fits models for genotypic disequilibria, as described in Huttley and Wilson (2000), Weir (1996) and Weir and Wilson (1986).
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)
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)
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 |
See the document hwde.pdf or hwde.html for details. See the references (below) for information on the interpretation of model parameters.
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 |
J.H. Maindonald
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.
make.contrasts
, decode.genotypes
data(IndianIrish) hwde(data=IndianIrish) data(mendelABC) hwde(data=mendelABC, loci=c("seedshape", "cotylcolor", "coatcolor"))
data(IndianIrish) hwde(data=IndianIrish) data(mendelABC) hwde(data=mendelABC, loci=c("seedshape", "cotylcolor", "coatcolor"))
This function implements an exact SNP test of
Hardy-Weinberg equilibrium. It is a wrapper for snphwe
hwexact(obs.hom1, obs.hets, obs.hom2, data, loci, observed)
hwexact(obs.hom1, obs.hets, obs.hom2, data, loci, observed)
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 |
The exact p-value testing departure from Hardy-Weinberg Equilibrium, conditional on the observed relative numbers of alleles of the two types
Randall Johnson – adapted from code by Wigginton et al
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
hwexact(68, 28, 4)
hwexact(68, 28, 4)
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
data(IndianIrish)
data(IndianIrish)
This data frame contains the following columns:
Factor with levels:
Indian
and Irish
Factor with levels:
MM
, MN
and NN
Factor with levels:
SS
, Ss
and ss
a numeric vector giving the frequency for each category of the tale
Mourant et al (1977) and Huttley and Wilson (2000).
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.
data(IndianIrish) hwde(data=IndianIrish)
data(IndianIrish) hwde(data=IndianIrish)
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.
make.contrasts(data = data[, loci], allele.chars = letters)
make.contrasts(data = data[, loci], allele.chars = letters)
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. |
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
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. |
J.H. Maindonald
identify.genotypes
, called by make.contrasts
make.contrasts(data=c("AA","Aa","aa"))
make.contrasts(data=c("AA","Aa","aa"))
The mendel3
data frame has 27 rows and 4 columns. Data are
from Mendel (1886), and are reproduced in Fisher (1936) and Weir (1996).
data(mendelABC)
data(mendelABC)
This data frame contains the following columns:
Factor with levels:
AA
, Aa
and aa
Factor with levels:
BB
, Bb
and bb
Factor with levels:
CC
, Cc
and cc
a numeric vector that holds the frequencies.
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).
Data are from Mendel (1886), and are reproduced in Fisher (1936) and Weir (1996).
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.
## 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"))
## 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"))