cointf.simintf: simulation¶
Simulation of crossover positions under the Housworth-Stahl model.
The interference pathway is a stationary renewal process with gap density
f* rescaled to rate 1 - p; the escape pathway is a homogeneous
Poisson process with rate p. Observed crossovers are their superposition.
- cointf.simintf.simulate_meioses(L, nu, p, n, seed)¶
Simulate independent meioses under the Housworth-Stahl model.
- Parameters:
- Lfloat
Chromosome length in Morgans,
> 0.- nufloat
Interference parameter,
> 0.- pfloat
Fraction of crossovers escaping interference, in
[0, 1].- nint
Number of meioses,
> 0.- seedint
Seed for
numpy.random.default_rng(),> 0.
- Returns:
- list of numpy.ndarray
Sorted crossover positions in Morgans, one array per meiosis.
- Raises:
- ValueError
If n or seed is not positive, or a model parameter is out of range.
See also
simulate_meiosisSimulate a single meiosis.
Examples
>>> data = simulate_meioses(L=1.5, nu=4.0, p=0.05, n=3, seed=7) >>> len(data) 3
- cointf.simintf.simulate_meiosis(L: float, nu: float, p: float, rng: Generator | None = None) ndarray¶
Simulate one meiosis under the Housworth-Stahl model.
Crossovers are the superposition of the interference pathway (rate
1 - p) and the escape pathway (ratep).- Parameters:
- Lfloat
Chromosome length in Morgans,
> 0.- nufloat
Interference parameter,
> 0.nu = 1is no interference andnu > 1positive interference.- pfloat
Fraction of crossovers escaping interference, in
[0, 1].p = 0is the pure interference model andp = 1a Poisson process.- rngnumpy.random.Generator, optional
Random number generator; a fresh
numpy.random.default_rng()if None.
- Returns:
- numpy.ndarray
Sorted crossover positions in Morgans, in
[0, L]; may be empty.
- Raises:
- ValueError
If L, nu or p is out of range.
See also
simulate_meiosesSimulate many meioses from one seed.
Notes
The expected number of crossovers is L for every
(nu, p). Fornu > 1the interference pathway has sub-Poisson counts.Examples
>>> import numpy as np >>> xs = simulate_meiosis(1.5, nu=4.0, p=0.05, rng=np.random.default_rng(1)) >>> bool(np.all((xs >= 0) & (xs <= 1.5))) True
- cointf.simintf.simulate_quartets(L, nu, p, n, seed)¶
Simulate phase-unknown (quartet) crossover data.
Each dataset pools the crossovers of two independent meioses with the same parameters, as observed for one parent in a family with two offspring when it is unknown which offspring inherited each crossover.
- Parameters:
- Lfloat
Chromosome length in Morgans,
> 0.- nufloat
Interference parameter,
> 0.- pfloat
Fraction of crossovers escaping interference, in
[0, 1].- nint
Number of quartets,
> 0.- seedint
Seed for
numpy.random.default_rng(),> 0.
- Returns:
- list of numpy.ndarray
Sorted pooled crossover positions in Morgans, one array per quartet.
- Raises:
- ValueError
If n or seed is not positive, or a model parameter is out of range.
See also
cointf.quartet.loglik_quartetLikelihood of quartet data.
Examples
>>> data = simulate_quartets(L=1.5, nu=4.0, p=0.05, n=3, seed=7) >>> len(data) 3