Mercurial > repos > jay > gaiac_box_plot
comparison gaiac_heatmap/gaiac_heatmap.py @ 0:0763bb545f98 draft
planemo upload for repository https://github.com/jaidevjoshi83/gaiac.git commit c29a769ed165f313a6410925be24f776652a9663-dirty
| author | jay |
|---|---|
| date | Thu, 15 May 2025 14:44:13 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:0763bb545f98 |
|---|---|
| 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 HeatMap(infile, clm_list, custom_column_labels, outfile, plottitile, fig_height, fig_width): | |
| 9 | |
| 10 df=pd.read_csv(infile, sep="\t") | |
| 11 cl = df.columns.tolist() | |
| 12 clms = [ cl[int(x)-1] for x in clm_list.split(',')] | |
| 13 | |
| 14 if custom_column_labels != None: | |
| 15 labels = custom_column_labels.split(',') | |
| 16 else: | |
| 17 labels = clms | |
| 18 | |
| 19 sns.set(font_scale=0.6,style='whitegrid') | |
| 20 plt.figure(figsize=(int(fig_height), int(fig_width))) | |
| 21 ax = sns.heatmap(df[clms].corr(),annot=True,xticklabels=labels,yticklabels=labels,fmt='.2g') | |
| 22 bottom, top = ax.get_ylim() | |
| 23 ax.set_ylim(bottom + 0.5, top - 0.5) | |
| 24 plt.savefig(outfile,dpi=300,bbox_inches="tight") | |
| 25 | |
| 26 if __name__=="__main__": | |
| 27 | |
| 28 parser = argparse.ArgumentParser() | |
| 29 parser.add_argument("-I", "--infile", required=True, default=None, help=".tsv") | |
| 30 parser.add_argument("-C", "--column_list", required=False, default=False, help="Path to target tsv file") | |
| 31 parser.add_argument("-L", "--custom_column_name", required=False, default=None, help="Path to target tsv file") | |
| 32 parser.add_argument("-O", "--output", required=False, default='Out.png', help="Path to target tsv file") | |
| 33 parser.add_argument("-T", "--title", required=False, default='Correlation plot', help="Path to target tsv file") | |
| 34 parser.add_argument("-H", "--height", required=False, default='14', help="Path to target tsv file") | |
| 35 parser.add_argument("-W", "--width", required=False, default='12', help="Path to target tsv file") | |
| 36 | |
| 37 args = parser.parse_args() | |
| 38 | |
| 39 HeatMap(args.infile, args.column_list, args.custom_column_name, args.output, args.title, args.width, args.height) |
