OneGenHWSim | R Documentation |
OneGenHWSim
creates n.sim
simulations of one
generation of genotypes under Hardy-Weinberg equilibrium for a
bi-allelic loci.
OneGenHWSim(n.ind = 50, p = 0.5, n.sim = 100)
n.ind |
Integer indicating the census size of the simulated populations. If decimals are inserted, they will be rounded. |
p |
Numerical between zero and one that indicates A1's allele
frequency. A2's allele frequency is assumed to be |
n.sim |
Number of simulations to be made. If decimals are inserted, they will be rounded. |
A data.frame
containing the number of individuals for each
genotype.
Matheus Januario, Dan Rabosky, Jennifer Auler
Hardy, G. H. (1908). Mendelian proportions in a mixed population. Science, 28, 49–50.
Weinberg, W. (1908). Uber den Nachweis der Vererbung beim Menschen. Jahreshefte des Vereins fur vaterlandische Naturkunde in Wurttemberg, Stuttgart 64:369–382. [On the demonstration of inheritance in humans]. Translation by R. A. Jameson printed in D. L. Jameson (Ed.), (1977). Benchmark papers in genetics, Volume 8: Evolutionary genetics (pp. 115–125). Stroudsburg, PA: Dowden, Hutchinson & Ross.
Mayo, O. (2008). A century of Hardy–Weinberg equilibrium. Twin Research and Human Genetics, 11(3), 249-256.
#using the default values (n.ind = 50, p = 0.5, n.sim = 100):
OneGenHWSim()
#Simulating with a already fixed allele:
OneGenHWSim(n.ind = 50, p = 1)
# Testing if the simulation works:
A1freq <- .789 #any value could work
n.simul <- 100
simulations <- OneGenHWSim(n.ind = n.simul, n.sim = n.simul, p = A1freq)
#expected:
c(A1freq^2, 2*A1freq*(1-A1freq), (1-A1freq)^2)
#simulated:
apply(X = simulations, MARGIN = 2, FUN = function(x){mean(x)/n.simul})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.