Home Download Help Resources Extensions FAQ NetLogo Publications Contact Us Donate Models: Library Community Modeling Commons Beginners Interactive NetLogo Dictionary (BIND) NetLogo Dictionary User Manuals: Web Printable Chinese Czech Farsi / Persian Japanese Spanish

NetLogo User Community Models(back to the NetLogo User Community Models)
## WHAT IS IT?
This is a model of the fundamental law of population genetics, a.k.a. HardyWeinberg Equilibrium. The model is strictly adherent to the implicit and explicit assumptions originally made in 1908 by the English mathematician Godfrey Harold Hardy and the German physician Wilhelm Weinberg. These assumptions are summarized as follows:
* the organism is diploid;
Based on these assumptions, the simulation shows that equilibrium of genotype and allele frequencies is reached in one generation, and the population remains in equilibrium in successive generations. Verification of HardyWeinberg Equilibrium in the population is done with the Chi square test.
## HOW IT WORKS
Three agents' types with a "dot" shape  one for each genotype  are implemented as described hereafter:
1) white agents = "DD", homozygous genotype for the dominant phenotype;
After fixing the initial number of individuals, each with a specific genotype, an equal number of males and females is assigned. Sex ratio is then maintained constantly = 1 throughout simulation. At the start of simulation, agents are arranged in a circle. The circular arrangement was chosen to facilitate visualization of random mating through the formation of links between agents of opposite sex. For each generation, each partner can only mate with a partner of opposite sex who is not engaged already in another mating event. After reproduction, the population of parents is completely replaced by the population of their offspring, which bears the specific genotypes predicted on the basis of Mendelian segregation rules. Over generations, population size remains constant Overlapping generations are never allowed because parents "die" at each generation after they have reproduced. The model uses a Chi square formula with correction for small sample size (i.e., expected values of genotypes < 5) (Hartl and Clark 2007).
## HOW TO USE IT
Use the sliders to select the initial number of agents with their specific genotypes. Press the setup button to arrange agents in a circle. Simulation consists of two steps to be performed in succession: first createpairs, then reproduction. These steps are implemented with two buttons to run the simulation in a discrete mode. Alternatively, simulation can be run in a continuous mode by pressing the "go" (forever) button. Evolution of genotype and allele frequency can be followed by watching at the corresponding monitors and plots. Statistical differences between observed and expected number of each genotypic class is calculated, generation after generation, by the Chi square statistics, and Chi square values are reported in the corresponding monitor and plot. If population is in equilibrium chi square does not exceed the critical value which  for one degree of freedom  is = 3,84. This value is represented in the Chi square plot as a red line.
## THINGS TO NOTICE
Note that each generation is equivalent to two ticks, one tick for creating pairs and the subsequent one for reproduction.
## THINGS TO TRY
Test the performance of the model with different initial numbers of the three genotypes.
## EXTENDING THE MODEL
The code can be modified to test the effects of evolutionary forces (e.g., selection, mutations, etc.) on HWE.
## NETLOGO FEATURES
The two key primitive terms that were used to implement the mating and the reproduction procedures were "createlinkwith" and "hatch" respectively. Furthermore, segregation ratios are stochastically implemented to assign the probabilities on Mendelian segregation ratios.
## RELATED MODELS
In the Netlogo Models Library look at (i) Hardy Weinberg Equilibrium, and (ii) Mendelian Inheritance.
## CREDITS AND REFERENCES
Hardy, G. H. (1908). Mendelian proportions in a mixed population. Science 28: 4950.
Hartl, D. L., and Clark, A. G. (2007). Principles of Population Genetics (4th edition), Chapter 2 pp. 4592. Sinauer.
Weinberg, W. (1908). Uber den Nachweis der Vererbung beim Menschen. Jahresh. Ver. Vaterl. Naturkd. Wurttemb 64: 369382 (English translations in Boyer 1963 and Jameson 1977).
## HOW TO CITE
For the model itself:
Tarantino, R., and Romano, V. (2022). HardyWeinberg Basic Model.
University of Palermo, Italy 
(back to the NetLogo User Community Models)