Commit 101d8fed authored by Carine Rey's avatar Carine Rey
Browse files

fix error if only 1 aa in the contengency table

parent 653893fc
......@@ -156,7 +156,7 @@ except Exception as exc:
logger.info("Ali (%s) ok after checking", AliFile.name)
df_leaves_l = []
n_sites = ali.get_alignment_length()
Sites = [i +1 for i in range(n_sites)]
prob = 1.0
......@@ -247,11 +247,13 @@ df_T.reset_index(drop=True,inplace=True)
df_T_conv = df_T[df_T["AA_up"] != df_T["AA_child"]]
df_T_conv_filtered = df_T_conv[df_T_conv["prob"] > 0.5]
logger.info(df_T_conv)
logger.info(df_T_conv_filtered)
df_T_conv_filtered = df_T_conv_filtered.groupby(['Sites']).apply(lambda x: x.AA_child.value_counts()).reset_index() #FRAGILE
df_T_NA_data = pd.DataFrame({'Sites':[0], "AA_child":['@']}) #AA_child must contain at least 2 differents values to value_counts()
df_T_conv_filtered = pd.concat([df_T_conv_filtered[['Sites','AA_child']], df_T_NA_data])
df_T_conv_filtered = df_T_conv_filtered.groupby(['Sites']).apply(lambda x: (x.AA_child.value_counts())).reset_index()
logger.info(df_T_conv_filtered)
logger.info(df_T_conv_filtered)
if df_T_conv_filtered.shape[0] > 1 :
df_T_conv_filtered.rename(index=str, columns={"level_1": "AA", "AA_child": "Freq"}, inplace = True)
......@@ -266,6 +268,7 @@ df_empty_data = pd.DataFrame({'Sites': Sites_NA,
df_final = pd.concat([ df for df in [df_empty_data,df_T_conv_filtered_max_AA] if not df.empty])
df_final = df_final[df_final.Sites != 0]
df_final.sort_values(by='Sites', inplace=True)
nb_T = len(trans_node_ids)
......
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