changeset 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 948064d8714e
children 321a4871564b
files fsd.py fsd.xml test-data/fsd_output1.pdf test-data/fsd_output2.pdf
diffstat 4 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/fsd.py	Wed Jul 24 05:50:06 2019 -0400
+++ b/fsd.py	Wed Aug 14 04:30:58 2019 -0400
@@ -114,7 +114,9 @@
             fig.text(0.45, 0.11, legend3b, size=10, transform=plt.gcf().transFigure)
             fig2.text(0.45, 0.11, legend3b, size=10, transform=plt.gcf().transFigure)
 
-            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))
+            legend4 = "family size > 20:\nnr. of tags\n{:,} ({:.3f})".format(len(integers[integers > 20]),
+                                                                             float(sum(integers[integers > 20]))
+                                                                             / sum(integers))            
             fig.text(0.58, 0.11, legend4, size=10, transform=plt.gcf().transFigure)
             fig2.text(0.58, 0.11, legend4, size=10, transform=plt.gcf().transFigure)
 
@@ -157,9 +159,7 @@
             fig.text(0.45, 0.09, legend3, size=10, transform=plt.gcf().transFigure)
             fig2.text(0.45, 0.09, legend3, size=10, transform=plt.gcf().transFigure)
 
-            legend4 = "{:,} ({:.3f})".format(
-                numpy.bincount(data2)[len(numpy.bincount(data2)) - 1].astype(int),
-                float(numpy.bincount(data2)[len(numpy.bincount(data2)) - 1]) / len(data2))
+            legend4 = "{:,} ({:.3f})".format(len(integers2[integers2 > 20]), float(sum(integers2[integers2 > 20])) / sum(integers2))
             fig.text(0.58, 0.09, legend4, size=10, transform=plt.gcf().transFigure)
             fig2.text(0.58, 0.09, legend4, size=10, transform=plt.gcf().transFigure)
 
@@ -202,9 +202,7 @@
             fig.text(0.45, 0.07, legend3b, size=10, transform=plt.gcf().transFigure)
             fig2.text(0.45, 0.07, legend3b, size=10, transform=plt.gcf().transFigure)
 
-            legend4 = "{:,} ({:.3f})".format(
-                numpy.bincount(data3)[len(numpy.bincount(data3)) - 1].astype(int),
-                float(numpy.bincount(data3)[len(numpy.bincount(data3)) - 1]) / len(data3))
+            legend4 = "{:,} ({:.3f})".format(len(integers3[integers3 > 20]), float(sum(integers3[integers3 > 20])) / sum(integers3))
             fig.text(0.58, 0.07, legend4, size=10, transform=plt.gcf().transFigure)
             fig2.text(0.58, 0.07, legend4, size=10, transform=plt.gcf().transFigure)
 
@@ -247,9 +245,7 @@
             fig.text(0.45, 0.05, legend3b, size=10, transform=plt.gcf().transFigure)
             fig2.text(0.45, 0.05, legend3b, size=10, transform=plt.gcf().transFigure)
 
-            legend4 = "{:,} ({:.3f})".format(
-                numpy.bincount(data4)[len(numpy.bincount(data4)) - 1].astype(int),
-                float(numpy.bincount(data4)[len(numpy.bincount(data4)) - 1]) / len(data4))
+            legend4 = "{:,} ({:.3f})".format(len(integers4[integers4 > 20]), float(sum(integers4[integers4 > 20])) / sum(integers4))
             fig.text(0.58, 0.05, legend4, size=10, transform=plt.gcf().transFigure)
             fig2.text(0.58, 0.05, legend4, size=10, transform=plt.gcf().transFigure)
 
@@ -286,6 +282,7 @@
                 counts_rel = ax.hist(list_to_plot2, weights=w,
                                      bins=numpy.arange(1, 23), stacked=False, edgecolor="black",
                                      linewidth=1, label=label, align="left", alpha=0.7, rwidth=0.8)
+                ax.set_ylim(0, 1.07)
             else:
                 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)
                 ax.legend(loc='upper right', fontsize=14, frameon=True, bbox_to_anchor=(0.9, 1))
@@ -327,8 +324,9 @@
                         new_c.append(c[c_idx])
                         new_unique.append(unique[c_idx])
                 y = numpy.array(new_unique) * numpy.array(new_c)
-                if len([list_to_plot_original > 20]) > 0:
+                if sum(list_to_plot_original[i] > 20) > 0:
                     y[len(y) - 1] = sum(list_to_plot_original[i][list_to_plot_original[i] > 20])
+                # y = [y[x[idx] == unique][0] if x[idx] in unique else 0 for idx in range(len(x))]
                 reads.append(y)
                 reads_rel.append(list(numpy.float_(y)) / sum(y))
 
@@ -343,7 +341,7 @@
                 if to_plot[l] == "Relative frequencies":
                     counts2_rel = ax.bar(x, list(numpy.float_(y)) / numpy.sum(y), align="edge", width=w,
                                          edgecolor="black", label=label[i],linewidth=1, alpha=0.7, color=colors[i])
-                    
+                    ax.set_ylim(0, 1.07)
                 else:
                     y = list(y.reshape((len(y))))
                     
--- a/fsd.xml	Wed Jul 24 05:50:06 2019 -0400
+++ b/fsd.xml	Wed Aug 14 04:30:58 2019 -0400
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- galaxy version 16.04 -->
-<tool id="fsd" name="FSD" version="1.0.1">
+<tool id="fsd" name="FSD" version="1.0.2">
     <description>: Family Size Distribution of duplex sequencing tags</description>
     <requirements>
         <requirement type="package" version="2.7">python</requirement>
Binary file test-data/fsd_output1.pdf has changed
Binary file test-data/fsd_output2.pdf has changed