tracts.driver_utils#
Helper functions and driver-file configuration classes (SamplesConfig, ModelsConfig,
OptimizationConfig, OutputConfig, InferenceConfig, etc., all pydantic models) supporting
tracts.driver’s run_tracts() pipeline: loading and validating the driver YAML
file, loading the population and demographic model it specifies, and producing the output files and plots
(output_simulation_data_sex_biased()) once optimization is complete.
Functions
|
Builds a genetic model and driver specification identical to the given ones, except with the sex-bias parameters in |
|
Checks that the final optimal parameters are compatible will well-defined migration matrices. |
Checks whether any of the final optimal parameters is close to a user-narrowed admissible bound (see |
|
Checks whether the optimal sex-bias parameters have values at the border of the feasible region, up to a pre-specified tolerance. |
|
|
Validates that the population labels in the data correspond to the model population labels. |
|
Checks that the number of starting parameters matches the number of model parameters and prints a message about the starting parameters setup. |
Collapse repeated identical starting-parameter sets to a single repetition. |
|
|
Computes physical starting parameters to optimize from. |
|
Compute derived parameters for the 'remainder' (dependent) ancestry in each parametrized population. |
|
Validates the admixture models specified in the driver file and returns the models for autosomes and allosomes. |
Checks whether any of the boundary-violating sex-bias parameter names in |
|
|
Computes and reports the observed ancestry proportions for a population, based on autosomal data and, if allosomes are specified in the driver file, allosomal data as well. |
|
Derives a demographic model's free base parameter names, split into sex-bias and non-sex-bias subsets, straight from its |
|
Assigns a colorblind-friendly color to each population, for use in output plots. |
Computes and logs the predicted ancestry proportions for the optimal parameters. |
|
Computes and logs the starting ancestry proportions for each set of starting parameters. |
|
|
Computes a function that takes in optimizer parameters, converts them to physical parameters using the model's parameter handler, and returns the violation score for those parameters. |
|
Computes a function that takes in optimizer parameters, converts them to physical parameters using the model's parameter handler, and returns the migration matrices for those parameters. |
Checks whether any sex-bias parameters are free (not fixed by ancestry proportions or value) in the demographic model. |
|
|
Loads the demographic model based on the specifications in the driver file. |
|
Loads the driver file and validates that it contains all required parameters for the inference. |
|
Loads the population data based on the specifications in the driver file. |
|
Locates the file path for a given filename by searching in multiple locations. |
|
Creates output graphs to compare data and the theoretical tract length distribution inferred by the model. |
|
Parses a chromosome specification and returns a list of chromosome numbers. |
|
Parses the individual filenames based on the provided format and locates their paths. |
|
Narrows each model parameter's admissible bounds according to the |
|
Produces starting parameters for optimization in physical units. |
|
Stacked bar chart of ancestry proportions in ADMIXTURE style. |
|
Writes a fixed-width text table of observed and predicted per-population values (for autosomes and, optionally, allosomes) to the output directory. |
|
Sets up fixed parameters in the demographic model based on the specifications in the driver file. |
Classes
|
Configuration for the inference process. |
|
Bundles the file-location and ancestry-proportion context needed to reload a demographic model from its driver/model YAML files (e.g. when the implicit population changes and the founder-event structure has to be re-parsed), so that functions needing this context take one parameter instead of five. |
|
Configuration for the demographic and admixture models used in the inference. |
|
Configuration for the optimization process used in the inference. |
|
Configuration for the output of the inference process. |
|
Optional lower/upper admissibility bounds for model parameters, specified as |
|
Configuration for the samples used in the inference. |
|
Configuration for the starting parameters used in the optimization. |