Skip to content
Snippets Groups Projects
Commit 49c0594a authored by nfontrod's avatar nfontrod
Browse files

src/gc_content/gc_stats.py: fix mann_whitney and make_stat function used when...

src/gc_content/gc_stats.py: fix mann_whitney and make_stat function used when more than two lists of exons are used
parent 6fd5c886
No related branches found
No related tags found
No related merge requests found
...@@ -21,10 +21,12 @@ def mann_whitney(df: pd.DataFrame) -> List[Any]: ...@@ -21,10 +21,12 @@ def mann_whitney(df: pd.DataFrame) -> List[Any]:
:return: The name of the groups and their p-value :return: The name of the groups and their p-value
""" """
regions = df['region'].unique() regions = df['region'].unique()
res = []
for r1, r2 in combinations(regions, 2): for r1, r2 in combinations(regions, 2):
v1 = df.loc[df['region'] == r1, "gc_content"] v1 = df.loc[df['region'] == r1, "gc_content"]
v2 = df.loc[df['region'] == r2, "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]]: def make_stat(df: pd.DataFrame) -> List[List[Any]]:
...@@ -35,12 +37,12 @@ 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: if len(df['location'].unique()) == 1:
return [mann_whitney(df)] return [mann_whitney(df)]
else: list_pval = []
list_pval = [] for loc in df['location'].unique():
for loc in df['location'].unique(): df_tmp = df.loc[df["location"] == loc, :]
df_tmp = df.loc[df["location"] == loc, :] result = mann_whitney(df_tmp)
res = mann_whitney(df_tmp) for res in result:
res[0] = (loc, res[0]) res[0] = (loc, res[0])
res[1] = (loc, res[1]) res[1] = (loc, res[1])
list_pval.append(res) list_pval.append(res)
return list_pval return list_pval
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment