Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

HWData

Generate genetic marker data in or out of Hardy-Weinberg Equilibrium


Description

HWData generates samples of genotypic counts under various schemes. It mainly uses sampling from the multinomial distribution given Hardy-Weinberg allele frequencies.

Usage

HWData(nm = 100, n = rep(100, nm), f = rep(0, nm), p = NULL, conditional
= FALSE, exactequilibrium = FALSE, pdist = "runif", x.linked = FALSE, nA
= NULL,
n.males=rep(round(0.5*n),nm), ...)

Arguments

nm

The number of bi-allelic markers.

n

The sample sizes.

f

The inbreeding coefficients (only for autosomal markers)

p

a vector of allele frequencies

conditional

if TRUE Haldane's distribution is used for sampling, if FALSE a multinomial distribution is used. Replaces parameter pfixed from the previous version of the package

exactequilibrium

generates data in exact HWE if set to TRUE

pdist

Take a random allele frequency from a uniform or beta distribution of pfixed = FALSE and p is not given.

x.linked

Simulated autosomal markers (x.linked=FALSE, the default) or X-chromosomal markers (x.linked=TRUE)

nA

A vector of minor allele counts, one for each marker. If not specified, it will be calculated from p

n.males

The number of males (only relevant if x.linked = TRUE)

...

specific parameters for the uniform or beta

Details

The exactequilibrium option only takes effects for autosomal markers (x.linked=FALSE) and multinomial sampling (conditional=FALSE).

Option pfixed is deprecated and replaced by conditional

HWData returns a matrix of genotype counts, nm by 3 for autsomal markers or nm by 5 for X-chromosomal markers. Output is no longer supplied in the compositional form. Function HWClo can be used to convert the genotype counts to a composition.

If the inbreeding coefficient is specified (f) it will only take effect for autosomal markers (x.linked=FALSE) and multinomial sampling (conditional=FALSE).

Value

X

A matrix containing the genotype counts.

Author(s)

Jan Graffelman (jan.graffelman@upc.edu)

See Also

Examples

nm <- 100
n <- 100
out <- HWData(nm,n)

HardyWeinberg

Statistical Tests and Graphics for Hardy-Weinberg Equilibrium

v1.7.2
GPL (>= 2)
Authors
Jan Graffelman [aut, cre], Christopher Chang [ctb], Xavi Puig [ctb], Jan Wigginton [ctb], Leonardo Ortoleva [ctb], William R. Engels [ctb]
Initial release
2021-04-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.