Skip to content
Snippets Groups Projects
Commit 6db81916 authored by nfontrod's avatar nfontrod
Browse files

src/07_ribosome_density.py: fix stats filename

parent 7ba444b0
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,6 @@ The goal of this script is to compute the ribosomal density for genes in \ ...@@ -7,7 +7,6 @@ The goal of this script is to compute the ribosomal density for genes in \
experiment 245-6-7 experiment 245-6-7
""" """
from multiprocessing import context
from pathlib import Path from pathlib import Path
from typing import List from typing import List
import doctest import doctest
...@@ -210,20 +209,22 @@ def avg_replicate(df_density: pd.DataFrame) -> pd.DataFrame: ...@@ -210,20 +209,22 @@ def avg_replicate(df_density: pd.DataFrame) -> pd.DataFrame:
return df return df
def statistical_analysis(df_density: pd.DataFrame, output: Path) -> float: def statistical_analysis(df_density: pd.DataFrame, output: Path,
list_type: str) -> float:
"""Get the density pvalue """Get the density pvalue
:param df_density: A density dataframe :param df_density: A density dataframe
:type df_density: pd.DataFrame :type df_density: pd.DataFrame
:param outout: The folder where the diagnostics will be produced :param outout: The folder where the diagnostics will be produced
:param the kind of list studied
:return: The pvalue needed :return: The pvalue needed
""" """
pandas2ri.activate() pandas2ri.activate()
output = output / "diag" output = output / "diag"
output.mkdir(exist_ok=True) output.mkdir(exist_ok=True)
treat = df_density["treatment"].unique()[0] treat = df_density["treatment"].unique()[0]
outfig = output / f"diag_{treat}.pdf" outfig = output / f"diag_{treat}_{list_type}.pdf"
outpval = output / f"diag_pval_{treat}.txt" outpval = output / f"diag_pval_{treat}_{list_type}.txt"
stat_s = r(f""" stat_s = r(f"""
require("DHARMa") require("DHARMa")
require("glmmTMB") require("glmmTMB")
...@@ -263,15 +264,18 @@ def create_density_figure(df_density: pd.DataFrame, gene_file: Path, ...@@ -263,15 +264,18 @@ def create_density_figure(df_density: pd.DataFrame, gene_file: Path,
data=df_mean, kind="violin", height=10, aspect=1.7, data=df_mean, kind="violin", height=10, aspect=1.7,
palette={"TDD_BRAF": "#a600ff", "CTRL": "dimgrey", palette={"TDD_BRAF": "#a600ff", "CTRL": "dimgrey",
"TDD_DMSO": "#ff8400"}, cut=True) "TDD_DMSO": "#ff8400"}, cut=True)
pdmso = statistical_analysis(df_density[df_density["treatment"] == "DMSO"].copy(), pdmso = statistical_analysis(
output_file.parent) df_density[df_density["treatment"] == "DMSO"].copy(),
pbraf = statistical_analysis(df_density[df_density["treatment"] == "BRAF"].copy(), output_file.parent, gene_file.stem)
output_file.parent) pbraf = statistical_analysis(
df_density[df_density["treatment"] == "BRAF"].copy(),
output_file.parent, gene_file.stem)
pdmso = "%.2e" % pdmso pdmso = "%.2e" % pdmso
pbraf = "%.2e" % pbraf pbraf = "%.2e" % pbraf
g.fig.suptitle(f"Ribosome density between {gene_file.stem} and CTRL" g.fig.suptitle(f"Ribosome density "
f"between {gene_file.stem} and CTRL"
f"genes in BRAF and DMSO condition\n" f"genes in BRAF and DMSO condition\n"
f"(p_treatment_BRAF = {pbraf} & p_treatment_BRAF = {pdmso}") f"(p_treatment_BRAF = {pbraf} & p_treatment_DMSO = {pdmso}")
g.set(ylabel="log10(density +1)") g.set(ylabel="log10(density +1)")
g.savefig(output_file) g.savefig(output_file)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment