From bf2fe661f9d2382cea16486a4fb0f22ea97ff374 Mon Sep 17 00:00:00 2001 From: kkaris Date: Fri, 3 May 2024 15:01:21 -0700 Subject: [PATCH] Also check for +/-inf --- depmap_analysis/network_functions/net_functions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/depmap_analysis/network_functions/net_functions.py b/depmap_analysis/network_functions/net_functions.py index d8e5e4fe..bd9f15e3 100644 --- a/depmap_analysis/network_functions/net_functions.py +++ b/depmap_analysis/network_functions/net_functions.py @@ -393,7 +393,8 @@ 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 - if un in z_corr and vn in z_corr and not np.isnan(z_corr.loc[un, vn]): + 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): 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)