diff --git a/depmap_analysis/network_functions/net_functions.py b/depmap_analysis/network_functions/net_functions.py index bd9f15e3..796c0f66 100644 --- a/depmap_analysis/network_functions/net_functions.py +++ b/depmap_analysis/network_functions/net_functions.py @@ -393,8 +393,11 @@ def add_corr_to_edges(graph: DiGraph, z_corr: pd.DataFrame, for u, v, data in tqdm(graph.edges(data=True)): un = u[0] if isinstance(u, tuple) else u vn = v[0] if isinstance(v, tuple) else v - z_sc = z_corr.loc[un, vn] - if un in z_corr and vn in z_corr and not np.isnan(z_sc) and not np.isinf(z_sc): + if ( + un in z_corr and vn in z_corr and + not np.isnan(z_corr.loc[un, vn]) and + not np.isinf(z_corr.loc[un, vn]) + ): z_sc = z_corr.loc[un, vn] data['z_score'] = round(z_sc, 4) data['corr_weight'] = round(z_sc_weight(z_sc, self_corr), 4)