From 0458f11d58e98c5ab25d5449fe52422ba0404c3c Mon Sep 17 00:00:00 2001 From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr> Date: Wed, 27 Jan 2021 16:40:33 +0100 Subject: [PATCH] src/gc_content/gc_content.py: change graphic style of the figure --- src/gc_content/gc_content.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gc_content/gc_content.py b/src/gc_content/gc_content.py index b34e871..c517c44 100644 --- a/src/gc_content/gc_content.py +++ b/src/gc_content/gc_content.py @@ -19,6 +19,7 @@ from pathlib import Path import seaborn as sns from .gc_stats import make_stat from .stat_annot import add_stat_annotation +import matplotlib.font_manager def get_gc_content(bed_line: List[Any], dic_seq: Fasta) -> float: @@ -139,7 +140,11 @@ def make_gc_barplot(df: pd.DataFrame, outfile: Path, environment: int, :param region_names: The name of the regions analysed :param ft_name: The name of the feature analyzed """ - sns.set(context="poster") + font_files = matplotlib.font_manager.findSystemFonts(fontpaths=None, + fontext='ttf') + font_list = matplotlib.font_manager.createFontList(font_files) + matplotlib.font_manager.fontManager.ttflist.extend(font_list) + sns.set(context="poster", style="white", font="Arial", font_scale=1.4) rgn = ", ".join(region_names[:-1]) + " and " + region_names[-1] title = f"GC content of {rgn} {ft_name}" p_vals = make_stat(df) @@ -164,6 +169,7 @@ def make_gc_barplot(df: pd.DataFrame, outfile: Path, environment: int, g.set_ylabels("GC content") g.set_xlabels("") g.fig.subplots_adjust(top=0.9) + g.ax.tick_params(left=True, bottom=True) g.fig.suptitle(title + " and their surrounding regions " f"of {environment} nucleotides") g.savefig(outfile) @@ -187,6 +193,7 @@ def create_barplot(beds: List[Path], bed_names: List[str], df = build_gc_dataframe(bed_content, dic_seq, environment, ft_name) outfile = ConfigGC.output / \ f"gc_content_{'-'.join(bed_names)}_env_{environment}_nt.pdf" + df.to_csv(str(outfile).replace(".pdf", ".txt"), index=False, sep="\t") outfile.parent.mkdir(exist_ok=True, parents=True) make_gc_barplot(df, outfile, environment, bed_names, ft_name) -- GitLab