Mercurial > repos > jay > gaiac_windrose_plot
annotate gaiac_heatmap/gaiac_heatmap.py @ 2:738f9ecd4dd1 draft
planemo upload for repository https://github.com/jaidevjoshi83/gaiac commit c31ef5726cd1d2659da9aeb956c22fb834b177ff
| author | jay | 
|---|---|
| date | Fri, 23 May 2025 17:54:48 +0000 | 
| parents | 1d05627d399f | 
| children | 
| rev | line source | 
|---|---|
| 0 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 1 import numpy as np | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 2 import pandas as pd | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 3 import matplotlib.pyplot as plt | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 4 import seaborn as sns | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 5 import argparse | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 6 #%matplotlib inline | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 7 | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 8 def HeatMap(infile, clm_list, custom_column_labels, outfile, plottitile, fig_height, fig_width): | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 9 | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 10 df=pd.read_csv(infile, sep="\t") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 11 cl = df.columns.tolist() | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 12 clms = [ cl[int(x)-1] for x in clm_list.split(',')] | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 13 | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 14 if custom_column_labels != None: | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 15 labels = custom_column_labels.split(',') | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 16 else: | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 17 labels = clms | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 18 | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 19 sns.set(font_scale=0.6,style='whitegrid') | 
| 
1d05627d399f
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))) | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 21 ax = sns.heatmap(df[clms].corr(),annot=True,xticklabels=labels,yticklabels=labels,fmt='.2g') | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 22 bottom, top = ax.get_ylim() | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 23 ax.set_ylim(bottom + 0.5, top - 0.5) | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 24 plt.savefig(outfile,dpi=300,bbox_inches="tight") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 25 | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 26 if __name__=="__main__": | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 27 | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 28 parser = argparse.ArgumentParser() | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 29 parser.add_argument("-I", "--infile", required=True, default=None, help=".tsv") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 30 parser.add_argument("-C", "--column_list", required=False, default=False, help="Path to target tsv file") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 31 parser.add_argument("-L", "--custom_column_name", required=False, default=None, help="Path to target tsv file") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 32 parser.add_argument("-O", "--output", required=False, default='Out.png', help="Path to target tsv file") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 33 parser.add_argument("-T", "--title", required=False, default='Correlation plot', help="Path to target tsv file") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 34 parser.add_argument("-H", "--height", required=False, default='14', help="Path to target tsv file") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 35 parser.add_argument("-W", "--width", required=False, default='12', help="Path to target tsv file") | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 36 | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 37 args = parser.parse_args() | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 38 | 
| 
1d05627d399f
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
 jay parents: diff
changeset | 39 HeatMap(args.infile, args.column_list, args.custom_column_name, args.output, args.title, args.width, args.height) | 
