Skip to content
Snippets Groups Projects
Commit 0347f483 authored by fadwael.khaddar_ird.fr's avatar fadwael.khaddar_ird.fr
Browse files

Modification de l'affichage graphique des plots et autres modifications

parent 20055901
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ import matplotlib.patches as mpatches
import argparse
import re
from tkinter import *
import tkinter as tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
matplotlib.use('TkAgg')
# Arguments
......@@ -58,8 +60,8 @@ def CpG_context():
rows.append(row)
rows_CG_df = pd.DataFrame(rows)
rows_CG = rows_CG_df.sort_values("chromosome")
#output_file = os.path.join(output_dir, filebasename + "_CG.csv")
#rows_CG.to_csv(output_file, index=False, sep='\t')
output_file = os.path.join(output_dir, filebasename + "_CG.csv")
rows_CG.to_csv(output_file, index=False, sep='\t')
#if not rows_CG.empty:
# for chromosome in rows_CG['chromosome'].unique():
# positions_par_chromosome[chromosome] = list(rows_CG.loc[rows_CG['chromosome'] == chromosome, ['strand', 'position']])
......@@ -184,14 +186,13 @@ def plotting():
CHG = CHG_context()
CHH = CHH_context()
fig, ax = plt.subplots(figsize=(6,3), subplot_kw=dict(aspect="equal"))
fig, ax = plt.subplots(figsize=(10,6), subplot_kw=dict(aspect="equal"))
nb_unmethylated = nb_C - CpG - CHG - CHH
counts = [CpG, CHG, CHH, nb_unmethylated]
labels = ["CpG", "CHG", "CHH", "unmethylated"]
fig = plt.figure()
ax = fig.add_subplot(111)
wedges, texts, autotexts = ax.pie(counts, autopct='%1.1f%%')
bbox_props= dict(boxstyle="square, pad=0.3", fc="w", ec="k", lw=0.72)
kw = dict(arrowprops=dict(arrowstyle="-"), bbox=bbox_props, zorder=0, va="center")
......@@ -206,12 +207,22 @@ def plotting():
ax.annotate(f"{labels[i]}: {counts[i]}", xy=(x, y), xytext=(1.35 * np.sign(x), 1.4 * y),
horizontalalignment=horizontalalignment, **kw)
#ax.pie(counts, autopct='%1.1f%%', startangle=90, center = (-2,0))
#legend = ax.legend(labels, loc = 2)
#ax.axis('equal')
plt.title(f"Methylation context amoung all cytosines in the sample : {filebasename}")
plt.show()
root = tk.Tk()
root.title("Methylation Statistics")
# Create a canvas to display the figure
canvas = FigureCanvasTkAgg(fig, master=root)
canvas.draw()
canvas.get_tk_widget().pack()
# Create a button to close the window
button = tk.Button(master=root, text="Fermer", command=root.quit)
button.pack()
# Start the tkinter event loop
tk.mainloop()
print("####-------- CALCULATION OF METHYLATION STATISTICS FROM TSV FILE GENERATED BY DeepSignal-Plant --------####")
......@@ -273,7 +284,7 @@ for filename in glob.glob(files): # to select all files present in that path
treated_df['k_mer'] = treated_df['k_mer'].str[2:] # filter dataset "treated_df" which contains only from the 3th element from k_mer
CpG_context()
#CpG_context()
#CHG_context()
#CHH_context()
#plotting()
plotting()
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