Skip to content
Snippets Groups Projects
Commit 0458f11d authored by nfontrod's avatar nfontrod
Browse files

src/gc_content/gc_content.py: change graphic style of the figure

parent ee75d560
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
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