Skip to content
Snippets Groups Projects
Commit 8907d939 authored by nfontrod's avatar nfontrod
Browse files

src/find_interaction_cluster/clip_figures/clip_compo_analyser.py: the...

src/find_interaction_cluster/clip_figures/clip_compo_analyser.py: the differents violins (enriched, imoverished) are now order in the figure with custom colors
parent 5f9c7b75
Branches
No related tags found
No related merge requests found
......@@ -353,8 +353,12 @@ def make_barplot(df_comp: pd.DataFrame, outfile: Path, cpnt: str,
:param clip_name: The name of the clip studied
"""
sns.set(context="talk")
dic_col = df_comp[["group", "color"]].drop_duplicates().copy()
dic_col.index = dic_col["group"]
dic_col.drop("group", axis=1, inplace=True)
dic_col = dic_col.to_dict()["color"]
g = sns.catplot(x="group", y=cpnt, data=df_comp, height=12, aspect=1.7,
kind="violin")
kind="violin", palette=dic_col)
g.fig.suptitle(f"Mean frequency of {cpnt}({cpnt_type})"
f"among different community groups\n"
f"created from the peak_density from clip {clip_name}")
......@@ -375,6 +379,14 @@ def update_composition_group(df_comp: pd.DataFrame, display_size: bool
:return: if display_size is False return df_comp else return df_comp \
with the group column containing the size of the groups.
"""
dic = {"ctrl": 1, "enriched": 2, "enriched_nosig": 2, "middle": 3,
"impoverished": 4, "impoverished_nosig": 4}
dic_color = {"ctrl": "#FFCD00", "enriched": "#D40C00",
"enriched_nosig": "#FF9A00", "middle": "#FF9A00",
"impoverished": "#526EFF", "impoverished_nosig": "#00A5F9"}
df_comp["order"] = df_comp["group"].map(dic)
df_comp["color"] = df_comp["group"].map(dic_color)
df_comp = df_comp.sort_values("order")
if not display_size:
return df_comp
d = {
......@@ -531,16 +543,18 @@ def get_ctrl_dic(list_files: List[Path], feature: str) -> Dict:
}
def merge_figures(folder: Path) -> None:
def merge_figures(folder: Path, list_ft: List[str]) -> None:
"""
Merge the figures together using imageMagick
:param folder: A folder containing pdf files
:param list_ft: The list of feature of interest
"""
fig_name = folder.parent.name
tmp_cmd = " ".join(f"{folder}/*_{ft}_*dft*.pdf" for ft in list_ft)
cmd = f"montage -geometry +1+1 -tile 1X3 " \
f"-compress jpeg -density 100 -label %t -pointsize 50 " \
f"{folder}/*dft*.pdf {folder}/{fig_name}.pdf"
f"{tmp_cmd} {folder}/{fig_name}.pdf"
sp.check_call(cmd, shell=True)
......@@ -659,7 +673,7 @@ def multi_tads_compo_figures(clip_result_folder: Path, feature: str,
pool.join()
list_folder = np.unique([r for r in results if r is not None])
for folder in list_folder:
merge_figures(folder)
merge_figures(folder, list_ft)
@lp.parse(feature=["gene", "exon"], threshold_feature=range(1, 1001),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment