Commit e8e9199b authored by Hanna  JULIENNE's avatar Hanna JULIENNE

treat case when inversion fail

parent a6f0a83a
......@@ -95,7 +95,7 @@ def raiss_model(zt, sig_t, sig_i_t, lamb=0.01, rcond=0.01, batch=True):
"""
sig_t_inv = invert_sig_t(sig_t, lamb, rcond)
if sig_t_inv is None:
return({"var" : [], "mu" : [], "ld_score" : [], "condition_number" : [], "correct_inversion":[] })
return None
else:
if batch:
condition_number = np.array([np.linalg.cond(sig_t)]*sig_i_t.shape[0])
......
......@@ -165,17 +165,18 @@ def impg_like_imputation(ld_file, ref_panel, zscore, window_size, buffer, lamb,
if(len(known) > 0):
imp = raiss_model(zt, sig_t, sig_i_t, lamb=lamb, rcond=rcond, batch=True)
batch_df = format_result_df(imp, ref_panel, known, unknowns)
# keep only snp in the core window (and not in the buffer)
start_core_window = int(start_ld_block) + i*window_resize
end_core_window = int(start_ld_block) + (i+1)*window_resize
in_core_window = in_region(batch_df.pos, start_core_window, end_core_window)
# keep only SNP with non negligible explained variance
snp_well_predicted = (batch_df.Var < 0.9)
batch_df_filt = batch_df.loc[in_core_window & snp_well_predicted, zscore_results.columns]
zscore_results = pd.concat([zscore_results, batch_df_filt])
if imp is not None:
batch_df = format_result_df(imp, ref_panel, known, unknowns)
# keep only snp in the core window (and not in the buffer)
start_core_window = int(start_ld_block) + i*window_resize
end_core_window = int(start_ld_block) + (i+1)*window_resize
in_core_window = in_region(batch_df.pos, start_core_window, end_core_window)
# keep only SNP with non negligible explained variance
snp_well_predicted = (batch_df.Var < 0.9)
batch_df_filt = batch_df.loc[in_core_window & snp_well_predicted, zscore_results.columns]
zscore_results = pd.concat([zscore_results, batch_df_filt])
i = i+1
print_progression(i, Nwindows)
......
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