Working example - parameters for simulating direct effects on fitness#
import fwdpy11
N = 1000
mu_neutral = 0.0
mu_selected = 1e-3
rho = 1000.
alpha = -50
p = {
    "nregions": [],
    "gvalue": fwdpy11.Multiplicative(2.0),
    "sregions": [fwdpy11.ExpS(0, 1., 1, mean=alpha/(2 * N))],
    "recregions": [fwdpy11.PoissonInterval(0, 1., rho / float(4 * N))],
    "rates": (mu_neutral, mu_selected, None),
    "prune_selected": True,
    "demography": None,
    "simlen": 10 * N,
    "demography": fwdpy11.ForwardDemesGraph.tubes([N], burnin=10)
}
params = fwdpy11.ModelParams(**p)
Let’s take a look at what he have:
print(params)
ModelParams(nregions=[], sregions=[fwdpy11.ExpS(beg=0, end=1.0, weight=1.0, mean=-0.025, h=1.0, coupled=True, label=0, scaling=1.0)], recregions=[PoissonInterval(beg=0, end=1.0, mean=0.25, discrete=False)], rates=MutationAndRecombinationRates(neutral_mutation_rate=0.0, selected_mutation_rate=0.001, recombination_rate=None), gvalue=Multiplicative(scaling=2.0, gvalue_to_fitness=None, noise=None, ndemes=1), demography=ForwardDemesGraph(yaml='time_units: generations\ngeneration_time: 1\ndemes:\n- name: deme0\n  epochs:\n  - {end_time: 0, start_size: 1000}\n', burnin=10, burnin_is_exact=False, round_non_integer_sizes=False), simlen=10000, prune_selected=True, allow_residual_selfing=True)
Let’s explain a few new things:
- The - rate- tuplecontains the neutral mutation rate, selected mutation rate, and recombination rate, respectively. The recombination rate is- Nonebecause the rates are all contained in- recregions. (See Genetic maps.) This parameterization of- rateswill soon be deprecated and the need to specify a recombination rate of- Nonewill go away.
- The - demographyfield is something we’ve not encountered yet. If nothing is provided, an empty instance of- fwdpy11.ForwardDemesGraphgets initialized. This means “no demographic events”. Demographic events are the subject of this page.
- simlenis how many generations to evolve the population.
- prune_selectedis a boolean. If- True, then mutations that are fixed in the alive individuals, and not present at all in ancient samples, will be removed from the simulation. This removal is an efficiency thing–we don’t need them for multiplicative models. In the future, we hope for a better method for handling fixations that allows for removal, even when present in ancient samples, during the simulation, then add them back in to the tables before returning from the simulation.
Warning
Do not set prune_selected = True for models of additive effects.
Doing so breaks our requirement that the rank order of relative fitness is preserved up to a multiplicative constant.
Our next vignette shows us some tricks that can be useful for modifying our params objects.