Function documentation#

fwdpy11.infinite_sites(rng, pop, mu)#
Parameters:
Returns:

Number of mutations added

Return type:

int

fwdpy11.simplify(pop, samples)#

Simplify a TableCollection stored in a Population.

Parameters:
Returns:

The simplified tables and array mapping input sample IDs to output IDS

Return type:

tuple

Note that the samples argument is agnostic with respect to the time of the nodes in the input tables. Thus, you may do things like simplify to a set of “currently-alive” nodes plus some or all ancient samples by including some node IDs from fwdpy11.DiploidPopulation.ancient_sample_metadata.

If the input contains ancient samples, and you wish to include them in the output, then you need to include their IDs in the samples argument.

Note

Due to node ID remapping, the metadata corresponding to nodes becomes a bit more difficult to look up. You need to use the output ID map, the original IDs, and the population’s metadata containers.

Deprecated since version 0.3.0: Prefer fwdpy11.simplify_tables()

Changed in version 0.3.0: Ancient samples are no longer kept by default

Changed in version 0.5.0: No longer requires a MutationVector argument.

fwdpy11.simplify_tables(tables, samples)#

Simplify a TableCollection.

Parameters:
Returns:

A simplified TableCollection and an array containing remapped sample ids.

Return type:

tuple

New in version 0.3.0.

fwdpy11.evolvets(rng, pop, params, simplification_interval, recorder=None, *, post_simplification_recorder=None, suppress_table_indexing=None, record_gvalue_matrix=False, stopping_criterion=None, track_mutation_counts=False, remove_extinct_variants=True, preserve_first_generation=False)#

Evolve a population with tree sequence recording

Parameters:
  • rng (fwdpy11.GSLrng) – random number generator

  • pop (fwdpy11.DiploidPopulation) – A population

  • params (fwdpy11.ModelParams) – simulation parameters

  • simplification_interval (int) – Number of generations between simplifications.

  • recorder (Callable) – (None) A temporal sampler/data recorder.

  • post_simplification_recorder (Callable) – (None) A temporal sampler

  • suppress_table_indexing (Optional[bool]) – (None) Prevents edge table indexing until end of simulation. The default value (None) will be interpreted as True

  • record_gvalue_matrix (bool) – (False) Whether to record genetic values into fwdpy11.DiploidPopulation.genetic_values.

  • preserve_first_generation (bool) – (False) Whether to record generation 0 as ancient samples. Must be True for tree sequence “recapitation”. See Finishing a simulation with msprime.

The recording of genetic values into fwdpy11.DiploidPopulation.genetic_values is suppressed by default. First, it is redundant with fwdpy11.DiploidMetadata.g for the common case of mutational effects on a single trait. Second, we save some memory by not tracking these matrices. However, it is useful to track these data for some cases when simulating multivariate mutational effects (pleiotropy).

Note

If recorder is None, then fwdpy11.NoAncientSamples will be used.

If post_simplification_recorder is None, then fwdpy11.RecordNothing will be used.

Changed in version 0.5.2: Added post_simplification_recorder.

Changed in version 0.7.1: Added preserve_first_generation.

Changed in version 0.8.0: Update to refactored ModelParams. Added check_demographic_event_timings.

fwdpy11.data_matrix_from_tables(tables, samples, *, record_neutral=True, record_selected=True, include_fixations=False, begin=0.0, end=None)#

Create a fwdpy11.DataMatrix from a table collection.

Parameters:
  • tables (fwdpy11.TableCollection) – A TableCollection

  • samples (list or numpy.ndarray) – A list of sample nodes

  • record_neutral (bool) – (True) If True, generate data for neutral variants

  • record_selected (bool) – (True) If True, generate data for selected variants

  • include_selected (bool) – (False) Whether to include variants fixed in the sample

  • begin – (0.0) Start of range, inclusive

  • end – (max float) End of range, exclusive

Return type:

fwdpy11.DataMatrix

New in version 0.3.0.

Changed in version 0.4.1: Add begin, end options as floats

Changed in version 0.5.0: No longer requires fwdpy11.MutationVector argument

fwdpy11.discrete_demography.from_demes(dg, burnin=10, *, round_non_integer_sizes=None)#

Build a fwdpy11.DemographicModelDetails object using demes. The deme graph can either be a demes Graph object or a string as the filepath to a demes-specifiend YAML demography.

Parameters:
  • dg (demes.Graph or str) – The demes Graph to convert.

  • burnin (int) – A factor for how many generations to burn in the simulation. For a typical demography with a single root, the number of generations of burn in is burnin times the root deme’s population size. For models with multiple root demes joined by migration, that population size is determined as the size of the metapopulation.

Return type:

fwdpy11.DemographicModelDetails

New in version 0.14.0.