Mercurial > repos > glogobyte > mirviz
comparison viz.py @ 5:4d59ac081282 draft
Uploaded
| author | glogobyte |
|---|---|
| date | Wed, 13 Oct 2021 11:19:17 +0000 |
| parents | |
| children | 0a4d6c483ff0 |
comparison
equal
deleted
inserted
replaced
| 4:216888953a0a | 5:4d59ac081282 |
|---|---|
| 1 from viz_graphs import * | |
| 2 from viz_functions import * | |
| 3 import argparse | |
| 4 import time | |
| 5 from multiprocessing import Process, Lock, Manager | |
| 6 | |
| 7 ################################################################################################################################################################################################################################################################## | |
| 8 starttime = time.time() | |
| 9 | |
| 10 parser = argparse.ArgumentParser() | |
| 11 parser.add_argument("-in", "--input", help="choose type of analysis", action="store") | |
| 12 parser.add_argument("-p_value", "--pval", help="choose type of analysis", action="store") | |
| 13 parser.add_argument("-fc", "--log2fc", help="choose type of analysis", action="store") | |
| 14 parser.add_argument("-top", "--top_mirnas", help="choose type of analysis", action="store") | |
| 15 parser.add_argument("-tool_dir", "--tool_directory", help="tool directory path", action="store") | |
| 16 parser.add_argument("-statistic", "--stat", help="tool directory path", action="store") | |
| 17 parser.add_argument("-diff_tool", "--tool", help="tool directory path", action="store") | |
| 18 | |
| 19 args = parser.parse_args() | |
| 20 | |
| 21 l=Lock() | |
| 22 number = int(args.top_mirnas) | |
| 23 log2fc = float(args.log2fc) | |
| 24 pval = float(args.pval) | |
| 25 iso_star_flag=0 | |
| 26 non_star_flag=0 | |
| 27 | |
| 28 if args.tool=="2": | |
| 29 | |
| 30 raw_EdgeR = read(args.input,0) | |
| 31 EdgeR = [x.rstrip("\n").split("\t") for x in raw_EdgeR] | |
| 32 del EdgeR[0] | |
| 33 for x in EdgeR: | |
| 34 if "/" in x[0]: | |
| 35 x[0]=x[0].split("/")[0]+"★" | |
| 36 | |
| 37 if args.stat=="1": | |
| 38 non_templated = [[x[0],x[1],x[4]] for x in EdgeR if "nt" in x[0] and x[1]!="NA" and x[4]!="NA"] | |
| 39 matures = [[x[0],x[1],x[4]] for x in EdgeR if 'chr' in x[0].split("_")[-1] and "nt" not in x[0] and x[1]!="NA" and x[4]!="NA"] | |
| 40 isoforms = [[x[0],x[1],x[4]] for x in EdgeR if 'chr' not in x[0].split("_")[-1] and "nt" not in x[0] and x[1]!="NA" and x[4]!="NA"] | |
| 41 else: | |
| 42 non_templated = [[x[0],x[1],x[5]] for x in EdgeR if "nt" in x[0] and x[1]!="NA" and x[5]!="NA"] | |
| 43 matures = [[x[0],x[1],x[5]] for x in EdgeR if 'chr' in x[0].split("_")[-1] and "nt" not in x[0] and x[1]!="NA" and x[5]!="NA"] | |
| 44 isoforms = [[x[0],x[1],x[5]] for x in EdgeR if 'chr' not in x[0].split("_")[-1] and "nt" not in x[0] and x[1]!="NA" and x[5]!="NA"] | |
| 45 | |
| 46 if args.tool=="1": | |
| 47 | |
| 48 raw_Deseq = read(args.input,0) | |
| 49 Deseq = [x.rstrip("\n").split("\t") for x in raw_Deseq] | |
| 50 for x in Deseq: | |
| 51 if "/" in x[0]: | |
| 52 x[0]=x[0].split("/")[0]+"★" | |
| 53 | |
| 54 if args.stat=="1": | |
| 55 non_templated = [[x[0],x[2],x[5]] for x in Deseq if "nt" in x[0] and x[2]!="NA" and x[5]!="NA"] | |
| 56 matures = [[x[0],x[2],x[5]] for x in Deseq if 'chr' in x[0].split("_")[-1] and "nt" not in x[0] and x[2]!="NA" and x[5]!="NA"] | |
| 57 isoforms = [[x[0],x[2],x[5]] for x in Deseq if 'chr' not in x[0].split("_")[-1] and "nt" not in x[0] and x[2]!="NA" and x[5]!="NA"] | |
| 58 elif args.stat=="2": | |
| 59 non_templated = [[x[0],x[2],x[6]] for x in Deseq if "nt" in x[0] and x[2]!="NA" and x[6]!="NA"] | |
| 60 matures = [[x[0],x[2],x[6]] for x in Deseq if 'chr' in x[0].split("_")[-1] and "nt" not in x[0] and x[2]!="NA" and x[6]!="NA"] | |
| 61 isoforms = [[x[0],x[2],x[6]] for x in Deseq if 'chr' not in x[0].split("_")[-1] and "nt" not in x[0] and x[2]!="NA" and x[6]!="NA"] | |
| 62 else: | |
| 63 non_templated = [[x[0],x[2],x[1]] for x in Deseq if "nt" in x[0] and x[2]!="NA" and x[1]!="NA"] | |
| 64 matures = [[x[0],x[2],x[1]] for x in Deseq if 'chr' in x[0].split("_")[-1] and "nt" not in x[0] and x[2]!="NA" and x[1]!="NA"] | |
| 65 isoforms = [[x[0],x[2],x[1]] for x in Deseq if 'chr' not in x[0].split("_")[-1] and "nt" not in x[0] and x[2]!="NA" and x[1]!="NA"] | |
| 66 | |
| 67 | |
| 68 diff_matures,diff_isoforms,diff_non_templated,names,non_temp,mat_iso = preproccess(non_templated,matures,isoforms,log2fc,pval,args.stat) | |
| 69 for x in mat_iso[:number]: | |
| 70 if "★" in x[0]: | |
| 71 iso_star_flag=1 | |
| 72 break | |
| 73 for x in non_temp[:number]: | |
| 74 if "★" in x[0]: | |
| 75 non_star_flag=1 | |
| 76 break | |
| 77 | |
| 78 | |
| 79 if non_templated!=[]: | |
| 80 analysis="2" | |
| 81 p=[Process(target=top_diff,args=(non_temp,number,"nt",l))] | |
| 82 p.extend([Process(target=top_diff,args=(mat_iso,number,"t",l))]) | |
| 83 p.extend([Process(target=top_scatter_non,args=(diff_matures,diff_isoforms,diff_non_templated,names,number))]) | |
| 84 | |
| 85 else: | |
| 86 analysis="1" | |
| 87 p=[Process(target=top_diff,args=(mat_iso,number,"t",l))] | |
| 88 p.extend([Process(target=top_scatter_tem,args=(diff_matures,diff_isoforms,names,number))]) | |
| 89 | |
| 90 [x.start() for x in p] | |
| 91 [x.join() for x in p] | |
| 92 | |
| 93 pdf_after_DE(analysis,args.top_mirnas,args.tool_directory,iso_star_flag,non_star_flag) | |
| 94 | |
| 95 print('That took {} seconds'.format(time.time() - starttime)) | |
| 96 |
