Model parameters#

class fwdpy11.ModelParams(*, nregions=NOTHING, sregions=NOTHING, recregions=NOTHING, rates, gvalue=None, demography=None, simlen=0, prune_selected=True, allow_residual_selfing=True)#

This class stores and validates the parameters of a simulation. Instances of this class are constructed using kwargs and instance attributes are immutable once initialized.

This class accepts the following kwargs, which are also the attribute names for instances:

Parameters:
  • nregions (list[fwdpy11.Region]) – List of regions where neutral mutations occur

  • sregions (list[fwdpy11.Sregion]) – List of regions where selected mutations occur

  • recregions (list[fwdpy11.Region] or list[object]) – List of regions where recombination events occur

  • rates (list or fwdpy11.MutationAndRecombinationRates) – The neutral mutation rate, selected mutation rate, and total recombination rate, respectively. See below for more details.

  • demography (object) – The demographic model to simulate

  • simlen (int) – The number of time steps to evolve

  • prune_selected (bool) – If True, remove selected fixations from the population when they are first detected as fixed.

  • allow_residual_selfing (bool) – If True, then an individual may be chosen twice as a parent. If False, two distinct parents are required.

Warning

When allow_residual_selfing is False, an exception will be raised if the parental deme has a size of 1. The reason is that outcrossing is not possible in order to generate the offspring.

Note

To initialize the rates field, we require an instance of fwdpy11.MutationAndRecombinationRates or a list of length three (3) specifying the three rates. The two mutation rates must be non-negative floats. For the recombination rate, the third value must also be a non-negative float if all objects in recrates are instances of fwdpy11.Region. However, if they are instead instances of any mixture of fwdpy11.PoissonInterval, fwdpy11.PoissonPoint, fwdpy11.BinomialPoint, or fwdpy11.BinomialInterval, then the final element in rates must be None. See the section on setting recombination rates for details.

If prune_selected is True, fixations will be remove during the simulation. This removal is a sensible thing to do if individual relative fitnesses are constant up to a multiplicative constant.

In a multiplicative model, removing a fixation would be equivalent to dividing all values by the same value, which does not affect their relative values.

However, removing a fixation in an additive model does change the relative values. Likewise, mappings from genetic value to fitness such as Gaussian stabilizing selection, or adding random noise to genetic values, also changes relative values.

This class will raise a warning if prune_selected is True and there is a possibility that removing fixations will change relative fitness. Such warnings should not be ignored as they suggest that a simulation may not be giving biologically sensible results.

New in version 0.1.1.

Changed in version 0.2.0: Changed this from a horrible class hierarchy into a much simpler, single class.

Changed in version 0.6.0: Updated to support fwdpy11.DiscreteDemography

Changed in version 0.8.0: Refactored class internals using attrs. Mutation and recombination rates now stored in fwdpy11.MutationAndRecombinationRates

Changed in version 0.14.0: Remove deprecated kwargs pself and popsizes.

Changed in version 0.20.0: Add allow_residual_selfing

asblack()#

Return a string representation formatted with black

asdict()#

Return dict representation

classmethod fromdict(d)#

Build an instance from a dictionary

class fwdpy11.MutationAndRecombinationRates(*, neutral_mutation_rate, selected_mutation_rate, recombination_rate)#

Stores and validates the mutation and recombination rate parameters of a simulation.

Instances of this class are created by kwargs that populate attributes of the same name:

Parameters:
  • neutral_mutation_rate (float) –

  • selected_mutation_rate (float) –

  • recombination_rate (float or None) –

Instances of this class are passed as the rates kwarg to fwdpy11.ModelParams.

New in version 0.8.0.

asblack()#

Return a string representation formatted with black

asdict()#

Return dict representation

classmethod fromdict(d)#

Build an instance from a dictionary