tracts.driver

Functions

get_time_scaled_model_bounds(model, ...)

get_time_scaled_model_func(model, ...)

load_driver_file(driver_path)

load_model_from_driver(driver_spec, ...[, ...])

load_population(driver_path, driver_spec[, ...])

locate_file_path(filename, script_dir[, ...])

output_simulation_data(sample_population, ...)

output_simulation_data_sex_biased(...[, ...])

Creates output graphs to compare data and the theoretical tract length distribution inferred by the model.

parse_chromosomes(chromosome_spec[, chromosomes])

parse_individual_filenames(individual_names, ...)

parse_start_params(start_param_bounds[, ...])

randomize(arr, a, b)

run_model(model_func, bound_func, ...[, ...])

run_model_multi_init(model_func, bound_func, ...)

Runs the model multiple times with different initial parameters.

run_model_sex_biased(model_func, bound_func, ...)

run_tracts(driver_filename[, script_dir])

scale_select_indices(arr, indices_to_scale)

tracts.driver.get_time_scaled_model_bounds(model, time_scaling_factor)
tracts.driver.get_time_scaled_model_func(model, time_scaling_factor)
Return type:

Callable[[ndarray], dict[str, ndarray]]

tracts.driver.load_driver_file(driver_path)
tracts.driver.load_model_from_driver(driver_spec, script_dir, driver_path, allosome_label=None)
tracts.driver.load_population(driver_path, driver_spec, script_dir=None, allosome_labels=None)
tracts.driver.locate_file_path(filename, script_dir, absolute_driver_yaml_path=None)
tracts.driver.output_simulation_data(sample_population, optimal_params, model, driver_spec)
tracts.driver.output_simulation_data_sex_biased(sample_population, optimal_params, model, driver_spec, ad_model_autosomes='DC', ad_model_allosomes='DC')

Creates output graphs to compare data and the theoretical tract length distribution inferred by the model.

tracts.driver.parse_chromosomes(chromosome_spec, chromosomes=None)
tracts.driver.parse_individual_filenames(individual_names, filename_string, script_dir, labels=['A', 'B'], directory='', absolute_driver_yaml_path=None)
tracts.driver.parse_start_params(start_param_bounds, repetitions=1, seed=None, model=None, time_scaling_factor=1)
tracts.driver.randomize(arr, a, b)
tracts.driver.run_model(model_func, bound_func, population, population_labels, startparams, population_dict, max_iter=None, exclude_tracts_below_cM=0, modelling_method=<class 'tracts.phase_type_distribution.PhTMonoecious'>, ad_model_autosomes='DC', ad_model_allosomes='DC', npts=0)
tracts.driver.run_model_multi_init(model_func, bound_func, population, population_labels, start_params_list, population_dict, max_iter=None, exclude_tracts_below_cM=0, modelling_method=<class 'tracts.phase_type_distribution.PhTMonoecious'>, ad_model_autosomes='DC', ad_model_allosomes='DC', npts=50)

Runs the model multiple times with different initial parameters.

Parameters:
  • model_func (Callable) – A function that takes parameters and returns migration matrices.

  • bound_func (Callable) – A function that calculates the violation score for the parameters.

  • population (Population) – The population object containing individual data.

  • population_labels (list[str]) – A list of labels corresponding to the populations.

  • start_params_list (list[numpy.ndarray]) – A list of initial parameter arrays to start the optimization.

  • exclude_tracts_below_cM (int, optional) – Minimum tract length in centimorgans to exclude from analysis. Default is 0.

  • modelling_method (type, optional) – The method used for modeling. Default is PhTMonoecious.

  • npts (int, optional) – Number of bins for the tract length histogram. Default is 50.

Return type:

tuple[list[ndarray], list[float]]

Returns:

  • tuple[list[numpy.ndarray], list[float]] – A tuple containing two lists: (i) a list of optimal parameters found for each set of starting parameters and (ii) a list of likelihoods corresponding to the optimal parameters.

tracts.driver.run_model_sex_biased(model_func, bound_func, population, population_labels, startparams, population_dict, max_iter=None, exclude_tracts_below_cM=0, ad_model_autosomes='DC', ad_model_allosomes='DC', npts=0)
tracts.driver.run_tracts(driver_filename, script_dir=None)
tracts.driver.scale_select_indices(arr, indices_to_scale, scaling_factor=1)