Skip to content
Snippets Groups Projects
Commit 202b6d60 authored by nfontrod's avatar nfontrod
Browse files

src/visu/figure_maker.py: modification of the tmp file name

parent 34f4bcbe
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,6 @@
Description:
"""
from pathlib import Path
from typing import List, Union, Any
from doctest import testmod
......@@ -183,7 +182,7 @@ def create_df_summary(df_cov: pd.DataFrame, figure_type: str, nb_bin: int,
:param order_condition: The order of conditions
:return: The summarised dataframe
"""
df_sum = df_cov.groupby(['bin', 'condition', 'replicate']).mean()\
df_sum = df_cov.groupby(['bin', 'condition', 'replicate']).mean() \
.reset_index()
if figure_type == "metagene":
return df_sum
......@@ -254,7 +253,7 @@ def figure_metagene(df_sum: pd.DataFrame, show_replicate: bool,
title += f"\nand in their surrounding regions of {environment[0]} nt"
g.fig.suptitle(title)
outfile_title = f"metagene_{region_name}_{nb_bin}bin_" \
f"{environment[0]}_nt-around-{environment[1]}-bin"
f"{environment[0]}_nt-around-{environment[1]}-bin"
if norm_bin0:
outfile_title += "_b0_norm"
outfile_title += ".pdf"
......@@ -294,7 +293,7 @@ def figure_barplot(df_sum: pd.DataFrame, show_replicate: bool,
title = f"Average coverage in region '{region_name}'"
g.fig.suptitle(title)
outfile_title = f"barplot_{region_name}_{nb_bin}bin_" \
f"{environment[0]}_nt-around-{environment[1]}-bin"
f"{environment[0]}_nt-around-{environment[1]}-bin"
if norm_bin0:
outfile_title += "_b0_norm"
outfile_title += ".pdf"
......@@ -310,7 +309,7 @@ def bin0_normalisation(df: pd.DataFrame) -> pd.DataFrame:
:return: the dataframe with normalised coverage
"""
df_val = df.loc[df['bin'] == 0,
['coverage', 'condition', 'replicate']]\
['coverage', 'condition', 'replicate']] \
.groupby(['condition', 'replicate']).mean().reset_index()
df_val.rename({"coverage": "coef"}, axis=1, inplace=True)
df = df.merge(df_val, how="left", on=['condition', 'replicate'])
......@@ -351,7 +350,7 @@ def create_figure(design: Path, bw_folder: Path, region_bed: Path,
df_exp = pd.read_csv(design, sep="\t")
regions = load_bed(region_bed)
region_bed_name = region_bed.name.replace('.bed', '')
outfile = f'tmp_cov_table_{region_bed_name}_{nb_bin}bin_' \
outfile = f'tmp_cov_table_{design.name}_{region_bed_name}_{nb_bin}bin_' \
f'{environment[0]}_nt-around-{environment[1]}-bin'
if norm_bin0:
outfile += '_bin0_norm'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment