Learn R Programming

learnPopGen (version 1.0.4)

genetic.drift: Genetic drift simulation

Description

This function simulates genetic drift at a biallelic genetic locus with no selection and no mutation in a sexually reproducing diploid population or set of populations. It is essentially redundant with drift.selection, but in which there is no difference in relative fitness among genotypes; however, it also allows the user to visualize heterozygosity or genetic variation through time - options that are not yet implemented in drift.selection.

Usage

genetic.drift(p0=0.5, Ne=20, nrep=10, time=100, show="p", pause=0.1, ...)

Arguments

p0

Starting frequency for the A allele.

Ne

Effective population size.

nrep

Number of replicate simulations.

time

Total time, in number of generations, for the simulation.

show

Various options for plotting. "p" shows the frequency of the A allele through time; "genotypes" creates an animated histogram with the frequencies of each of the three genotypes through time; "fixed" shows the fraction of populations that have fixed for each allele, a or A; "heterozygosity" plots the mean heterozygosity and the expected heterozygosity through time. The default is show="p".

pause

Pause between generations. pause=0.01 (for instance) might smooth animation.

...

optional arguments. In genetic.drift the optional arguments are presently: colors (a vector giving the colors to be used to graph the various simulations); and lwd. The plot method of the object class adds the optional argument type (e.g., "l" or "s".)

Value

The function creates one of several possible plots, depending on the value of show.

The function also invisibly returns an object of class "genetic.drift" that can be printed or re-plotted by the user using corresponding print and plot methods. (See examples.)

See Also

drift.selection, founder.event, selection

Examples

Run this code
# NOT RUN {
	
# }
# NOT RUN {
		genetic.drift()
		object<-genetic.drift(p0=0.7,show="heterozygosity")
		plot(object,show="genotypes")
	
# }

Run the code above in your browser using DataLab