tracts.driver.run_model_sex_biased#
- run_model_sex_biased(model_func, bound_func, population, startparams, population_dict, parameter_handler=None, max_iter=None, exclude_tracts_below_cM=0, ad_model_autosomes='DC', ad_model_allosomes='DC', npts=0, verbose_log=0, verbose_screen=0, two_steps_optimization=True)#
Runs the optimization for any demographic model, including sex-biased models. Works with only autosomal admixture or with both autosomal and allosomal admixture.
- Parameters:
model_func (
callable) – A function that takes a parameter array and returns a dictionary of migration matrices for each population.bound_func (
callable) – A function that takes a parameter array and returns a violation score indicating how much the parameters violate the bounds.population (
Population) – A Population object containing the data to fit.startparams (
list) – An array of initial parameters to start the optimization.population_dict (
dict) – A dictionary mapping population labels to their corresponding indices in the model.parameter_handler (ParameterHandler, optional) – An object that handles parameter transformations and fixed parameters. Default is None.
max_iter (
int|None) – Maximum number of iterations for the optimization algorithm. Default is None, which means no limit.exclude_tracts_below_cM (
float) – Minimum tract length in centimorgans to exclude from analysis. Default is 0.ad_model_autosomes (
str) – The model to use for autosomal admixture. Must be one of ‘DC’, ‘DF’, ‘M’, ‘H-DC’ or ‘H-DF’. Default is ‘DC’.ad_model_allosomes (
str) – The model to use for allosomal admixture. Must be one of ‘DC’, ‘DF’, ‘H-DC’ or ‘H-DF’. Default is ‘DC’. If None, allosomal admixture will not be modeled.npts (
int) – Number of bins for the tract length histogram. Default is 50.verbose_log (
int) – Verbosity level for logging. Default is 0 (no verbose output). If greater than 0, iterations are logged everyverbose_logsteps.verbose_screen (
int) – Verbosity level for screen prints. Default is 0. If greater than 0, iterations are printed everyverbose_screensteps.two_steps_optimization (
bool) – Whether to use a two-step optimization procedure for sex-biased models. If True, the optimization will first be run on non-sex bias parameters using only autosomal data. Then, a second optimization will be run with sex-bias parameters using both autosomal and allosomal data, starting from the results of the first optimization. Default is True.
- Returns:
A tuple containing the optimal parameters found and the corresponding likelihood.
- Return type:
tuple [np.ndarray, float]