Commit e413b780 authored by Hanna  JULIENNE's avatar Hanna JULIENNE
Browse files

fix zero division

parent d378743c
......@@ -16,7 +16,6 @@ class ImputationLauncher(object):
"""
"""
ref_panel_file = "/mnt/atlas/PCMA/1._DATA/ImpG_refpanel/{0}.eur.1pct.bim".format(chrom)
#ref_panel = pd.read_csv(ref_panel_file, sep="\t", names=['chr', "nothing", 'pos', 'Ref_all', 'alt_all'], index_col = 1)
......
......@@ -23,9 +23,6 @@ def impg_model(zt, sig_t, sig_i_t, lamb=0.01, batch=True):
sig_t_inv = np.linalg.pinv(sig_t)
var = compute_var(sig_i_t, sig_t_inv, lamb, batch)
#if var< 0:
# var=0
mu = compute_mu(sig_i_t, sig_t_inv, zt)
mu = mu / (((1+lamb)-var)**0.5)
#mu = mu / (((1+lamb)-var)**0.5)
return({"var":var, "mu":mu})
......@@ -11,7 +11,6 @@ from .ld_matrix import generate_sparse_matrix
import pandas as pd
import numpy as np
def parse_region_position(ld_file):
"""
Retrieve the region definition from a ld-file generated by impute_jass
......@@ -51,7 +50,6 @@ def prepare_zscore_for_imputation(ref_panel, zscore):
zscore = zscore.loc[zscore.index.intersection(ref_panel.index)]
return zscore
def in_region(pos_vector, start, end):
return ((start < pos_vector) & (pos_vector < end))
......@@ -103,11 +101,16 @@ def impg_like_imputation(ld_file, ref_panel, zscore, window_size, buffer, unknow
LD_mat = generate_sparse_matrix(ld_file, ref_panel)
Nwindows = ((int(end_ld_block)) - (int(start_ld_block)))//window_size
# adapt window size to cover the LD block
window_resize = np.ceil((int(end_ld_block) - (int(start_ld_block)))/Nwindows)
if Nwindows > 0:
window_resize = np.ceil((int(end_ld_block) - (int(start_ld_block)))/Nwindows)
else:
Nwindows = 1
window_resize = np.ceil(int(end_ld_block) - (int(start_ld_block)))
all_unknowns = ref_panel.loc[ref_panel.index.difference(zscore.index)]
#zscore = pd.read_csv(Zfile, index_col=0, sep="\t")
zscore = prepare_zscore_for_imputation(ref_panel, zscore)
print("### Imputation of {0} snps ###".format(unknowns.shape[0]))
print("### Imputation of {0} snps ###".format(all_unknowns.shape[0]))
for i in range(Nwindows):
# Boundary of the sliding_window
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment