annotate viz_functions.py @ 10:cc071a0d5d43 draft

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