annotate viz_functions.py @ 13:3ba53d80714b draft default tip

Uploaded
author glogobyte
date Fri, 22 Oct 2021 19:37:27 +0000
parents 77d835d85a2f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
1 import pandas as pd
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
2 import matplotlib.patches as mpatches
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
3 import matplotlib.font_manager as font_manager
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
4 import matplotlib.pyplot as plt
13
3ba53d80714b Uploaded
glogobyte
parents: 7
diff changeset
5 import sys
7
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
6
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
7 #########################################################################################
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
8
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
9 # Read a file and return it as a list
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
10 def read(path, flag):
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
11 if flag == 0:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
12 with open(path) as fp:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
13 file=fp.readlines()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
14 fp.close()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
15 return file
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
16
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
17 if flag == 1:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
18 with open(path) as fp:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
19 file = fp.read().splitlines()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
20 fp.close()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
21 return file
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
22
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
23 # Write a list to a txt file
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
24 def write(path, list):
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
25 with open(path,'w') as fp:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
26 for x in list:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
27 fp.write(str("\t".join(x[1:-1])))
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
28 fp.close()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
29
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
30
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
31 ################################################################################################################################################################>
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
32
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
33 def top_diff(miRNA_info, number,flag,l):
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
34
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
35 Kind=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
36
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
37 miRNA_info.sort(key = lambda x: abs(x[1]),reverse=True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
38 miRNA_info = miRNA_info[:number]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
39 miRNA_info.sort(key = lambda x: x[0])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
40
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
41 for x in miRNA_info:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
42 if x[1] > 0:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
43 Kind.append(True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
44 elif x[1] < 0:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
45 Kind.append(False)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
46 else:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
47 Kind.append("Zero")
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
48
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
49 top_miRNA = {"Names": [x[0] for x in miRNA_info],
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
50 "Log2FC": [x[1] for x in miRNA_info],
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
51 "Kind": Kind};
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
52
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
53 df_miRNA = pd.DataFrame(data=top_miRNA)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
54 df_miRNA = df_miRNA.sort_values(by=['Names'])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
55 if df_miRNA.empty==False:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
56 h1=df_miRNA.plot.barh(x= 'Names',y='Log2FC',color=df_miRNA.Kind.map({True: 'g', False: 'r', 'Zero':'k'}))
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
57 figure = plt.gcf() # get current figure
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
58 figure.set_size_inches(5, 12) # set figure's size manually to your full screen (32x18)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
59 up_reg = mpatches.Patch(color='green', label='Upregulated')
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
60 down_reg = mpatches.Patch(color='red', label='Downregulated')
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
61 font = font_manager.FontProperties(weight='bold', style='normal')
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
62 l3 = plt.legend(handles=[up_reg,down_reg],bbox_to_anchor=(1.04,0.5), loc="center left", borderaxespad=0)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
63 h1.set_ylabel(" ", fontsize=3, fontweight='bold')
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
64 h1.set_xlabel("Log2FC", fontsize=12, fontweight='bold')
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
65 plt.axvline(x=0, color="k")
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
66
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
67 plt.grid(axis='y', linewidth=0.2)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
68 plt.grid(axis='x', linewidth=0.2)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
69 if flag=='t':
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
70 plt.savefig('tem.png', bbox_inches='tight', dpi=300)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
71 if flag=='nt':
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
72 plt.savefig('non.png', bbox_inches='tight', dpi=300)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
73
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
74
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
75 ################################################################################################################################################################>
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
76
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
77 def unique(sequence):
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
78 seen = set()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
79 return [x for x in sequence if not (x in seen or seen.add(x))]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
80
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
81 ################################################################################################################################################################>
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
82
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
83 def top_scatter_non(matures,isoforms,non_temp,uni_names,number):
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
84
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
85 mat_names=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
86 mat_log2fc=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
87
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
88 iso_names=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
89 iso_log2fc=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
90
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
91 non_temp_names=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
92 non_temp_log2fc=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
93
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
94 count=0
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
95 for x in uni_names:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
96 flag = False
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
97 if count<number:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
98 for y in matures:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
99 if x in y[0]:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
100 mat_log2fc.append(y[1])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
101 mat_names.append(x)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
102 flag=True
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
103 for y in isoforms:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
104 if x in y[0]:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
105 iso_log2fc.append(y[1])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
106 iso_names.append(x)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
107 flag=True
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
108 for y in non_temp:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
109 if x in y[0]:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
110 non_temp_log2fc.append(y[1])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
111 non_temp_names.append(x)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
112 flag=True
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
113 if flag==True:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
114 count+=1
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
115
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
116 mat_df = pd.DataFrame(dict(names=mat_names, log2fc=mat_log2fc))
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
117 iso_df = pd.DataFrame(dict(names=iso_names, log2fc=iso_log2fc))
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
118 non_df = pd.DataFrame(dict(names=non_temp_names, log2fc= non_temp_log2fc))
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
119
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
120 iso_df.sort_values(by=['names'])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
121 mat_df.sort_values(by=['names'])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
122 non_df.sort_values(by=['names'])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
123
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
124 fig, ax = plt.subplots()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
125
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
126 h3=ax.scatter(iso_df['log2fc'],iso_df['names'],edgecolors='k',linewidth=1, marker='o', c='red',alpha=0.4)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
127 h1=ax.scatter(mat_df['log2fc'],mat_df['names'],edgecolors='k',linewidth=1, marker='o', c='green',alpha=0.4)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
128 h2=ax.scatter(non_df['log2fc'],non_df['names'],edgecolors='k',linewidth=1, marker='o', c='orange',alpha=0.4)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
129
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
130 l3 = plt.legend([h1,h2,h3],["RefSeq miRNA","Non-templated isomiR","Templated isomiR"],bbox_to_anchor=(1.04,0.5), loc="center left", borderaxespad=0)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
131 plt.axvline(x=0, color="k")
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
132 plt.grid(axis='y', linewidth=0.2)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
133 plt.grid(axis='x', linewidth=0.2)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
134 plt.xlabel("Log2FC", fontsize=12, fontweight='bold')
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
135 plt.yticks(rotation=0,ha="right", fontsize=10)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
136 plt.xticks(rotation=0,ha="right", fontsize=10)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
137 plt.tight_layout()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
138 figure = plt.gcf() # get current figure
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
139 figure.set_size_inches(16, 12) # set figure's size manually to your full screen (32x18)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
140 plt.savefig('a2.png', bbox_inches='tight', dpi=300)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
141
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
142 #########################################################################################################################################################################################################################################
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
143
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
144 def top_scatter_tem(matures,isoforms,uni_names,number):
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
145
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
146 mat_names=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
147 mat_log2fc=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
148
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
149 iso_names=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
150 iso_log2fc=[]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
151
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
152 count=0
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
153 for x in uni_names:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
154 flag = False
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
155 if count<number:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
156 for y in matures:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
157 if x in y[0]:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
158 mat_log2fc.append(y[1])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
159 mat_names.append(x)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
160 flag=True
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
161 for y in isoforms:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
162 if x in y[0]:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
163 iso_log2fc.append(y[1])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
164 iso_names.append(x)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
165 flag=True
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
166 if flag==True:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
167 count+=1
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
168
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
169 mat_df = pd.DataFrame(dict(names=mat_names, log2fc=mat_log2fc))
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
170 iso_df = pd.DataFrame(dict(names=iso_names, log2fc=iso_log2fc))
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
171
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
172 iso_df.sort_values(by=['names'])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
173 mat_df.sort_values(by=['names'])
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
174
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
175 fig, ax = plt.subplots()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
176
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
177 h3=ax.scatter(iso_df['log2fc'],iso_df['names'],edgecolors='k',linewidth=1, marker='o', c='red',alpha=0.4)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
178 h1=ax.scatter(mat_df['log2fc'],mat_df['names'],edgecolors='k',linewidth=1, marker='o', c='green',alpha=0.4)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
179
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
180 l3 = plt.legend([h1,h3],["RefSeq miRNA","Templated isomiR"],bbox_to_anchor=(1.04,0.5), loc="center left", borderaxespad=0)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
181 plt.axvline(x=0, color="k")
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
182 plt.grid(axis='y', linewidth=0.2)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
183 plt.grid(axis='x', linewidth=0.2)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
184 plt.xlabel("Log2FC", fontsize=12, fontweight='bold')
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
185 plt.yticks(rotation=0,ha="right", fontsize=10)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
186 plt.xticks(rotation=0,ha="right", fontsize=10)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
187 plt.tight_layout()
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
188 figure = plt.gcf() # get current figure
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
189 figure.set_size_inches(16, 12) # set figure's size manually to your full screen (32x18)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
190 plt.savefig('a2.png', bbox_inches='tight', dpi=300)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
191
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
192
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
193 ##############################################################################################################################################################################################################################################
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
194
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
195 def preproccess(non_templated,matures,isoforms,log2fc,pval,stat):
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
196
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
197 if stat=="3":
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
198 non_temp = [[x[0],float(x[1]),float(x[2])] for x in non_templated if abs(float(x[1]))>log2fc and float(x[2])>pval]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
199 mat = [[x[0],float(x[1]),float(x[2])] for x in matures if abs(float(x[1]))>log2fc and float(x[2])>pval]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
200 iso = [[x[0],float(x[1]),float(x[2])] for x in isoforms if abs(float(x[1]))>log2fc and float(x[2])>pval]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
201 else:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
202 non_temp = [[x[0],float(x[1]),float(x[2])] for x in non_templated if abs(float(x[1]))>log2fc and float(x[2])<pval]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
203 mat = [[x[0],float(x[1]),float(x[2])] for x in matures if abs(float(x[1]))>log2fc and float(x[2])<pval]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
204 iso = [[x[0],float(x[1]),float(x[2])] for x in isoforms if abs(float(x[1]))>log2fc and float(x[2])<pval]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
205
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
206 mat_iso = mat+iso
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
207
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
208 if not non_temp and not mat and not iso:
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
209 sys.exit("There aren't entries which meet these criteria")
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
210
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
211 mat.sort(key = lambda x: abs(float(x[1])),reverse=True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
212 iso.sort(key = lambda x: abs(float(x[1])),reverse=True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
213 non_temp.sort(key = lambda x: abs(float(x[1])),reverse=True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
214
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
215 all=mat+iso+non_temp
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
216 all.sort(key = lambda x: abs(float(x[1])), reverse=True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
217 names=[x[0].split("_")[0] for x in all]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
218 uni_names=unique(names)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
219
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
220 diff_non_templated = [[x[0],float(x[1]),float(x[2])] for x in non_templated if abs(float(x[1]))>1 and float(x[2])<pval and x[0].split("_")[0] in uni_names]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
221 diff_matures = [[x[0],float(x[1]),float(x[2])] for x in matures if abs(float(x[1]))>1 and float(x[2])<pval and x[0].split("_")[0] in uni_names]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
222 diff_isoforms = [[x[0],float(x[1]),float(x[2])] for x in isoforms if abs(float(x[1]))>1 and float(x[2])<pval and x[0].split("_")[0] in uni_names]
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
223
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
224 diff_matures.sort(key = lambda x: abs(float(x[1])),reverse=True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
225 diff_isoforms.sort(key = lambda x: abs(float(x[1])),reverse=True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
226 diff_non_templated.sort(key = lambda x: abs(float(x[1])),reverse=True)
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
227
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
228 return diff_matures,diff_isoforms,diff_non_templated,uni_names,non_temp,mat_iso
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
229
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
230 ################################################################################################################################################################################################################################################>
77d835d85a2f Uploaded
glogobyte
parents:
diff changeset
231