Learn R Programming

learnPopGen (version 1.0.4)

msd: Migration, drift, and selection

Description

Simulates migration, natural selection, and genetic drift. Selection can be in opposite directions in the two populations experiencing gene flow.

Usage

msd(p0=c(0.5,0.5), Ne=c(100,100), w=list(c(1,1,1),c(1,1,1)), 
		m=c(0.01,0.01), ngen=400, colors=c("red","blue"), ...)

Arguments

p0

starting frequency for the A allele in each of two populations.

Ne

effective population size for each of two populations.

w

fitnesses of the three genotypes (AA, Aa, and aa, in that order) in each of the two populations. w should take the form of a list of two vectors.

m

rates of migration from the first population to the second, and from the second population to the first, in that order. This value is best interpreted as the probability that an individual born in population 1 will migrate to population 2 before reproduction, and vice versa.

ngen

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

colors

colors to use for plotting.

...

optional arguments. Presently, the only optional argument for msd is show.legend (which defaults to TRUE). The plot method adds the additional optional arguments of colors (a vector of colors for the two simulated populations), lwd, and type (e.g., "l" or "s").

Value

The function creates a plot and invisibly returns a list containing the allele frequency through time for each of the two simulated populations.

The returned object is of class "msd" and can be printed or re-plotted using corresponding print or plot methods. (See examples.)

See Also

drift.selection

Examples

Run this code
# NOT RUN {
	msd()
	msd(p0=c(0.25,0.75),w=list(c(1,0.9,0.8),c(0.8,0.9,1)))
	object<-msd(p0=c(0.75,0.25),w=list(c(1,0.9,0.8),
		c(0.8,0.9,1)),m=c(0.1,0.1),ngen=100)
	print(object)
	plot(object,colors=c("black","grey"),lwd=4,type="s")
# }

Run the code above in your browser using DataLab