From 49c0594a4d2d3e5a16d9fef72d60b39228d51fb5 Mon Sep 17 00:00:00 2001
From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr>
Date: Mon, 15 Mar 2021 18:18:09 +0100
Subject: [PATCH] src/gc_content/gc_stats.py: fix mann_whitney and make_stat
 function used when more than two lists of exons are used

---
 src/gc_content/gc_stats.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/gc_content/gc_stats.py b/src/gc_content/gc_stats.py
index 778022b..483460c 100644
--- a/src/gc_content/gc_stats.py
+++ b/src/gc_content/gc_stats.py
@@ -21,10 +21,12 @@ def mann_whitney(df: pd.DataFrame) -> List[Any]:
     :return: The name of the groups and their p-value
     """
     regions = df['region'].unique()
+    res = []
     for r1, r2 in combinations(regions, 2):
         v1 = df.loc[df['region'] == r1, "gc_content"]
         v2 = df.loc[df['region'] == r2, "gc_content"]
-        return [r1, r2, mannwhitneyu(v1, v2)[-1]]
+        res.append([r1, r2, mannwhitneyu(v1, v2)[-1]])
+    return res
 
 
 def make_stat(df: pd.DataFrame) -> List[List[Any]]:
@@ -35,12 +37,12 @@ def make_stat(df: pd.DataFrame) -> List[List[Any]]:
     """
     if len(df['location'].unique()) == 1:
         return [mann_whitney(df)]
-    else:
-        list_pval = []
-        for loc in df['location'].unique():
-            df_tmp = df.loc[df["location"] == loc, :]
-            res = mann_whitney(df_tmp)
+    list_pval = []
+    for loc in df['location'].unique():
+        df_tmp = df.loc[df["location"] == loc, :]
+        result = mann_whitney(df_tmp)
+        for res in result:
             res[0] = (loc, res[0])
             res[1] = (loc, res[1])
             list_pval.append(res)
-        return list_pval
+    return list_pval
-- 
GitLab