Mercurial > repos > mheinzl > fsd
comparison fsd.py @ 41:54f0dac1c834 draft
planemo upload for repository https://github.com/monikaheinzl/duplexanalysis_galaxy/tree/master/tools/fsd commit 033dd7b750f68e8aa68f327d7d72bd311ddbee4e-dirty
author | mheinzl |
---|---|
date | Wed, 14 Aug 2019 04:30:58 -0400 |
parents | 00f5ca6bb610 |
children | 321a4871564b |
comparison
equal
deleted
inserted
replaced
40:948064d8714e | 41:54f0dac1c834 |
---|---|
112 | 112 |
113 legend3b = "PE reads\n{:,} ({:.3f})".format(numpy.bincount(data1)[1], float(numpy.bincount(data1)[1]) / sum(integers)) | 113 legend3b = "PE reads\n{:,} ({:.3f})".format(numpy.bincount(data1)[1], float(numpy.bincount(data1)[1]) / sum(integers)) |
114 fig.text(0.45, 0.11, legend3b, size=10, transform=plt.gcf().transFigure) | 114 fig.text(0.45, 0.11, legend3b, size=10, transform=plt.gcf().transFigure) |
115 fig2.text(0.45, 0.11, legend3b, size=10, transform=plt.gcf().transFigure) | 115 fig2.text(0.45, 0.11, legend3b, size=10, transform=plt.gcf().transFigure) |
116 | 116 |
117 legend4 = "family size > 20:\nnr. of tags\n{:,} ({:.3f})".format(numpy.bincount(data1)[len(numpy.bincount(data1)) - 1].astype(int), float(numpy.bincount(data1)[len(numpy.bincount(data1)) - 1]) / len(data1)) | 117 legend4 = "family size > 20:\nnr. of tags\n{:,} ({:.3f})".format(len(integers[integers > 20]), |
118 float(sum(integers[integers > 20])) | |
119 / sum(integers)) | |
118 fig.text(0.58, 0.11, legend4, size=10, transform=plt.gcf().transFigure) | 120 fig.text(0.58, 0.11, legend4, size=10, transform=plt.gcf().transFigure) |
119 fig2.text(0.58, 0.11, legend4, size=10, transform=plt.gcf().transFigure) | 121 fig2.text(0.58, 0.11, legend4, size=10, transform=plt.gcf().transFigure) |
120 | 122 |
121 legend5 = "PE reads\n{:,} ({:.3f})".format(sum(integers[integers > 20]), float(sum(integers[integers > 20])) / sum(integers)) | 123 legend5 = "PE reads\n{:,} ({:.3f})".format(sum(integers[integers > 20]), float(sum(integers[integers > 20])) / sum(integers)) |
122 fig.text(0.70, 0.11, legend5, size=10, transform=plt.gcf().transFigure) | 124 fig.text(0.70, 0.11, legend5, size=10, transform=plt.gcf().transFigure) |
155 | 157 |
156 legend3 = "{:,} ({:.3f})".format(numpy.bincount(data2)[1], float(numpy.bincount(data2)[1]) / sum(integers2)) | 158 legend3 = "{:,} ({:.3f})".format(numpy.bincount(data2)[1], float(numpy.bincount(data2)[1]) / sum(integers2)) |
157 fig.text(0.45, 0.09, legend3, size=10, transform=plt.gcf().transFigure) | 159 fig.text(0.45, 0.09, legend3, size=10, transform=plt.gcf().transFigure) |
158 fig2.text(0.45, 0.09, legend3, size=10, transform=plt.gcf().transFigure) | 160 fig2.text(0.45, 0.09, legend3, size=10, transform=plt.gcf().transFigure) |
159 | 161 |
160 legend4 = "{:,} ({:.3f})".format( | 162 legend4 = "{:,} ({:.3f})".format(len(integers2[integers2 > 20]), float(sum(integers2[integers2 > 20])) / sum(integers2)) |
161 numpy.bincount(data2)[len(numpy.bincount(data2)) - 1].astype(int), | |
162 float(numpy.bincount(data2)[len(numpy.bincount(data2)) - 1]) / len(data2)) | |
163 fig.text(0.58, 0.09, legend4, size=10, transform=plt.gcf().transFigure) | 163 fig.text(0.58, 0.09, legend4, size=10, transform=plt.gcf().transFigure) |
164 fig2.text(0.58, 0.09, legend4, size=10, transform=plt.gcf().transFigure) | 164 fig2.text(0.58, 0.09, legend4, size=10, transform=plt.gcf().transFigure) |
165 | 165 |
166 legend5 = "{:,} ({:.3f})".format(sum(integers2[integers2 > 20]), float(sum(integers2[integers2 > 20])) / sum(integers2)) | 166 legend5 = "{:,} ({:.3f})".format(sum(integers2[integers2 > 20]), float(sum(integers2[integers2 > 20])) / sum(integers2)) |
167 fig.text(0.70, 0.09, legend5, size=10, transform=plt.gcf().transFigure) | 167 fig.text(0.70, 0.09, legend5, size=10, transform=plt.gcf().transFigure) |
200 | 200 |
201 legend3b = "{:,} ({:.3f})".format(numpy.bincount(data3)[1], float(numpy.bincount(data3)[1]) / sum(integers3)) | 201 legend3b = "{:,} ({:.3f})".format(numpy.bincount(data3)[1], float(numpy.bincount(data3)[1]) / sum(integers3)) |
202 fig.text(0.45, 0.07, legend3b, size=10, transform=plt.gcf().transFigure) | 202 fig.text(0.45, 0.07, legend3b, size=10, transform=plt.gcf().transFigure) |
203 fig2.text(0.45, 0.07, legend3b, size=10, transform=plt.gcf().transFigure) | 203 fig2.text(0.45, 0.07, legend3b, size=10, transform=plt.gcf().transFigure) |
204 | 204 |
205 legend4 = "{:,} ({:.3f})".format( | 205 legend4 = "{:,} ({:.3f})".format(len(integers3[integers3 > 20]), float(sum(integers3[integers3 > 20])) / sum(integers3)) |
206 numpy.bincount(data3)[len(numpy.bincount(data3)) - 1].astype(int), | |
207 float(numpy.bincount(data3)[len(numpy.bincount(data3)) - 1]) / len(data3)) | |
208 fig.text(0.58, 0.07, legend4, size=10, transform=plt.gcf().transFigure) | 206 fig.text(0.58, 0.07, legend4, size=10, transform=plt.gcf().transFigure) |
209 fig2.text(0.58, 0.07, legend4, size=10, transform=plt.gcf().transFigure) | 207 fig2.text(0.58, 0.07, legend4, size=10, transform=plt.gcf().transFigure) |
210 | 208 |
211 legend5 = "{:,} ({:.3f})".format(sum(integers3[integers3 > 20]), | 209 legend5 = "{:,} ({:.3f})".format(sum(integers3[integers3 > 20]), |
212 float(sum(integers3[integers3 > 20])) / sum(integers3)) | 210 float(sum(integers3[integers3 > 20])) / sum(integers3)) |
245 | 243 |
246 legend3b = "{:,} ({:.3f})".format(numpy.bincount(data4)[1], float(numpy.bincount(data4)[1]) / sum(integers4)) | 244 legend3b = "{:,} ({:.3f})".format(numpy.bincount(data4)[1], float(numpy.bincount(data4)[1]) / sum(integers4)) |
247 fig.text(0.45, 0.05, legend3b, size=10, transform=plt.gcf().transFigure) | 245 fig.text(0.45, 0.05, legend3b, size=10, transform=plt.gcf().transFigure) |
248 fig2.text(0.45, 0.05, legend3b, size=10, transform=plt.gcf().transFigure) | 246 fig2.text(0.45, 0.05, legend3b, size=10, transform=plt.gcf().transFigure) |
249 | 247 |
250 legend4 = "{:,} ({:.3f})".format( | 248 legend4 = "{:,} ({:.3f})".format(len(integers4[integers4 > 20]), float(sum(integers4[integers4 > 20])) / sum(integers4)) |
251 numpy.bincount(data4)[len(numpy.bincount(data4)) - 1].astype(int), | |
252 float(numpy.bincount(data4)[len(numpy.bincount(data4)) - 1]) / len(data4)) | |
253 fig.text(0.58, 0.05, legend4, size=10, transform=plt.gcf().transFigure) | 249 fig.text(0.58, 0.05, legend4, size=10, transform=plt.gcf().transFigure) |
254 fig2.text(0.58, 0.05, legend4, size=10, transform=plt.gcf().transFigure) | 250 fig2.text(0.58, 0.05, legend4, size=10, transform=plt.gcf().transFigure) |
255 | 251 |
256 legend5 = "{:,} ({:.3f})".format(sum(integers4[integers4 > 20]), | 252 legend5 = "{:,} ({:.3f})".format(sum(integers4[integers4 > 20]), |
257 float(sum(integers4[integers4 > 20])) / sum(integers4)) | 253 float(sum(integers4[integers4 > 20])) / sum(integers4)) |
284 if to_plot[l] == "Relative frequencies": | 280 if to_plot[l] == "Relative frequencies": |
285 w = [numpy.zeros_like(data) + 1. / len(data) for data in list_to_plot2] | 281 w = [numpy.zeros_like(data) + 1. / len(data) for data in list_to_plot2] |
286 counts_rel = ax.hist(list_to_plot2, weights=w, | 282 counts_rel = ax.hist(list_to_plot2, weights=w, |
287 bins=numpy.arange(1, 23), stacked=False, edgecolor="black", | 283 bins=numpy.arange(1, 23), stacked=False, edgecolor="black", |
288 linewidth=1, label=label, align="left", alpha=0.7, rwidth=0.8) | 284 linewidth=1, label=label, align="left", alpha=0.7, rwidth=0.8) |
285 ax.set_ylim(0, 1.07) | |
289 else: | 286 else: |
290 counts = ax.hist(list_to_plot2, bins=numpy.arange(minimumX, maximumX + 2), stacked=False, edgecolor="black", linewidth=1, label=label, align="left", alpha=0.7, rwidth=0.8, color=colors) | 287 counts = ax.hist(list_to_plot2, bins=numpy.arange(minimumX, maximumX + 2), stacked=False, edgecolor="black", linewidth=1, label=label, align="left", alpha=0.7, rwidth=0.8, color=colors) |
291 ax.legend(loc='upper right', fontsize=14, frameon=True, bbox_to_anchor=(0.9, 1)) | 288 ax.legend(loc='upper right', fontsize=14, frameon=True, bbox_to_anchor=(0.9, 1)) |
292 | 289 |
293 ax.set_xticks(numpy.array(ticks)) | 290 ax.set_xticks(numpy.array(ticks)) |
325 else: | 322 else: |
326 c_idx = numpy.where(t == unique)[0] | 323 c_idx = numpy.where(t == unique)[0] |
327 new_c.append(c[c_idx]) | 324 new_c.append(c[c_idx]) |
328 new_unique.append(unique[c_idx]) | 325 new_unique.append(unique[c_idx]) |
329 y = numpy.array(new_unique) * numpy.array(new_c) | 326 y = numpy.array(new_unique) * numpy.array(new_c) |
330 if len([list_to_plot_original > 20]) > 0: | 327 if sum(list_to_plot_original[i] > 20) > 0: |
331 y[len(y) - 1] = sum(list_to_plot_original[i][list_to_plot_original[i] > 20]) | 328 y[len(y) - 1] = sum(list_to_plot_original[i][list_to_plot_original[i] > 20]) |
329 # y = [y[x[idx] == unique][0] if x[idx] in unique else 0 for idx in range(len(x))] | |
332 reads.append(y) | 330 reads.append(y) |
333 reads_rel.append(list(numpy.float_(y)) / sum(y)) | 331 reads_rel.append(list(numpy.float_(y)) / sum(y)) |
334 | 332 |
335 x = list(numpy.arange(numpy.amin(unique), numpy.amax(unique) + 1).astype(float)) | 333 x = list(numpy.arange(numpy.amin(unique), numpy.amax(unique) + 1).astype(float)) |
336 if len(list_to_plot2) == 1: | 334 if len(list_to_plot2) == 1: |
341 w = 1./(len(list_to_plot) + 1) | 339 w = 1./(len(list_to_plot) + 1) |
342 | 340 |
343 if to_plot[l] == "Relative frequencies": | 341 if to_plot[l] == "Relative frequencies": |
344 counts2_rel = ax.bar(x, list(numpy.float_(y)) / numpy.sum(y), align="edge", width=w, | 342 counts2_rel = ax.bar(x, list(numpy.float_(y)) / numpy.sum(y), align="edge", width=w, |
345 edgecolor="black", label=label[i],linewidth=1, alpha=0.7, color=colors[i]) | 343 edgecolor="black", label=label[i],linewidth=1, alpha=0.7, color=colors[i]) |
346 | 344 ax.set_ylim(0, 1.07) |
347 else: | 345 else: |
348 y = list(y.reshape((len(y)))) | 346 y = list(y.reshape((len(y)))) |
349 | 347 |
350 counts2 = ax.bar(x, y, align="edge", width=w, edgecolor="black", label=label[i], linewidth=1, | 348 counts2 = ax.bar(x, y, align="edge", width=w, edgecolor="black", label=label[i], linewidth=1, |
351 alpha=0.7, color=colors[i]) | 349 alpha=0.7, color=colors[i]) |