spDemography.add_ancestral_populations

spDemography.add_ancestral_populations(anc_sizes, merge_time, anc_id=None, anc_merge_times=None, anc_merge_sizes=None, migration_rate=None)

Adds ancestral populations to the given demographic model, mapping demes in the spatial simulation to ancestral populations.

Parameters

Name Type Description Default
anc_sizes List[float] A list of ancestral population sizes. required
merge_time Union[float, int] The time at which all demes in the spatial simulation merge into one or more ancestral populations. required
anc_id Optional[np.ndarray] An array of ancestral population IDs- the output of [split_landscape_by_pop][utilities.split_landscape_by_pop]. Defaults to None. None
anc_merge_times Optional[List[float]] A list of merge times for ancestral populations. Defaults to None. None
anc_merge_sizes Optional[List[float]] A list of sizes for merged ancestral populations. Defaults to None. None
migration_rate Optional[float] The symmetric migration rate between ancestral populations. Defaults to None. None

Returns

Type Description
msprime.Demography The demographic model with the added ancestral populations.

Raises

Type Description
ValueError If the model already contains ancestral populations.
ValueError If the number of demes in the demographic model does not match the number of demes in the admixture ID raster.

Notes

The function adds ancestral populations to the given demographic model. If anc_id is not provided, a single ancestral population is added with the initial size specified in anc_sizes[0]. If anc_id is provided, a new ancestral population is added for each admixture population, with sizes specified in anc_sizes. The demes in the simulation are then merged into their respective ancestral populations based on the values in anc_id. If anc_merge_times is provided, the ancestral populations are merged at the specified times. If migration_rate is provided, symmetric migration is allowed between ancestral populations.