Beispiel #1
0
def set_up_quant_trait_model():
    # TODO add neutral variants
    N = 1000
    demography = np.array([N] * 10 * N, dtype=np.uint32)
    rho = 1.
    # theta = 100.
    # nreps = 500
    # mu = theta/(4*N)
    r = rho / (4 * N)

    GSSmo = fwdpy11.GSSmo([(0, 0, 1), (N, 1, 1)])
    a = fwdpy11.Additive(2.0, GSSmo)
    p = {
        'nregions': [],
        'sregions': [fwdpy11.GaussianS(0, 1, 1, 0.25)],
        'recregions': [fwdpy11.Region(0, 1, 1)],
        'rates': (0.0, 0.025, r),
        'gvalue': a,
        'prune_selected': False,
        'demography': demography
    }
    params = fwdpy11.ModelParams(**p)
    rng = fwdpy11.GSLrng(101 * 45 * 110 * 210)
    pop = fwdpy11.DiploidPopulation(N, 1.0)
    return params, rng, pop
def runsim(args):
    popsizes = np.array([args.popsize] * 20 * args.popsize, dtype=np.int32)
    locus_boundaries = [(i, i + 11) for i in range(0, 10 * 11, 11)]
    sregions = [fwdpy11.GaussianS(i[0] + 5, i[0] + 6, 1, args.sigma)
                for i in locus_boundaries]
    recregions = [fwdpy11.PoissonInterval(
        *i, args.rho / (4 * args.popsize)) for i in locus_boundaries]
    recregions.extend([fwdpy11.BinomialPoint(i[1], 0.5)
                       for i in locus_boundaries[:-1]])
    pop = fwdpy11.DiploidPopulation(args.popsize, locus_boundaries[-1][1])

    optima = fwdpy11.GSSmo(
        [(0, 0, args.VS), (10 * args.popsize, args.opt, args.VS)])
    p = {'nregions': [],  # No neutral mutations -- add them later!
         'gvalue': fwdpy11.Additive(2.0, optima),
         'sregions': sregions,
         'recregions': recregions,
         'rates': (0.0, args.mu, None),
         # Keep mutations at frequency 1 in the pop if they affect fitness.
         'prune_selected': False,
         'demography':  np.array(popsizes, dtype=np.uint32)
         }
    params = fwdpy11.ModelParams(**p)
    rng = fwdpy11.GSLrng(args.seed)
    s = Recorder(args.popsize)
    fwdpy11.evolvets(rng, pop, params, 100, s,
                     suppress_table_indexing=True,
                     track_mutation_counts=True)
    return pop
Beispiel #3
0
def runsim(args):
    popsizes = np.array([args.popsize] * 20 * args.popsize, dtype=np.int32)
    pop = fwdpy11.DiploidPopulation(args.popsize, 1.0)
    sregions = [fwdpy11.GaussianS(0, 1, 1, args.sigma)]
    recregions = [fwdpy11.PoissonInterval(0, 1, args.recrate)]

    optima = fwdpy11.GSSmo([(0, 0, args.VS),
                            (10 * args.popsize, args.opt, args.VS)])
    p = {
        'nregions': [],  # No neutral mutations -- add them later!
        'gvalue': fwdpy11.Additive(2.0, optima),
        'sregions': sregions,
        'recregions': recregions,
        'rates': (0.0, args.mu, None),
        # Keep mutations at frequency 1 in the pop if they affect fitness.
        'prune_selected': False,
        'demography': np.array(popsizes, dtype=np.uint32)
    }
    params = fwdpy11.ModelParams(**p)
    rng = fwdpy11.GSLrng(args.seed)
    s = Recorder(args.popsize)
    fwdpy11.evolvets(rng,
                     pop,
                     params,
                     100,
                     s,
                     suppress_table_indexing=True,
                     track_mutation_counts=True)
    return pop
def runsim(args):
    """
    Run the simulation and deliver output to files.
    """
    pop = fwdpy11.DiploidPopulation(args.popsize, GENOME_LENGTH)

    rng = fwdpy11.GSLrng(args.seed)

    GSSmo = fwdpy11.GSSmo([(0, 0, args.VS),
                           (10 * args.popsize, args.opt, args.VS)])

    popsizes = [args.popsize
                ] * (10 * args.popsize + int(args.time * float(args.popsize)))
    p = {
        'nregions': [],  # No neutral mutations -- add them later!
        'gvalue': fwdpy11.Additive(2.0, GSSmo),
        'sregions': [fwdpy11.GaussianS(0, GENOME_LENGTH, 1, args.sigma)],
        'recregions': [fwdpy11.Region(0, GENOME_LENGTH, 1)],
        'rates': (0.0, args.mu, args.rho / float(4 * args.popsize)),
        # Keep mutations at frequency 1 in the pop if they affect fitness.
        'prune_selected': False,
        'demography': np.array(popsizes, dtype=np.uint32)
    }
    params = fwdpy11.ModelParams(**p)

    r = Recorder(args.record, args.preserve, args.num_ind)
    fwdpy11.evolvets(rng, pop, params, 100, r, suppress_table_indexing=True)

    with lzma.open(args.filename, 'wb') as f:
        pickle.dump(pop, f)

    if args.statfile is not None:
        stats = pd.DataFrame(r.data, columns=DATA._fields)
        # Write the statistics to an sqlite3 database,
        # which can be processed in R via dplyr.
        conn = sqlite3.connect(args.statfile)
        stats.to_sql('data', conn)
 def setUp(self):
     self.optima = [(0, 0.0, 1.0), (100, 1.0, 1.0)]
     self.g = fwdpy11.GSSmo(self.optima)
Beispiel #6
0
 def setUp(self):
     self.a = fwdpy11.Additive(
         2.0, fwdpy11.GSS(0.0, 1.0))
     self.b = fwdpy11.Additive(
         2.0, fwdpy11.GSSmo([(0, 0.0, 1.0)]))
     self.pop = fwdpy11.DiploidPopulation(1000)