From 0396538fd3a9e6683889fa805b1101fe52a76249 Mon Sep 17 00:00:00 2001
From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr>
Date: Wed, 15 Jul 2020 15:56:29 +0200
Subject: [PATCH] src/find_interaction_cluster/sf_and_communities.py: fix
 get_stat4communities to keep the same community names

---
 src/find_interaction_cluster/sf_and_communities.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/find_interaction_cluster/sf_and_communities.py b/src/find_interaction_cluster/sf_and_communities.py
index b14d6995..92209a18 100644
--- a/src/find_interaction_cluster/sf_and_communities.py
+++ b/src/find_interaction_cluster/sf_and_communities.py
@@ -151,7 +151,7 @@ def get_stat4communities(sf_name: str, reg: str,
     result = ConfigGraph.get_community_file(project, weight, global_weight,
                                             same_gene,
                                             "_communities.txt")
-    communities = get_communities(result, 49)
+    communities = get_communities(result, 0)
     regulated_dic, number = get_every_events_4_a_sl(cnx, sf_name, reg)
     reg_exons = regulated_dic[sf_name + "_" + reg]
     d = {"community": [], "reg_in_community": [], "community_size": [],
@@ -161,7 +161,7 @@ def get_stat4communities(sf_name: str, reg: str,
         if len(community) > 49:
             reg_community, tot_commmunity, prop = \
                 get_exon_regulated_in_communities(community, reg_exons)
-            d["community"].append(f"C{k}")
+            d["community"].append(f"C{k + 1}")
             d['reg_in_community'].append(reg_community)
             d['community_size'].append(tot_commmunity)
             d['%reg in community'].append(prop)
@@ -169,9 +169,9 @@ def get_stat4communities(sf_name: str, reg: str,
                                                  n2, t2))
     d['padj'] = [np.nan, np.nan] + list(multipletests(d['pval'][2:],
                                                       method='fdr_bh')[1])
-    d['sf'] = [sf_name] * (len(communities) + 2)
-    d['reg'] = [reg] * (len(communities) + 2)
-    d['project'] = [project] * (len(communities) + 2)
+    d['sf'] = [sf_name] * len(d["community"])
+    d['reg'] = [reg] * len(d["community"])
+    d['project'] = [project] * len(d["community"])
     return pd.DataFrame(d)
 
 
-- 
GitLab