annotate mirgene_graphs.py @ 27:6e365f2eb24a draft

Uploaded
author glogobyte
date Wed, 20 Oct 2021 14:40:13 +0000
parents 0bf751c64fe9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
1 import itertools
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
2 import pandas as pd
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
3 from math import pi
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
4 import numpy as np
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
5 import matplotlib.pyplot as plt
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
6 import math
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
7 import logomaker as lm
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
8 from fpdf import FPDF, fpdf
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
9 import glob
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
10
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
11 ###############################################################################################################################################################################
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
12 def pie_non_temp(merge_con,merge_non_con,merge_tre,merge_non_tre,c_unmap,t_unmap,c_unmap_counts,t_unmap_counts,group_name1,group_name2):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
13
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
14 c_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge_con]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
15 t_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge_tre]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
16 c_non_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge_non_con]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
17 t_non_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge_non_tre]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
18
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
19 c_templ = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
20 c_tem_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
21 c_mature = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
22 c_mat_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
23 t_templ = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
24 t_tem_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
25 t_mature = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
26 t_mat_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
27
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
28 c_non = len(c_non_samples)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
29 c_non_counts = sum(x[2] for x in c_non_samples)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
30 t_non = len(t_non_samples)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
31 t_non_counts = sum(x[2] for x in t_non_samples)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
32
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
33 c_unmap = c_unmap - c_non
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
34 t_unmap = c_unmap - t_non
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
35
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
36 c_unmap_counts=c_unmap_counts - c_non_counts
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
37 t_unmap_counts=t_unmap_counts - t_non_counts
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
38
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
39
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
40 for x in c_samples:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
41
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
42 if "/" not in x[0]:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
43 if len(x[0].split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
44 c_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
45 c_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
46 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
47 c_templ+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
48 c_tem_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
49 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
50 f=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
51 for y in x[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
52 if len(y.split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
53 c_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
54 c_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
55 f=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
56 break
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
57 if f==0:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
58 c_templ+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
59 c_tem_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
60
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
61 for x in t_samples:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
62
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
63 if "/" not in x[0]:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
64 if len(x[0].split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
65 t_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
66 t_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
67 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
68 t_templ+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
69 t_tem_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
70 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
71 f=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
72 for y in x[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
73 if len(y.split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
74 t_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
75 t_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
76 f=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
77 break
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
78 if f==0:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
79 t_templ+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
80 t_tem_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
81
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
82 fig = plt.figure(figsize=(7,5))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
83
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
84 labels = 'miRNA RefSeq','templated', 'unassigned' ,'non-templated'
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
85 sizes = [c_mat_counts, c_tem_counts, c_unmap_counts,c_non_counts]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
86 colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue']
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
87 # Plot
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
88 ax1 = plt.subplot2grid((1,2),(0,0))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
89 patches, texts, autotexts=plt.pie(sizes, labels=labels, colors=colors, startangle=140,autopct='%1.1f%%',radius=0.8)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
90 [x.set_fontsize(10) for x in texts]
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
91 plt.title(group_name1.capitalize() + ' group (reads)',fontsize=12)
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
92
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
93 labels = 'miRNA RefSeq','templated', 'unassigned','non-templated'
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
94 sizes = [t_mat_counts, t_tem_counts, t_unmap_counts, t_non_counts]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
95 colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue']
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
96 # Plot
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
97 ax2 = plt.subplot2grid((1,2),(0,1))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
98 patches, texts, autotexts=plt.pie(sizes, labels=labels, colors=colors, startangle=140,autopct='%1.1f%%',radius=0.8)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
99 [x.set_fontsize(10) for x in texts]
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
100 plt.title(group_name2.capitalize() + ' group (reads)', fontsize=12)
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
101 plt.savefig('pie_non.png',dpi=300)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
102
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
103 ####################################################################################################################################################################################################################
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
104
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
105 def pie_temp(merge_con,c_unmap,c_unmap_counts,merge_tre,t_unmap,t_unmap_counts,group_name1,group_name2):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
106
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
107 c_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge_con]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
108 t_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge_tre]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
109
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
110 c_templ = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
111 c_tem_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
112 c_mature = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
113 c_mat_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
114 t_templ = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
115 t_tem_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
116 t_mature = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
117 t_mat_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
118
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
119 for x in c_samples:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
120
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
121 if "/" not in x[0]:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
122 if len(x[0].split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
123 c_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
124 c_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
125 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
126 c_templ+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
127 c_tem_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
128 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
129 f=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
130 for y in x[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
131 if len(y.split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
132 c_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
133 c_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
134 f=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
135 break
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
136 if f==0:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
137 c_templ+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
138 c_tem_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
139
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
140 for x in t_samples:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
141
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
142 if "/" not in x[0]:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
143 if len(x[0].split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
144 t_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
145 t_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
146 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
147 t_templ+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
148 t_tem_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
149 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
150 f=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
151 for y in x[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
152 if len(y.split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
153 t_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
154 t_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
155 f=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
156 break
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
157 if f==0:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
158 t_templ+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
159 t_tem_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
160
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
161
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
162 fig = plt.figure()
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
163 labels = 'miRNA RefSeq','templated', 'unassigned'
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
164 sizes = [c_mat_counts, c_tem_counts, c_unmap_counts]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
165 colors = ['gold', 'yellowgreen', 'lightskyblue']
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
166 explode = (0.2, 0.05, 0.1)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
167 # Plot
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
168 ax1 = plt.subplot2grid((1,2),(0,0))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
169 patches, texts, autotexts=plt.pie(sizes, labels=labels, colors=colors, startangle=140,autopct='%1.1f%%',radius=0.8)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
170 [x.set_fontsize(10) for x in texts]
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
171 plt.title(group_name1.capitalize() + ' group (reads)', fontsize=12)
20
2eebd59cc5ea Uploaded
glogobyte
parents: 18
diff changeset
172 labels = 'miRNA RefSeq','templated', 'unassigned'
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
173 sizes = [t_mat_counts, t_tem_counts, t_unmap_counts]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
174 colors = ['gold', 'yellowgreen', 'lightskyblue']
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
175 explode = (0.2, 0.05, 0.1)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
176 # Plot
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
177 ax2 = plt.subplot2grid((1,2),(0,1))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
178 patches, texts, autotexts=plt.pie(sizes, labels=labels, colors=colors, startangle=140,autopct='%1.1f%%',radius=0.8)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
179 [x.set_fontsize(10) for x in texts]
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
180 plt.title(group_name2.capitalize() + ' group (reads)',fontsize = 12)
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
181 plt.savefig('pie_tem.png',dpi=300)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
182
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
183 ###################################################################################################################################################################################################################
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
184
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
185 def make_spider(merge_con,merge_tre,group_name1,group_name2):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
186
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
187 c_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge_con]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
188 t_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge_tre]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
189
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
190 c_5 = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
191 c_5_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
192 c_3 = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
193 c_3_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
194 c_both =0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
195 c_both_counts=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
196 c_mature = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
197 c_mat_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
198 c_exception=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
199 c_exception_counts=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
200
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
201
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
202 t_5 = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
203 t_5_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
204 t_3 = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
205 t_3_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
206 t_both = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
207 t_both_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
208 t_mature = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
209 t_mat_counts = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
210 t_exception = 0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
211 t_exception_counts=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
212
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
213 for x in c_samples:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
214
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
215 if "/" not in x[0]:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
216 if len(x[0].split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
217 c_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
218 c_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
219 elif 0 == int(x[0].split("_")[3]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
220 c_5+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
221 c_5_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
222 elif 0 == int(x[0].split("_")[4]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
223 c_3+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
224 c_3_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
225 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
226 c_both+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
227 c_both_counts+=x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
228
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
229 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
230 f=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
231 for y in x[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
232 if len(y.split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
233 c_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
234 c_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
235 f=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
236 break
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
237 if f==0:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
238 part=x[0].split("/")[0].split("_")[-2]+"_"+x[0].split("/")[0].split("_")[-1]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
239 num=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
240 for y in x[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
241 if y.split("_")[-2]+"_"+y.split("_")[-1]==part:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
242 num+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
243 if num==len(x[0].split("/")):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
244
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
245 if 0 == int(x[0].split("/")[0].split("_")[3]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
246 c_5+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
247 c_5_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
248 elif 0 == int(x[0].split("/")[0].split("_")[4]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
249 c_3+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
250 c_3_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
251 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
252 c_both+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
253 c_both_counts+=x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
254 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
255 c_exception+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
256 c_exception_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
257
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
258
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
259 for x in t_samples:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
260
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
261 if "/" not in x[0]:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
262 if len(x[0].split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
263 t_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
264 t_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
265 elif 0 == int(x[0].split("_")[3]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
266 t_5+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
267 t_5_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
268 elif 0 == int(x[0].split("_")[4]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
269 t_3+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
270 t_3_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
271 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
272 t_both+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
273 t_both_counts+=x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
274
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
275 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
276 f=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
277 for y in x[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
278 if len(y.split("_"))==2:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
279 t_mature+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
280 t_mat_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
281 f=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
282 break
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
283 if f==0:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
284 part=x[0].split("/")[0].split("_")[-2]+"_"+x[0].split("/")[0].split("_")[-1]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
285 num=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
286 for y in x[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
287 if y.split("_")[-2]+"_"+y.split("_")[-1]==part:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
288 num+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
289 if num==len(x[0].split("/")):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
290
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
291 if 0 == int(x[0].split("/")[0].split("_")[3]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
292 t_5+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
293 t_5_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
294 elif 0 == int(x[0].split("/")[0].split("_")[4]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
295 t_3+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
296 t_3_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
297 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
298 t_both+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
299 t_both_counts+=x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
300 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
301 t_exception+=1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
302 t_exception_counts += x[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
303
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
304
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
305 c_all = c_5+c_3+c_both+c_mature+c_exception
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
306 c_all_counts = c_5_counts + c_3_counts + c_both_counts + c_mat_counts + c_exception_counts
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
307
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
308 t_all = t_5+t_3+t_both+t_mature + t_exception
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
309 t_all_counts = t_5_counts + t_3_counts + t_both_counts + t_mat_counts + t_exception_counts
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
310
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
311 c_5 = round(c_5/c_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
312 c_3 = round(c_3/c_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
313 c_both = round(c_both/c_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
314 c_mature = round(c_mature/c_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
315 c_exception = round(c_exception/c_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
316
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
317 c_5_counts = round(c_5_counts/c_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
318 c_3_counts = round(c_3_counts/c_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
319 c_both_counts = round(c_both_counts/c_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
320 c_mat_counts = round(c_mat_counts/c_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
321 c_exception_counts = round(c_exception_counts/c_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
322
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
323 t_5 = round(t_5/t_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
324 t_3 = round(t_3/t_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
325 t_both = round(t_both/t_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
326 t_mature = round(t_mature/t_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
327 t_exception = round(t_exception/t_all*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
328
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
329 t_5_counts = round(t_5_counts/t_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
330 t_3_counts = round(t_3_counts/t_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
331 t_both_counts = round(t_both_counts/t_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
332 t_mat_counts = round(t_mat_counts/t_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
333 t_exception_counts = round(t_exception_counts/t_all_counts*100,2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
334
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
335 radar_max = max(c_5, c_3, c_both,c_mature,c_exception,t_5,t_3,t_both,t_mature,t_exception)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
336 radar_max_counts = max(c_5_counts,c_3_counts,c_both_counts,c_mat_counts,c_exception_counts,t_5_counts,t_3_counts,t_both_counts,t_mat_counts,t_exception_counts)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
337
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
338 df=pd.DataFrame({
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
339 'group':[group_name1.capitalize(),group_name2.capitalize()],
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
340 """5'3'-isomiRs""":[c_both,t_both],
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
341 """3'-isomiRs""":[c_3,t_3],
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
342 'RefSeq miRNA':[c_mature,t_mature],
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
343 """5'-isomiRs""":[c_5,t_5],
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
344 'others*':[c_exception,t_exception]})
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
345
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
346 df1=pd.DataFrame({
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
347 'group':[group_name1.capitalize(),group_name2.capitalize()],
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
348 """5'-3'-isomiRs""":[c_both_counts,t_both_counts],
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
349 """3'-isomiRs""":[c_3_counts,t_3_counts],
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
350 'RefSeq miRNA':[c_mat_counts,t_mat_counts],
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
351 """5'-isomiRs""":[c_5_counts,t_5_counts],
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
352 'others*':[c_exception_counts,t_exception_counts]})
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
353
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
354 spider_last(df,radar_max,1,group_name1,group_name2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
355 spider_last(df1,radar_max_counts,2,group_name1,group_name2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
356
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
357
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
358 ##############################################################################################################################################################################################################
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
359
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
360 def spider_last(df,radar_max,flag,group_name1,group_name2):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
361 # ------- PART 1: Create background
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
362 fig = plt.figure()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
363 # number of variable
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
364 categories=list(df)[1:]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
365 N = len(categories)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
366
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
367 # What will be the angle of each axis in the plot? (we divide the plot / number of variable)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
368 angles = [n / float(N) * 2 * pi for n in range(N)]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
369 angles += angles[:1]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
370
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
371 # Initialise the spider plot
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
372 ax = plt.subplot(111, polar=True)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
373
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
374 # If you want the first axis to be on top:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
375 ax.set_theta_offset(pi/2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
376 ax.set_theta_direction(-1)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
377
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
378 # Draw one axe per variable + add labels labels yet
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
379 plt.xticks(angles[:-1], categories, fontsize=13)
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
380
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
381 # Draw ylabels
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
382 radar_max=round(radar_max+radar_max*0.1)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
383 mul=len(str(radar_max))-1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
384 maxi=int(math.ceil(radar_max / pow(10,mul))) * pow(10,mul)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
385 sep = round(maxi/4)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
386 plt.yticks([sep, 2*sep, 3*sep, 4*sep, 5*sep], [str(sep)+'%', str(2*sep)+'%', str(3*sep)+'%', str(4*sep)+'%', str(5*sep)+'%'], color="grey", size=12)
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
387 plt.ylim(0, maxi)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
388
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
389 # ------- PART 2: Add plots
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
390
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
391 # Plot each individual = each line of the data
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
392 # I don't do a loop, because plotting more than 3 groups makes the chart unreadable
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
393
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
394 # Ind1
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
395 values=df.loc[0].drop('group').values.flatten().tolist()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
396 values += values[:1]
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
397 ax.plot(angles, values,'-o', linewidth=1, linestyle='solid', label=group_name1.capitalize())
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
398 ax.fill(angles, values, 'b', alpha=0.1)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
399
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
400 # Ind2
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
401 values=df.loc[1].drop('group').values.flatten().tolist()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
402 values += values[:1]
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
403 ax.plot(angles, values, '-o' ,linewidth=1, linestyle='solid', label=group_name2.capitalize())
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
404 ax.fill(angles, values, 'r', alpha=0.1)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
405
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
406 # Add legend
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
407 if flag==1:
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
408 plt.legend(loc='upper right', prop={'size': 11}, bbox_to_anchor=(0.0, 0.1))
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
409 plt.savefig('spider_non_red.png',dpi=300)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
410 else:
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
411 plt.legend(loc='upper right', prop={'size': 11}, bbox_to_anchor=(0.0, 0.1))
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
412 plt.savefig('spider_red.png',dpi=300)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
413
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
414 #############################################################################################################################################################################################################
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
415
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
416 def hist_red(samples,flag,group):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
417
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
418 lengths=[]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
419 cat=[]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
420 total_reads=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
421 seq=[]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
422
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
423 if flag == "c":
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
424 title = "Length distribution of "+group.lower()+" group (redundant reads)"
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
425 if flag == "t":
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
426 title = "Length distribution of "+group.lower()+" group (redundant reads)"
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
427
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
428 for i in samples:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
429 for x in i:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
430 lengths.append(x[3])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
431 if x[1]=="0":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
432 seq.append([x[3],x[0].split("-")[1],"Mapped"])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
433 cat.append("Mapped")
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
434 if x[1] == "4":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
435 seq.append([x[3],x[0].split("-")[1],"Unassigned"])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
436 cat.append("Unassigned")
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
437
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
438 uni_len=list(set(lengths))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
439 uni_len=[x for x in uni_len if x<=35]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
440 low=min(lengths)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
441 up=max(lengths)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
442 seq.sort()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
443 uni_seq=list(seq for seq,_ in itertools.groupby(seq))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
444 dim=up-low
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
445
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
446 if dim>20:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
447 s=5
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
448 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
449 s=8
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
450
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
451 total_reads+=sum([int(x[1]) for x in uni_seq])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
452
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
453 map_reads=[]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
454 unmap_reads=[]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
455 length=[]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
456 for y in uni_len:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
457 map_temp=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
458 unmap_temp=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
459 for x in uni_seq:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
460 if x[0]==y and x[2]=="Mapped":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
461 map_temp+=int(x[1])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
462 if x[0]==y and x[2]=="Unassigned":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
463 unmap_temp+=int(x[1])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
464 if y<=35:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
465 length.append(y)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
466 map_reads.append(round(map_temp/total_reads*100,2))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
467 unmap_reads.append(round(unmap_temp/total_reads*100,2))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
468
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
469 ylim=max([sum(x) for x in zip(unmap_reads, map_reads)])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
470 ylim=ylim+ylim*20/100
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
471 fig, ax = plt.subplots()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
472 width=0.8
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
473 ax.bar(length, unmap_reads, width, label='Unassigned')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
474 h=ax.bar(length, map_reads, width, bottom=unmap_reads, label='Mapped')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
475 plt.xticks(np.arange(length[0], length[-1]+1, 1))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
476 plt.yticks(np.arange(0, ylim, 5))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
477 plt.xlabel('Length (nt)',fontsize=14)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
478 plt.ylabel('Percentage',fontsize=14)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
479 plt.title(title,fontsize=14)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
480 ax.legend()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
481 plt.ylim([0, ylim])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
482 ax.grid(axis='y',linewidth=0.2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
483
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
484 if flag=='c':
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
485 plt.savefig('c_hist_red.png',dpi=300)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
486
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
487 if flag=='t':
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
488 plt.savefig('t_hist_red.png',dpi=300)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
489
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
490 ##############################################################################################################################################################################################################################################
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
491
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
492 def logo_seq_red(merge, flag, group):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
493
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
494 if flag=="c":
18
01679b6e886a Uploaded
glogobyte
parents: 17
diff changeset
495 titlos = group.capitalize() + " group (redundant)"
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
496 file_logo = "c_logo.png"
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
497 file_bar = "c_bar.png"
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
498 if flag=="t":
18
01679b6e886a Uploaded
glogobyte
parents: 17
diff changeset
499 titlos = group.capitalize() + " group (redundant)"
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
500 file_logo = "t_logo.png"
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
501 file_bar = "t_bar.png"
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
502
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
503 c_samples=[[x[0],x[1],sum(int(i) for i in x[2:])] for x in merge]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
504
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
505 A=[0]*3
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
506 C=[0]*3
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
507 G=[0]*3
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
508 T=[0]*3
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
509 total_reads=0
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
510
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
511 for y in c_samples:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
512 if "/" in y[0]:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
513 length=[]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
514 for x in y[0].split("/"):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
515 length.append([len(x.split("_")[-1]),x.split("_")[-1],y[2]])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
516
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
517 best=min(length)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
518 total_reads+=best[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
519 for i in range(3):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
520 if i<len(best[1]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
521 if best[1][i] == "A":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
522 A[i]+=best[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
523 elif best[1][i] == "C":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
524 C[i]+=best[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
525 elif best[1][i] == "G":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
526 G[i]+=best[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
527 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
528 T[i]+=best[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
529 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
530 total_reads+=y[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
531 for i in range(3):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
532 if i<len(y[0].split("_")[-1]):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
533 if y[0].split("_")[-1][i] == "A":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
534 A[i]+=(y[2])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
535 elif y[0].split("_")[-1][i] == "C":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
536 C[i]+=(y[2])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
537 elif y[0].split("_")[-1][i] == "G":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
538 G[i]+=(y[2])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
539 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
540 T[i]+=y[2]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
541
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
542 A[:] = [round(x*100,1) / total_reads for x in A]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
543 C[:] = [round(x*100,1) / total_reads for x in C]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
544 G[:] = [round(x*100,1) / total_reads for x in G]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
545 T[:] = [round(x*100,1) / total_reads for x in T]
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
546
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
547 data = {'A':A,'C':C,'G':G,'T':T}
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
548 df = pd.DataFrame(data, index=[1,2,3])
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
549
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
550 h=df.plot.bar(color=tuple(["g", "b","gold","r"]) )
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
551 h.grid(axis='y',linewidth=0.2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
552 plt.xticks(rotation=0, ha="right")
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
553 plt.ylabel("Counts (%)",fontsize=18)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
554 plt.xlabel("Numbers of additional nucleotides",fontsize=18)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
555 plt.title(titlos,fontsize=20)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
556 plt.tight_layout()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
557 plt.savefig(file_bar, dpi=300)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
558
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
559 crp_logo = lm.Logo(df, font_name = 'DejaVu Sans')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
560
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
561 crp_logo.style_spines(visible=False)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
562 crp_logo.style_spines(spines=['left', 'bottom'], visible=True)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
563 crp_logo.style_xticks(rotation=0, fmt='%d', anchor=0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
564 crp_logo.ax.set_title(titlos,fontsize=18)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
565 crp_logo.ax.set_ylabel("Counts (%)", fontsize=16,labelpad=5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
566 crp_logo.ax.set_xlabel("Numbers of additional nucleotides",fontsize=16, labelpad=5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
567 crp_logo.ax.xaxis.set_ticks_position('none')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
568 crp_logo.ax.xaxis.set_tick_params(pad=-1)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
569 figure = plt.gcf()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
570 figure.set_size_inches(6, 4)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
571 crp_logo.fig.savefig(file_logo,dpi=300)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
572
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
573 ##########################################################################################################################################################################################################
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
574
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
575 def pdf_before_DE(analysis,group_name1,group_name2):
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
576
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
577 # Image extensions
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
578 if analysis=="2":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
579 image_extensions = ("c_hist_red.png","t_hist_red.png","pie_non.png","spider_red.png","spider_non_red.png","c_logo.png","t_logo.png","c_bar.png","t_bar.png")
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
580 else:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
581 image_extensions = ("c_hist_red.png","t_hist_red.png","pie_tem.png","spider_red.png","spider_non_red.png")
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
582 # This list will hold the images file names
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
583 images = []
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
584
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
585 # Build the image list by merging the glob results (a list of files)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
586 # for each extension. We are taking images from current folder.
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
587 for extension in image_extensions:
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
588 images.extend(glob.glob(extension))
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
589 #sys.exit(images)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
590 # Create instance of FPDF class
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
591 pdf = FPDF('P', 'in', 'A4')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
592 # Add new page. Without this you cannot create the document.
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
593 pdf.add_page()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
594 # Set font to Arial, 'B'old, 16 pts
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
595 pdf.set_font('Arial', 'B', 20.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
596
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
597 # Page header
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
598 pdf.cell(pdf.w-0.5, 0.5, 'IsomiR profile report',align='C')
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
599 pdf.ln(0.7)
26
0bf751c64fe9 Uploaded
glogobyte
parents: 24
diff changeset
600 pdf.set_font('Arial','B', 16.0)
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
601 pdf.cell(pdf.w-0.5, 0.5, 'sRNA length distribution',align='C')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
602
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
603 # Smaller font for image captions
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
604 pdf.set_font('Arial', '', 11.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
605
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
606 # Image caption
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
607 pdf.ln(0.5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
608
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
609 yh=FPDF.get_y(pdf)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
610 pdf.image(images[0],x=0.3,w=4, h=3)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
611 pdf.image(images[1],x=4,y=yh, w=4, h=3)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
612 pdf.ln(0.3)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
613
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
614 # Image caption
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
615 pdf.cell(0.2)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
616 pdf.cell(3.0, 0.0, " Mapped and unmapped reads to custom precursor arm reference DB (5p and 3p arms) in "+group_name1.lower())
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
617 pdf.ln(0.2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
618 pdf.cell(0.2)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
619 pdf.cell(3.0, 0.0, " (left) and "+group_name2.lower()+" (right) groups")
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
620
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
621
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
622 pdf.ln(0.5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
623 h1=FPDF.get_y(pdf)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
624 pdf.image(images[2],x=1, w=6.5, h=5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
625 h2=FPDF.get_y(pdf)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
626 FPDF.set_y(pdf,h1+0.2)
24
1d8cdfb3a359 Uploaded
glogobyte
parents: 20
diff changeset
627 pdf.set_font('Arial','B', 16.0)
1d8cdfb3a359 Uploaded
glogobyte
parents: 20
diff changeset
628 if analysis=="2":
1d8cdfb3a359 Uploaded
glogobyte
parents: 20
diff changeset
629 pdf.cell(pdf.w-0.5, 0.5, 'Templated and non-templated isomiRs',align='C')
1d8cdfb3a359 Uploaded
glogobyte
parents: 20
diff changeset
630 else:
1d8cdfb3a359 Uploaded
glogobyte
parents: 20
diff changeset
631 pdf.cell(pdf.w-0.5, 0.5, 'Templated isomiRs',align='C')
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
632 pdf.set_font('Arial', '', 11.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
633 FPDF.set_y(pdf,h2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
634 FPDF.set_y(pdf,9.5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
635 # Image caption
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
636 pdf.cell(0.2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
637 if analysis=="2":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
638 pdf.cell(3.0, 0.0, " RefSeq miRNAs, templated isomiRs, non-templated isomiRs and unassigned sequences as percentage")
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
639 pdf.ln(0.2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
640 pdf.cell(0.2)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
641 pdf.cell(3.0, 0.0, " of total sRNA reads in "+group_name1.lower()+" (left) and "+group_name2.lower()+" (right) groups")
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
642
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
643 else:
24
1d8cdfb3a359 Uploaded
glogobyte
parents: 20
diff changeset
644 pdf.cell(3.0, 0.0, " RefSeq miRNAS, templated isomiRs and unassigned sequences as percentage of total sRNA reads in")
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
645 pdf.ln(0.2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
646 pdf.cell(0.2)
17
0cdc0c3c821e Uploaded
glogobyte
parents: 6
diff changeset
647 pdf.cell(3.0, 0.0, " "+group_name1.lower()+" (left) and "+group_name2.lower()+" (right) groups")
6
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
648
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
649 pdf.add_page()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
650 pdf.set_font('Arial', 'B', 18.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
651 pdf.cell(pdf.w-0.5, 0.5, "Templated isomiR subtypes",align='C')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
652 pdf.ln(0.7)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
653 pdf.set_font('Arial', 'B', 14.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
654 pdf.cell(pdf.w-0.5, 0.5, "Templated isomiR profile (redundant reads)",align='C')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
655 pdf.ln(0.5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
656 pdf.image(images[3],x=1.5, w=5.5, h=4)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
657 pdf.ln(0.6)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
658 pdf.cell(pdf.w-0.5, 0.0, "Templated isomiR profile (non-redundant reads)",align='C')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
659 pdf.set_font('Arial', '', 12.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
660 pdf.ln(0.2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
661 pdf.image(images[4],x=1.5, w=5.5, h=4)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
662 pdf.ln(0.3)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
663 pdf.set_font('Arial', '', 11.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
664 pdf.cell(0.2)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
665 pdf.cell(3.0, 0.0, " * IsomiRs potentially generated from multiple loci")
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
666
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
667 if analysis=="2":
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
668 pdf.add_page('L')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
669
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
670 pdf.set_font('Arial', 'B', 18.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
671 pdf.cell(pdf.w-0.5, 0.5, "Non-templated isomiRs",align='C')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
672 pdf.ln(0.5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
673 pdf.set_font('Arial', 'B', 14.0)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
674 pdf.cell(pdf.w-0.5, 0.5, "3'-end additions to RefSeq miRNAs and templated isomiRs",align='C')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
675 pdf.ln(0.7)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
676
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
677 yh=FPDF.get_y(pdf)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
678 pdf.image(images[5],x=1.5,w=3.65, h=2.65)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
679 pdf.image(images[7],x=6.5,y=yh, w=3.65, h=2.65)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
680 pdf.ln(0.5)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
681 yh=FPDF.get_y(pdf)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
682 pdf.image(images[6],x=1.5,w=3.65, h=2.65)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
683 pdf.image(images[8],x=6.5,y=yh, w=3.65, h=2.65)
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
684
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
685 pdf.close()
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
686 pdf.output('report1.pdf','F')
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
687
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
688 #############################################################################################################################################################3
d58f050acd18 Uploaded
glogobyte
parents:
diff changeset
689