key = jax.random.PRNGKey(42)
founder_pop = quick_haplo(
key=key,
n_ind=10,
n_chr=3,
seg_sites=100,
inbred=False
)BreedingState
BreedingState (population:__main__.Population, key:jax.Array, generation:int, next_id:int)
*The complete, self-contained state of a single simulation replicate at a point in time.
This object is the primary carrier passed between steps in the simulation.
Attributes: population (Population): The current population of individuals. key (jax.Array): The JAX pseudo-random number generator key. generation (int): The current generation number of the simulation.*
Trait
Trait (qtl_chromosome:jax.Array, qtl_position:jax.Array, qtl_effects:jax.Array, qtl_dominance_effects:jax.Array, intercept:jax.Array)
*Defines the genetic architecture of one or more traits.
This structure holds the information linking genotypes to phenotypes, based on an additive and dominance QTL model.
Attributes: qtl_chromosome (jnp.ndarray): Chromosome index for each QTL. Shape: (n_qtl,) qtl_position (jnp.ndarray): Locus index for each QTL within its chromosome. Shape: (n_qtl,) qtl_effects (jnp.ndarray): The additive effect of each QTL on each trait. Shape: (n_qtl, n_traits) qtl_dominance_effects (jnp.ndarray): The dominance effect of each QTL on each trait. Shape: (n_qtl, n_traits) intercept (jnp.ndarray): The base value for each trait. Shape: (n_traits,)*
Population
Population (geno:jax.Array, ibd:jax.Array, meta:jax.Array)
*Represents a collection of individuals within a breeding program.
Attributes: geno (jnp.ndarray): Genotypes. Shape: (n_individuals, n_chr, 2, n_loci) ibd (jnp.ndarray): Identity-by-descent tracking for founder alleles. Shape: (n_individuals, n_chr, 2, n_loci) meta (jnp.ndarray): Metadata [id, mother_id, father_id, birth_gen]. Shape: (n_individuals, 4)*
GeneticMap
GeneticMap (chromosome_lengths:jax.Array, locus_positions:List[jax.Array])
*Defines the genetic map of the organism.
Attributes: chromosome_lengths (jnp.ndarray): The genetic length of each chromosome in Morgans. Shape: (n_chr,) locus_positions (List[jnp.ndarray]): A list where each element is a JAX array containing the Morgan positions of loci for a single chromosome.*
msprime_pop
msprime_pop (key:jax.Array, n_ind:int, n_chr:int, n_loci_per_chr:int, ploidy:int=2, effective_population_size:int=15000, mutation_rate:float=1e-07, recombination_rate_per_chr:float=1e-08, maf_threshold:float=0.05, base_chr_length:int=500000, num_simulated_individuals:Optional[int]=None, enforce_founder_maf:bool=True)
*Simulate a founder population from an msprime ancestry model.
The output matches the lightweight Population/GeneticMap structures used by the workflow notebooks so it can plug straight into trait sampling, phenotype simulation, and selection routines.*
quick_haplo
quick_haplo (key:jax.Array, n_ind:int, n_chr:int, seg_sites:int, inbred:bool=False, chr_length:float=1.0)
Create a simple founder population and a uniform genetic map.
add_trait
add_trait (key:jax.Array, founder_pop:__main__.Population, n_qtl_per_chr:int, mean:jax.Array, var_a:jax.Array, var_d:jax.Array, sigma:jax.Array)
Sample QTLs and multi-trait effects for both additive and dominance components.
| Type | Details | |
|---|---|---|
| key | Array | |
| founder_pop | Population | |
| n_qtl_per_chr | int | |
| mean | Array | (n_traits,) |
| var_a | Array | Additive variance (n_traits,) |
| var_d | Array | Dominance variance (n_traits,) |
| sigma | Array | (n_traits, n_traits) PSD |
| Returns | Trait |
compute_dosage
compute_dosage (population:__main__.Population)
*Computes the dosage of the ‘1’ allele for each individual at each locus.
Dosage is calculated as the sum of alleles across the two homologous chromosomes, resulting in values of 0, 1, or 2.
Args: population: A Population object.
Returns: A 3D array of dosages with shape (n_individuals, n_chr, n_loci).*