reproduce
Below is an auto-generated summary of the xftsim.reproduce submodule API.
- class xftsim.reproduce.RecombinationMap(p=None, m=None, vid=None, chrom=None, pos_bp=None)[source]
Bases:
objectA class to represent a diploid recombination map.
- Parameters:
p (
floatornumpy.ndarray, optional) – Probabilities, either a float or a numpy.ndarray, default is None. A single value results in an exchangeable map, an array corresponds to probabilities of recombination between specified loci.m (
int, optional) – Number of variants. Required if p is a float.vid (
numpy.ndarray, optional) – Variant IDs, default is None.chrom (
numpy.ndarray, optional) – Chromosomes, default is None.pos_bp (
numpy.ndarray, optional) – Per-variant base-pair positions, default is None. When provided, any locus j wherepos_bp[j] == pos_bp[j-1]has its recombination probability forced to 0: crossover cannot occur between two mutations at the same physical site (e.g., multi-allelic sites where two ALT entries share a position, or msprime-discretized positions that collide). Without this guard, the GRG-native meiosis path’s interval-based mutation filter (bisect_lefton positions) silently groups all same-position variants into whichever segment claims the position, producing wrong-hap assignments at the few duplicate-position cells.
- Parameters:
m (
int)vid (
Any))chrom (
Int64))pos_bp (
Int64))
- static constant_map(m, p=0.5, pos_bp=None)[source]
Create a constant recombination map.
- Parameters:
m (
int) – Number of variants.p (
float, optional) – Recombination probability, default is 0.5.pos_bp (
numpy.ndarray, optional) – Per-variant base-pair positions; forwarded toRecombinationMap.__init__to suppress crossovers between same-position variants. See class docstring.
- Return type:
- Returns:
RecombinationMap– A constant recombination map.- Parameters:
- static from_haplotypes(haplotypes, p=0.5)[source]
Create a constant recombination map from haplotypes.
Threads
haplotypes.variants.pos_bpinto the constructor when available so that same-position variants are properly handled (see class docstring). Falls back to None when the haplotype object lacks position metadata, which preserves the historical behavior.- Parameters:
haplotypes (
DenseHaplotypeArrayorGraphHaplotypeOperator) – Haplotypes data. Any object with.mand.vid; if it also exposes.variants.pos_bp, that’s used.p (
float, optional) – Probability, default is 0.5.
- Return type:
- Returns:
RecombinationMap– A constant recombination map.- Parameters:
p (
float)
- xftsim.reproduce.meiosis(parental_haplotypes, recombination_map, maternal_inds, paternal_inds, rng=None)[source]
Performs meiosis on parental haplotypes.
- Parameters:
parental_haplotypes (
DenseHaplotypeArray) – Parental haplotype data.recombination_map (
RecombinationMap) – Recombination probabilities.maternal_inds (
numpy.ndarray[int64]) – An array of maternal parent indices.paternal_inds (
numpy.ndarray[int64]) – An array of paternal parent indices.rng (
numpy.random.RandomState, optional) – Master RNG. Used to derive per-offspring seeds viaSeedSequence.spawnso that crossover sampling is deterministic given the master state (independent of hownb.prangeschedules offspring across threads). IfNone(the default), a freshRandomStateis constructed, preserving the historical non-deterministic behavior for callers that don’t pass an rng.
- Return type:
Int8)- Returns:
numpy.ndarray[int8]– 3D array of offspring genotypes (n_offspring, m, 2).- Parameters:
parental_haplotypes (
DenseHaplotypeArray)recombination_map (
RecombinationMap)maternal_inds (
Int64))paternal_inds (
Int64))rng (
RandomState)