HWData | R Documentation |
HWData generates samples of genotypic counts under various schemes. It mainly uses sampling from the multinomial distribution for given or random allele frequencies, either assuming Hardy-Weinberg proportions or a specified degree of inbreeding. Sampling can also be performed conditional on the allele frequency. The same procedures are also available for X linked markers.
HWData(nm = 100, n = rep(100, nm), f = rep(0, nm), p = NULL, conditional = FALSE,
exactequilibrium = FALSE, x.linked = FALSE, nA = NULL, n.males = round(0.5 * n),
shape1 = 1, shape2 = 1, counts = TRUE)
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 |
exactequilibrium |
generates data in exact HWE if set to
|
x.linked |
Simulated autosomal markers ( |
nA |
A vector of minor allele counts, one for each marker. If not
specified, it will be calculated from |
n.males |
The number of males (only relevant if |
shape1 |
First shape parameter of the beta distribution used to generate allele frequencies |
shape2 |
Second shape parameter of the beta distribution used to generate allele frequencies |
counts |
If |
Option pfixed
is deprecated and replaced by conditional
Option pdist
is deprecated and replaced by parameters shape1
and shape2
HWData
returns a matrix of genotype counts, nm
by 3 for
autsomal markers or nm
by 5 for X-chromosomal markers.
If the inbreeding coefficient is specified (f
) it will only
take effect for autosomal markers (x.linked=FALSE
) and
multinomial sampling (conditional=FALSE
).
X |
A matrix containing the genotype counts. |
Jan Graffelman (jan.graffelman@upc.edu)
HWTernaryPlot
#
# Generate 100 SNPs with uniform allele frequency under the equilibrium assumption.
#
out <- HWData(nm=100,n=100)
#
# Generate genotype frequencies of 100 SNPs with uniform allele frequency assuming exact equilbrium.
#
X <- HWData(nm=100, exactequilibrium = TRUE, counts = FALSE)
#
# Generate 100 SNPs (as counts), all having an expected A allele frequency of 0.50
#
X <- HWData(nm=100,p=0.5)
#
# Generate 100 SNPs, 50 with A allele frequency 0.25 and 50 with A allele frequency 0.75,
# assuming fixed allele frequencies.
#
X <- HWData(nm=100,p=rep(c(0.25,0.75),50), conditional = TRUE)
#
# Generate 100 SNPs with a skewed (beta) distribution of the allele frequency,
# rich in variants with a low minor allele frequency.
#
X <- HWData(nm=100,shape1=1,shape2=10)
#
# Generate 100 X chromosomal SNPs with uniformly distributed allele frequency.
#
X <- HWData(nm=100, x.linked = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.