Given population size, initial allele frequency, generations to evolve, number of replicates, this script demonstrates changes of allele frequency at single locus due to genetic drift. The core part of this function is shown below. The full Python code is available for download.

def simuGeneticDrift(popSize=100, p=0.2, generations=100, replications=5):
    '''Simulate the Genetic Drift as a result of random mating.'''
    # diploid population, one chromosome with 1 locus
    # random mating with sex
    pop = Population(size=popSize, loci=[1])
    simu=Simulator(pop, rep=replications)

    if useRPy:
        plotter = VarPlotter('alleleFreq[0][0]', ylim=[0, 1], ylab='allele frequency',
            update=generations-1, saveAs='geneticDrift.png')
        plotter = NoneOp()

    # if number of generation is smaller than 200, step is 10 generations,
    # if it's between 200 and 500, set step to be 20 generations,
    # otherwise, step = 50 generations.
    if generations <= 200:
        s = 10
    elif 200 < generations <= 500:
        s = 20
        s = 50

        # everyone initially will have the same allele frequency
        initOps = [
            InitGenotype(freq=[p, 1-p])
        matingScheme = RandomMating(),
        postOps = [
            PyEval(r'"Generation %d:\t" % gen', reps = 0, step = s),
	        PyEval(r"'%.3f\t' % alleleFreq[0][0]", step = s),
	        PyOutput('\n', reps=-1, step = s),
        gen = generations

This script will produce figures such as

27 June 2012

04:58 by !Hello, I have a set of alleles from one population with significant variation and a set from a population with low variation. Is it possible to use the population with sig. var. as a starting point and use the low var. pop. as an ending point in an attempt to see how long it took for the variation to go from high to low?

23 November 2015

00:42 by c?!Hi

Leave a Comment

Enter code 613