Core modules#

tracts.chromosome

Defines Chrom (and its diploid counterpart Chropair), a chromosome represented as a partition of Tract objects.

tracts.core

The optimization core: compute_objective() evaluates a demographic model's log-likelihood for a given set of parameters, and optimize_cob_sex_biased_single_step()/ optimize_cob_sex_biased_two_steps() drive the actual optimization (in one step, or in two steps that first fit non-sex-bias parameters on autosomal data before fitting sex-bias parameters).

tracts.driver

The main entry point for tracts: run_tracts() loads a driver YAML file, runs the (optionally two-step) optimization via tracts.core, and writes the output files and plots via output_simulation_data_sex_biased().

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.

tracts.genetic_model

Bundles a demographic model together with the admixture and phase-type model configuration used to evaluate its likelihood.

tracts.haploid

Defines Haploid, a haploid genome composed of Chrom objects, built by loading a single haplotype's .bed file.

tracts.indiv

Defines Indiv, a diploid individual built from a pair of Haploid genomes (one per haplotype file).

tracts.likelihood_options

Bundles the logging verbosity and autosome/allosome inclusion flags used when evaluating a demographic model's likelihood, to avoid threading them as separate parameters through tracts.core's optimization functions.

tracts.plot

Re-plots the output figures produced by output_simulation_data_sex_biased() (i.e. by run_tracts()) directly from a previously produced output directory, without re-running the optimization.

tracts.population

Defines Population, a collection of Indiv objects loaded from a sample directory of .bed files.

tracts.tract

Defines Tract, the labeled genomic interval that every higher-level structure in tracts (Chrom, Haploid, Indiv, Population) is ultimately built from.

tracts.tracts_data

Bundles the population and mapped tract-length histogram data used to evaluate a demographic model's likelihood, to avoid threading autosome/allosome bins, mapped data arrays, and sample counts as separate parameters through tracts.core's optimization functions.

tracts.util

General-purpose helpers used across the package: a stderr-printing convenience function, a same-sign check, and the transformations between physical (time/rate/sex-bias) parameter space and the unconstrained space used internally by the optimizer.