reproduce

Below is an auto-generated summary of the xftsim.reproduce submodule API.

class xftsim.reproduce.Meiosis(rmap=None, p=None)

Bases: object

A class representing the process of meiosis.

recombinationMap

A pre-defined recombination map.

Type:

RecombinationMap, optional

p

A probability used when generating an exchangable recombination map on the fly.

Type:

float, optional

get_recombination_map(haplotypes):

Returns the recombination map, either pre-defined or generated on the fly.

reproduce(parental_haplotypes=None, mating=None, control=None):

Returns a HaplotypeArray representing the offspring after meiosis.

get_recombination_map(haplotypes)

Get the recombination map, either pre-defined or generated on the fly.

Parameters:

haplotypes (xr.DataArray) – The haplotype data.

Returns:

RecombinationMap – The recombination map.

reproduce(parental_haplotypes=None, mating=None, control=None)

Return a HaplotypeArray representing the offspring after meiosis.

Parameters:
  • parental_haplotypes (xr.DataArray, optional) – The parental haplotype data.

  • mating (MateAssignment, optional) – The mate assignment object.

  • control (dict, optional) – A dictionary containing control parameters.

Returns:

HaplotypeArray – The HaplotypeArray representing the offspring after meiosis.

class xftsim.reproduce.RecombinationMap(p=None, vindex=None, vid=None, chrom=None)

Bases: object

A class to represent a diploid recombination map. In the future, will require XftIndex object instead of vid and chrom.

Parameters:
  • p (float or numpy.ndarray, optional) – Probabilities, either a float or a numpy.ndarray, default is None. A single value results in an exchangle map, an array corresponds to probabilities of recombination between specified loci

  • vindex (xft.index.HaploidVariantIndex | xft.index.DiploidVariantIndex) – Variant index. Only provide if not providing vid / chrom

  • vid (NDArray[Shape[``”*”``], Any], optional) – Variant IDs, default is None.

  • chrom (NDArray[Shape[``”*”``], Int64], optional) – Chromosomes, default is None.

static constant_map_from_haplotypes(haplotypes=<class 'xarray.core.dataarray.DataArray'>, p=0.5)

Create a constant recombination map from haplotypes.

Parameters:
  • haplotypes (xr.DataArray) – Haplotypes data array.

  • p (np.float64, optional) – Probability, default is 0.5.

Returns:

RecombinationMap – A constant recombination map.

static variable_map_from_haplotypes_with_cM(haplotypes=<class 'xarray.core.dataarray.DataArray'>)

Create a variable recombination map from haplotypes with centimorgan distances.

Parameters:

haplotypes (xr.DataArray) – Haplotypes data array.

Returns:

RecombinationMap – A variable recombination map.

Raises:

ValueError – If distance in centimorgans is required and not present in the input.

xftsim.reproduce.meiosis(parental_haplotypes, recombination_p, maternal_inds, paternal_inds)

Performs meiosis on parental haplotypes.

Parameters:
  • parental_haplotypes (numpy.ndarray[int8]) – An array of parental haplotypes.

  • recombination_p (numpy.ndarray[float64]) – An array of recombination probabilities.

  • maternal_inds (numpy.ndarray[int64]) – An array of maternal indices.

  • paternal_inds (numpy.ndarray[int64]) – An array of paternal indices.

Returns:

numpy.ndarray[int8] – An array of offspring haplotypes.

xftsim.reproduce.transmit_parental_phenotypes(mating, parental_phenotypes, offspring_phenotypes, control=None)

Transmits parental phenotypes to offspring.

Parameters:
  • mating (MateAssignment) – An object representing mating assignments.

  • parental_phenotypes (xr.DataArray) – A data array containing parental phenotypes.

  • offspring_phenotypes (xr.DataArray) – A data array containing offspring phenotypes.

  • control (dict, optional) – A dictionary containing additional control parameters, default is None.

Returns:

None