limix.stats.compute_dosage

limix.stats.compute_dosage(expec, alt=None)[source]

Compute dosage from allele expectation.

Parameters:
  • expec (array_like) – Allele expectations encoded as a variants-by-samples-by-alleles matrix.
  • ref (array_like) – Allele reference of each locus. The allele having the minor allele frequency for the provided expec is used as the reference if None. Defaults to None.
Returns:

Dosage encoded as a variants-by-samples matrix.

Return type:

numpy.ndarray

Examples


>>> from bgen_reader import read_bgen, allele_expectation, example_files
>>> from bgen_reader import compute_dosage
>>>
>>> with example_files("example.32bits.bgen") as filepath:
...     bgen = read_bgen(filepath, verbose=False)
...     e = allele_expectation(bgen["genotype"], nalleles=2, ploidy=2)
...     dosage = compute_dosage(e).compute()
...     print(dosage.shape)
...     print(dosage)
(199, 500)
[[       nan 1.93575854 1.91558579 ... 1.94351192 0.10894776 1.01101689]
 [1.98779296 1.97802735 0.02111815 ... 1.95492412 1.00897216 1.02255316]
 [0.01550294 0.99383543 1.97933958 ... 1.98681641 1.99041748 1.99603272]
 ...
 [1.99319479 1.980896   1.98767124 ... 1.9943846  1.99716186 1.98712159]
 [0.01263467 0.09661863 0.00869752 ... 0.00643921 0.00494384 0.01504517]
 [0.99185182 1.94860838 0.99734497 ... 0.02914425 1.97827146 0.9515991 ]]