Mercurial > repos > jay > gaiac_heatmap
comparison gaiac_ratio_scatter_plot/gaiac_ratio_scatter_plot.py @ 0:59c78e99325f draft
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
| author | jay |
|---|---|
| date | Thu, 15 May 2025 14:45:00 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:59c78e99325f |
|---|---|
| 1 import numpy as np | |
| 2 import pandas as pd | |
| 3 import matplotlib.pyplot as plt | |
| 4 import seaborn as sns | |
| 5 import argparse | |
| 6 #%matplotlib inline | |
| 7 | |
| 8 def ScatterPlot(InFile, PlotingOptionforx, PlotingOptionfory, xclm1, xclm2, yclm1, yclm2,outfile, plottitle,fig_height, fig_width, clm_lab_y, clm_lab_x): | |
| 9 | |
| 10 df = pd.read_csv(InFile, sep="\t") | |
| 11 clm_list = df.columns.tolist() | |
| 12 | |
| 13 if PlotingOptionforx == 'simple': | |
| 14 dfx = df[clm_list[int(xclm1)-1]] | |
| 15 | |
| 16 elif PlotingOptionforx == 'advance': | |
| 17 dfx = pd.DataFrame() | |
| 18 dfx['ratiox'] = df[clm_list[int(xclm1)-1]]/df[clm_list[int(xclm2)-1]] | |
| 19 | |
| 20 if PlotingOptionfory == 'simple': | |
| 21 dfy = df[clm_list[int(yclm1)-1]] | |
| 22 | |
| 23 elif PlotingOptionfory == 'advance': | |
| 24 dfy = pd.DataFrame() | |
| 25 dfy['ratioy'] = df[clm_list[int(yclm1)-1]]/df[clm_list[int(yclm2)-1]] | |
| 26 | |
| 27 df = pd.concat([dfx, dfy], axis=1) | |
| 28 | |
| 29 print (df) | |
| 30 | |
| 31 df.columns.tolist()[0] | |
| 32 | |
| 33 #plt.figure(figsize=(8,6)) | |
| 34 plt.figure(figsize=(int(fig_width),int(fig_height))) | |
| 35 g = sns.lmplot(x=df.columns.tolist()[0], y=df.columns.tolist()[1],data=df,lowess=True,aspect=1.1,ci=None, scatter_kws={"s": 100}) | |
| 36 g.set(ylabel=clm_lab_y, xlabel=clm_lab_x) | |
| 37 #plt.show() | |
| 38 plt.savefig(outfile,dpi=300,bbox_inches="tight") | |
| 39 | |
| 40 if __name__=="__main__": | |
| 41 | |
| 42 parser = argparse.ArgumentParser(description="Generate a customized plot from a .tsv file with specified plotting options.") | |
| 43 | |
| 44 parser.add_argument( | |
| 45 "-I", "--infile", | |
| 46 required=True, | |
| 47 help="Input .tsv file containing the data to be plotted." | |
| 48 ) | |
| 49 | |
| 50 parser.add_argument( | |
| 51 "-px", "--plotting_option_for_x", | |
| 52 required=True, | |
| 53 help="Plotting option for the X-axis (e.g., line, scatter)." | |
| 54 ) | |
| 55 | |
| 56 parser.add_argument( | |
| 57 "-py", "--plotting_option_for_y", | |
| 58 required=True, | |
| 59 help="Plotting option for the Y-axis (e.g., line, scatter)." | |
| 60 ) | |
| 61 | |
| 62 parser.add_argument( | |
| 63 "-c1", "--x_column_1", | |
| 64 required=True, | |
| 65 help="Column name in the .tsv file for the primary X-axis data." | |
| 66 ) | |
| 67 | |
| 68 parser.add_argument( | |
| 69 "-c2", "--x_column_2", | |
| 70 required=False, | |
| 71 default=None, | |
| 72 help="Optional second column name for the X-axis." | |
| 73 ) | |
| 74 | |
| 75 parser.add_argument( | |
| 76 "-c3", "--y_column_1", | |
| 77 required=True, | |
| 78 help="Column name in the .tsv file for the primary Y-axis data." | |
| 79 ) | |
| 80 | |
| 81 parser.add_argument( | |
| 82 "-c4", "--y_column_2", | |
| 83 required=False, | |
| 84 default=None, | |
| 85 help="Optional second column name for the Y-axis." | |
| 86 ) | |
| 87 | |
| 88 parser.add_argument( | |
| 89 "-O", "--output", | |
| 90 required=False, | |
| 91 default='Out.png', | |
| 92 help="Output file name for the generated plot image (default: Out.png)." | |
| 93 ) | |
| 94 | |
| 95 parser.add_argument( | |
| 96 "-T", "--title", | |
| 97 required=False, | |
| 98 default='Time Series plot', | |
| 99 help="Title of the plot (default: 'Time Series plot')." | |
| 100 ) | |
| 101 | |
| 102 parser.add_argument( | |
| 103 "-H", "--height", | |
| 104 required=False, | |
| 105 default='14', | |
| 106 help="Height of the plot figure in inches (default: 14)." | |
| 107 ) | |
| 108 | |
| 109 parser.add_argument( | |
| 110 "-W", "--width", | |
| 111 required=False, | |
| 112 default='12', | |
| 113 help="Width of the plot figure in inches (default: 12)." | |
| 114 ) | |
| 115 | |
| 116 parser.add_argument( | |
| 117 "-Y", "--ylab", | |
| 118 required=False, | |
| 119 default='Y label', | |
| 120 help="Label for the Y-axis (default: 'Y label')." | |
| 121 ) | |
| 122 | |
| 123 parser.add_argument( | |
| 124 "-X", "--xlab", | |
| 125 required=False, | |
| 126 default='X label (time)', | |
| 127 help="Label for the X-axis (default: 'X label (time)')." | |
| 128 ) | |
| 129 | |
| 130 args = parser.parse_args() | |
| 131 | |
| 132 ScatterPlot(args.infile, args.plotting_option_for_x, args.plotting_option_for_y, args.x_column_1, args.x_column_2, args.y_column_1, args.y_column_2, args.output, args.title, args.height, args.width, args.ylab, args.xlab) | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 |
