tracts.demography.parametrized_demography_sex_biased.ParametrizedDemographySexBiased#
- class ParametrizedDemographySexBiased(name=None, min_time=1, max_time=inf, allosome_label=None)#
Bases:
ParametrizedDemographyA class representing a demographic history with varying rates of male and female migration. The class constructs a separate migration matrix for male and female individuals, where each entry represents the proportion of admixed individuals of that sex that is replaced during that migration. The matrices are implemented as two subpopulations whose migrations have independent rate parameters but linked time parameters.
- name#
The name of the demographic model.
- Type:
str
- min_time#
The minimum time for any demographic event in the model.
- Type:
float
- max_time#
The maximum time for any demographic event in the model.
- Type:
float
- allosome_label#
The label for the allosome chromosome in the model, if applicable.
- Type:
str | None
- logger#
The logger.
- Type:
logging.Logger
- add_continuous_migration(dest_population, source_population, rate_param, start_param, end_param)#
Adds a continuous migration from a source population, parametrized by start_time, end_time, and magnitude.
- Parameters:
dest_population (
str) – The name of the destination population for the continuous migration.source_population (
str) – The name of the source population for the continuous migration.rate_param (
str) – The name of the parameter defining the migration rate for the continuous migration.start_param (
str) – The name of the parameter defining the start time of the continuous migration.end_param (
str) – The name of the parameter defining the end time of the continuous migration.
- add_founder_event(dest_population, source_populations, remainder_population, found_time, end_time=None)#
Adds a founder event. A parametrized demography must have exactly one founder event.
- Parameters:
dest_population (
str) – The name of the destination population for the founder event.source_populations (
dict[str,str]) – A dictionary where the keys are the names of the source populations for the founder event and the values are the names of the parameters defining the proportions contributed by each source population.remainder_population (
str) – The name of the population that contributes the remaining proportion for the founder event, if applicable. If None, the proportions defined by the parameters in source_populations should sum to 1.found_time (
str) – The name of the parameter defining the time of the founder event.end_time (
str|None) – The name of the parameter defining the end time of the founder event, if applicable. If None, the founder event is assumed to be instantaneous.
- add_pulse_migration(dest_population, source_population, rate_param, time_param)#
Adds a pulse migration from a source population, parametrized by time and rate.
- Parameters:
dest_population (
str) – The name of the destination population for the pulse migration.source_population (
str) – The name of the source population for the pulse migration.rate_param (
str) – The name of the parameter defining the migration rate for the pulse migration.time_param (
str) – The name of the parameter defining the time of the pulse migration.
- static load_from_YAML(source)#
Creates an instance of
ParametrizedDemographySexBiasedfrom a YAML file.- Parameters:
source (
str|Path) – The file path to the YAML file containing the demographic model specification. See online documentation for the expected format of the YAML file.- Returns:
An instance of
ParametrizedDemographySexBiasedrepresenting the demographic model specified in the YAML file.- Return type:
- proportions_from_matrices(migration_matrices)#
Computes the ancestry proportions for each population and chromosome type from the migration matrices.
- Parameters:
migration_matrices (
dict[str,ndarray]) – A dictionary where the keys are the names of the migration matrices for each population and sex (formatted as ‘{population}{sex_type.suffix}’) and the values are the corresponding migration matrices as numpy arrays.- Returns:
proportions – A dictionary where the keys are the names of the populations and chromosome types and the values are the corresponding ancestry proportions as numpy arrays.
- Return type:
dict[str, numpy.ndarray]
- proportions_from_matrices_return_keys()#
Returns the keys for the ancestry proportions computed from the migration matrices, which are formatted as ‘{population}_{chromosome_type}’ where chromosome_type is either ‘autosomal’ or the allosome label specified for the demography.
- Returns:
The set of keys for the ancestry proportions computed from the migration matrices.
- Return type:
set[str]