hapsburg.PackagesSupport.fit_ne
Class the fits Ne with a MLE framework. Standard error either from bootstrap over individuals, or from likelihood curve (kind of assumping ROH are independent, which is not fully correct) @Author: Harald Ringbauer, 2020
Classes
Class for MLE estimation of block sharing |
Functions
|
Create ROH for single individual. Everything measured in Morgan. |
|
Create ROH for single individual. Everything measured in Morgan. |
|
Load and return ROH length vector |
REturn default line of results dataframe. |
Module Contents
- class hapsburg.PackagesSupport.fit_ne.MLE_ROH_Ne(endog=[], exog=[], start_params=[1000], min_len=4, max_len=20.0, error_model=False, output=False, chr_lgts=[], **kwds)
Bases:
statsmodels.base.model.GenericLikelihoodModelClass for MLE estimation of block sharing between populations with modeled error Bins into length blocks and models block-sharing between populations as indep. Poisson Operates in cM unit space (not Morgan!)
- bin_width = 0.1
- mid_bins = []
- chr_lgts = []
- fp_rate = []
- theoretical_shr = []
- trans_mat
- full_shr_pr = []
- density_fun = 0
- start_params = []
- error_model = True
- estimates = []
- summary = 0
- output = True
- initialize_ll_model(**kwds)
Function to initialize LL model
- set_params(recalculate_bins=False, **kwargs)
Set the Parameters. Takes keyworded arguments
- fit(start_params=None, maxiter=10000, maxfun=5000, **kwds)
Fit Parameters via fit method of statsmodels
- fit_ll_profile(ns=[], level=1.92, num=1000)
Fit Parameters via likelihood profile. Only works for 1D search. Return ML, lower, upper CI values ns: Array of 2Ne values to test. level: loglikelihood difference to use for CI values.
- loglikeobs(params)
Return vector of log likelihoods for every observation. (here pairs of pops)
- ll_individual(roh, params)
Log likelihood function for every raw of data (sharing between countries). Return log likelihood.
- create_bins()
Creates the bins according to parameters in Class. Also set the false positive rate
- calculate_thr_shr(params)
Calculates the expected Bessel-Decay per bin
- calculate_trans_mat()
Calculate the transition matrix from true estimated to observed values for block sharing.
- calculate_full_bin_prob()
Calculate the full probablities per bin
- get_bl_shr_interval(interval, r, params=[])
Return the estimated block-sharing under the model in interval given distance r. For this use all the bins intersecting the interval and average. Assumes r is array and return array
- print_block_nr()
Calculate and print the Nr of analyzed Blocks of right Length.
- ci_li(ns=[], level=1.92, update=True)
Get confidence Intervall based on likelihood ration test. Return lower, upper Ne supported by ns: N values to test. level: loglikelihood difference to use. update: Whether to update Confidence Intervals in the fit
- block_shr_density(l, params)
Calculate and print the Nr of analyzed Blocks of right Length.
- get_summ_as_df(summary)
Transforms statsmodels summary to pandas dataframe. If no summary given use the last saved one Return that dataframe
- hapsburg.PackagesSupport.fit_ne.ind_roh_from_pdf(ne=500, bin_range=[0.04, 0.5], nbins=100000, output=False)
Create ROH for single individual. Everything measured in Morgan. Return array of ROH lengths, in Morgan
- hapsburg.PackagesSupport.fit_ne.inds_roh_from_pdf(n_ind=5, ne=500, bin_range=[0.04, 0.5], nbins=100000, output=False, cm=True)
Create ROH for single individual. Everything measured in Morgan. Return array of ROH lengths, in Morgan. cm: If true, output in centimorgan
- hapsburg.PackagesSupport.fit_ne.load_roh_vec(iids=[], base_path='./output/roh/', suffix='_roh_full.csv')
Load and return ROH length vector
- hapsburg.PackagesSupport.fit_ne.get_default_res()
REturn default line of results dataframe. Used for unfittable scenarios