hapsburg.emissions_lowmem

Class for calculating Emission Probabilities in a memory-efficient way. Specifically, it computes emission probability for the non-ROH state and the ROH state (only two states, 0 or 1). The original implementation computes the emission probability for all ROH states, which scales linearly with the number of haplotypes in the reference panel. Contains Sub-Classes, as well as a factory Method. @ Author: Yilei Huang, 2024, All rights reserved

Classes

Emissions

Class for emission probabilities

Model_Emissions

Implements the haploid model Emission probabilities

RC_Model_Emissions

Implements the Read Count model Emission probabilities.

Diploid_GT_Emissions

Implements the Diploid Genotype model Emission probabilities.

RC_Model_Emissions_withContamination

Class for emission probabilities

Functions

load_emission_model_lowmem(ref_states[, e_model, c, ...])

Load the Emission Model

Module Contents

class hapsburg.emissions_lowmem.Emissions(ref_haps=[], blocksize=8, overhang=0)

Bases: object

Class for emission probabilities Has methods to return emission probabilities

p = []
ref_haps = []
e_rate = 0.01
e_rate_ref = 0.001
overhang = 0
blocksize = 8
allele_freq_per_block(gts_one_block)

Calculate allele frequency per block. Return 1D array of length blocksize

calc_allelefreq_blockwise()

Calculate allele frequency for all markers in ref_haps, blockwise

abstractmethod give_emission(ob_stat)

Gives the emission matrix of path of states Return emission matrix [3,l]

set_params(**kwargs)

Set the Parameters. Takes keyworded arguments

class hapsburg.emissions_lowmem.Model_Emissions(ref_haps=[], blocksize=8, overhang=0)

Bases: Emissions

Implements the haploid model Emission probabilities

give_emission(ob_stat)

Return the full emission Probability directly in Log Space. ob_stat: Observed Genotypes [2,l] (only use 1st row)

class hapsburg.emissions_lowmem.RC_Model_Emissions(ref_haps=[], blocksize=8, overhang=0)

Bases: Emissions

Implements the Read Count model Emission probabilities.

give_emission(ob_stat)

Gives the emission matrix of path of states Return emission matrix [3,l]

class hapsburg.emissions_lowmem.Diploid_GT_Emissions(ref_haps=[], blocksize=8, overhang=0)

Bases: Emissions

Implements the Diploid Genotype model Emission probabilities.

give_emission(ob_stat)

Gives the emission matrix of path of states Return emission matrix [3,l]

class hapsburg.emissions_lowmem.RC_Model_Emissions_withContamination(ref_haps, c, pCon, blocksize=8, overhang=0)

Bases: Emissions

Class for emission probabilities Has methods to return emission probabilities

c = 0.0
pCon = []
give_emission(ob_stat)

Gives the emission matrix of path of states Return emission matrix [3,l]

hapsburg.emissions_lowmem.load_emission_model_lowmem(ref_states, e_model='haploid', c=0.0, pCon=[], overhang=0)

Load the Emission Model