comparison fsd.py @ 22:5e650e66e058 draft

planemo upload for repository https://github.com/monikaheinzl/duplexanalysis_galaxy/tree/master/tools/fsd commit b8a2f7b7615b2bcd3b602027af31f4e677da94f6-dirty
author mheinzl
date Tue, 21 May 2019 08:17:02 -0400
parents 89ddbe5ae2aa
children 5ae4fd1d4a12
comparison
equal deleted inserted replaced
21:89ddbe5ae2aa 22:5e650e66e058
328 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 reads.append(y) 329 reads.append(y)
330 reads_rel.append(list(numpy.float_(y)) / sum(y)) 330 reads_rel.append(list(numpy.float_(y)) / sum(y))
331 331
332 x = list(numpy.arange(numpy.amin(unique), numpy.amax(unique) + 1).astype(float)) 332 x = list(numpy.arange(numpy.amin(unique), numpy.amax(unique) + 1).astype(float))
333 x = [xi + barWidth for xi in x] 333 if len(list_to_plot2) == 1:
334 x = [xi * 0.5 for xi in x]
335 w = 0.4
336 else:
337 x = [xi + barWidth for xi in x]
338 w = 1./(len(list_to_plot) + 1)
334 339
335 if to_plot[l] == "Relative frequencies": 340 if to_plot[l] == "Relative frequencies":
336 counts2_rel = ax.bar(x, list(numpy.float_(y)) / sum(y), align="edge", width=1./(len(list_to_plot) + 1), 341 counts2_rel = ax.bar(x, list(numpy.float_(y)) / sum(y), align="edge", width=w,
337 edgecolor="black", label=label[i], alpha=0.8, linewidth=1, color=colors[i]) 342 edgecolor="black", label=label[i], alpha=0.8, linewidth=1, color=colors[i])
338 else: 343 else:
339 counts2 = ax.bar(x, y, align="edge", width=1./(len(list_to_plot) + 1), edgecolor="black", label=label[i], 344 counts2 = ax.bar(x, y, align="edge", width=w, edgecolor="black", label=label[i],
340 alpha=0.8, linewidth=1, color=colors[i]) 345 alpha=0.8, linewidth=1, color=colors[i])
341 if i == len(list_to_plot2): 346 if i == len(list_to_plot2):
342 barWidth += 1. / (len(list_to_plot) + 1) + 1. / (len(list_to_plot) + 1) 347 barWidth += 1. / (len(list_to_plot) + 1) + 1. / (len(list_to_plot) + 1)
343 else: 348 else:
344 barWidth += 1. / (len(list_to_plot) + 1) 349 barWidth += 1. / (len(list_to_plot) + 1)
346 if to_plot[l] == "Absolute frequencies": 351 if to_plot[l] == "Absolute frequencies":
347 ax.legend(loc='upper right', fontsize=14, frameon=True, bbox_to_anchor=(0.9, 1)) 352 ax.legend(loc='upper right', fontsize=14, frameon=True, bbox_to_anchor=(0.9, 1))
348 else: 353 else:
349 ax.set_xlabel("Family size", fontsize=14) 354 ax.set_xlabel("Family size", fontsize=14)
350 355
351 ax.set_xticks(numpy.array(ticks)) 356 if len(list_to_plot2) == 1:
357 ax.set_xticks(numpy.array([xi + 0.2 for xi in x]))
358 else:
359 ax.set_xticks(numpy.array(ticks))
352 ax.set_xticklabels(ticks1) 360 ax.set_xticklabels(ticks1)
353 ax.set_ylabel(to_plot[l], fontsize=14) 361 ax.set_ylabel(to_plot[l], fontsize=14)
354 if log_axis: 362 if log_axis:
355 ax.set_yscale('log') 363 ax.set_yscale('log')
356 ax.grid(b=True, which="major", color="#424242", linestyle=":") 364 ax.grid(b=True, which="major", color="#424242", linestyle=":")
408 output_file.write("{}{}".format(int(reads[n][j]), sep)) 416 output_file.write("{}{}".format(int(reads[n][j]), sep))
409 output_file.write("\n") 417 output_file.write("\n")
410 j += 1 418 j += 1
411 output_file.write("sum{}".format(sep)) 419 output_file.write("sum{}".format(sep))
412 if len(label) == 1: 420 if len(label) == 1:
413 output_file.write("{}{}".format(int(sum(reads)), sep)) 421 output_file.write("{}{}".format(int(sum(numpy.concatenate(reads))), sep))
414 else: 422 else:
415 for i in reads: 423 for i in reads:
416 output_file.write("{}{}".format(int(sum(i)), sep)) 424 output_file.write("{}{}".format(int(sum(i)), sep))
417 output_file.write("\n") 425 output_file.write("\n")
418 426