diff --git a/raiss/filter_format_output.py b/raiss/filter_format_output.py index 3491d2546b2339c7865ed0bfeb2c205afddae80a..203e13efd547f669516a7a0f16fd9eaa717b19d2 100644 --- a/raiss/filter_format_output.py +++ b/raiss/filter_format_output.py @@ -17,7 +17,7 @@ def filter_output(zscores, fout, R2_threshold = 0.6, minimum_ld = 5): zscores.reset_index(inplace = True) - zscores = zscores[['index', 'pos', 'A0', 'A1', 'Z', 'Var', "ld_score"]] + zscores = zscores[['index', 'pos', 'A0', 'A1', 'Z', 'Var', "ld_score"]].copy() zscores["imputation_R2"] = 1-zscores["Var"] zscores.columns = ['rsID','pos','A0','A1','Z', 'Var', "ld_score", "imputation_R2"] diff --git a/raiss/windows.py b/raiss/windows.py index 349cbb4209b997a7676352ccf4d8ff5a6187e1d8..e30e9b1622321b29bf978133ce0fcbe0fb924ee2 100644 --- a/raiss/windows.py +++ b/raiss/windows.py @@ -42,6 +42,8 @@ def realigned_zfiles_on_panel(ref_panel, zscore): zscore.sort_index(inplace=True) sub_ref_panel.sort_index(inplace=True) + print(sub_ref_panel.Ref_all) + print(zscore.A0) allele_inverted = (sub_ref_panel.Ref_all != zscore.A0) zscore.loc[allele_inverted, "A0"] = sub_ref_panel.loc[allele_inverted].Ref_all @@ -188,7 +190,13 @@ def impg_like_imputation(ld_file, ref_panel, zscore, window_size, buffer, lamb, in_core_window = in_region(batch_df.pos, start_core_window, end_core_window) batch_df_filt = batch_df.loc[(in_core_window), zscore_results.columns] - zscore_results = pd.concat([zscore_results, batch_df_filt]) + if ((batch_df_filt.empty==False) or (batch_df_filt.dropna().empty==False)): + if zscore_results.empty: + zscore_results = batch_df_filt + else: + zscore_results = pd.concat([zscore_results, batch_df_filt]) + + except (ValueError, KeyError, TypeError) as e: print("Inversion failed for window {0} - {1}".format(start_windows,end_windows )) print("With error : {}".format(e))