hapsburg.hmm_inference
Main Inference Class for HMM. Wrapper for Inerence of Posterior. @ Author: Harald Ringbauer, 2019, All rights reserved
Classes
Analyze Class for HMMs. |
Functions
|
Prepares the grouped 3x3 Matrix (3rd State: Everything in OTHER ROH State) |
|
Calculates exponentiation of the rates matrix with rec_v |
Print the current Memory Usage in mB |
Module Contents
- class hapsburg.hmm_inference.HMM_Analyze(folder='./Simulated/Example0/', t_model='model', e_model='haploid', p_model='SardHDF5', post_model='Standard', output=True, save=True, cython=True, manual_load=False, lowmem=False, save_fp=True, start=-np.inf, end=np.inf)
Bases:
objectAnalyze Class for HMMs. This is the main Class, all specific Inference schemes inherit from it and overwrite functions. Contains objects as field for pre-processing, transition as well as emission probabilities. Contains most Parameters (but some of them like the output folders are decided by pre-processing subclass)
- folder = ''
- output = True
- save = True
- save_fp = True
- n_ref = 20
- sanity_checks = True
- ref_states = []
- ob_stat = []
- pCon = []
- lowmem = False
- overhang = 0
- r_map = []
- pos = []
- v_path = []
- posterior = []
- iid = ''
- ch = 0
- start
- end
- fwd_bkwd = 0
- e_model = 'haploid'
- t_model = 'model'
- p_model = 'SardHDF5'
- post_model = 'Standard'
- load_objects(iid='', ch=0, c=0.0)
Load all the required Objects in right order
- load_secondary_objects(c=0.0)
Load all secondary objects (but not the pre-processing one)
- load_data(iid='', ch=0)
Load the External Data
- load_emission_model(c=0.0, pCon=[])
Method to load an Emission Model
- load_transition_model()
Load the Transition Model
- load_preprocessing_model(conPop=[])
- load_postprocessing_model()
- prepare_rmap(cm=False, min_gap=1e-10, max_gap=0.05)
Return the recombination map [in Morgan] Input: Map Positions [l] Return: Rec. Distance Array [l] cm: Whether input is in centimorgan or morgan min_cap: Minimum Gap between Loci
- pre_compute_transition_matrix(t, r_vec, n_ref)
Precompute and return the full transition Matrix t full Transition Matrix [k,k]. NO LOG STATE r_vec Map Length of Jumps [l]
- calc_posterior(save=True, full=False, in_val=0.0001)
Calculate the poserior for each path FULL: Wether to return fwd, bwd as well as tot_ll (Mode for postprocessing) in_val: The Initial Probability to copy from one Ind.
- calc_posterior_lowmem(save=True, full=False, in_val=0.0001)
same functionality as calc_posterior, but a low-memory implmentation. The emission matrix is not pre-computed, but calculated for each marker on the fly the reference panel is stored in the most compact format possible (aka one bit per allele)
- compute_tot_neg_likelihood(c, in_val=0.0001)
Calculate the poserior for each path in_val: The Initial Probability to copy from one Ind.
- optimze_ll_transition_param(roh_trans_params)
Calculate and return the log likelihoods for Transitions Parameters roh_trans_params [m]
- optimize_ll_contamination_BFGS(init_c)
Find MLE of contamination rate by L-BFGS-B.
- optimize_ll_contamANDerr(init_c, init_err)
- post_processing(save=True)
Do the Postprocessing of ROH Blocks Parameters: See in Postprocessing
- mmr_call(windowSize=0.001, save=True)
Calculate Maximal Match Rate
- hapsburg.hmm_inference.prep_3x3matrix(t, n_ref)
Prepares the grouped 3x3 Matrix (3rd State: Everything in OTHER ROH State)
- hapsburg.hmm_inference.exponentiate_r(rates, rec_v)
Calculates exponentiation of the rates matrix with rec_v rates: 2D Matrix. rec_v: Array of length l
- hapsburg.hmm_inference.print_memory_usage()
Print the current Memory Usage in mB