Mercurial > repos > jay > gaiac_precision
annotate gaiac_violin_plot/gaiac_violin_plot.py @ 0:287d6cc86582 draft
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
| author | jay | 
|---|---|
| date | Thu, 15 May 2025 14:45:45 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 1 import numpy as np | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 2 import pandas as pd | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 3 import matplotlib.pyplot as plt | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 4 import seaborn as sns | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 5 #%matplotlib inline | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 6 import argparse as argparse | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 7 def violinplot(infile, clm_list_y, custom_xtick_labels, outfile, plottitle, fig_height, fig_width, clm_lab_y, clm_lab_x): | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 8 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 9 df=pd.read_csv(infile, sep="\t") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 10 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 11 cl = df.columns.tolist() | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 12 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 13 clms = [cl[int(x)-1] for x in clm_list_y.split(',')] | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 14 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 15 if custom_xtick_labels != None: | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 16 labels = custom_xtick_labels.split(',') | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 17 #print(labels) | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 18 else: | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 19 labels = clms | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 20 plt.figure(figsize=(int(fig_height),int(fig_width))) | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 21 sns.set(font_scale=0.8,style='whitegrid') | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 22 fig=sns.violinplot(data=df[clms]) | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 23 fig.set_ylabel(clm_lab_y) | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 24 fig.set_xlabel(clm_lab_x) | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 25 fig.set_xticklabels(labels) | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 26 fig.set_title(plottitle) | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 27 plt.tight_layout | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 28 plt.savefig(outfile,dpi=300,bbox_inches="tight") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 29 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 30 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 31 if __name__=="__main__": | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 32 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 33 parser = argparse.ArgumentParser() | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 34 parser.add_argument("-I", "--infile", required=True, default=None, help="Input data file in TSV (tab-separated) format.") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 35 parser.add_argument("-C", "--column_list_y", required=False, default=False, help="Comma-separated list of column names to plot on the Y-axis.") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 36 parser.add_argument("-L", "--custom_xtick_name", required=False, default=None, help="Comma-separated list of custom legend names for the plot legend.") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 37 parser.add_argument("-O", "--output", required=False, default='Out.png', help="Filename for the output plot image (e.g. 'plot.png').") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 38 parser.add_argument("-T", "--title", required=False, default='Time Series plot', help="Title of the time series plot.") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 39 parser.add_argument("-H", "--height", required=False, default='14', help="Height of the figure in inches (default: 14).") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 40 parser.add_argument("-W", "--width", required=False, default='12', help="Width of the figure in inches (default: 12).") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 41 parser.add_argument("-Y", "--ylab", required=False, default='Y label', help="Label for the Y-axis (default: 'Y label').") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 42 parser.add_argument("-X", "--xlab", required=False, default='X label(time)', help="Label for the X-axis (default: 'X label(time)').") | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 43 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 44 args = parser.parse_args() | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 45 | 
| 
287d6cc86582
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 46 violinplot(args.infile, args.column_list_y, args.custom_xtick_name, args.output, args.title, args.width, args.height, args.ylab, args.xlab) | 
