changeset 0:fe542273784f draft default tip

Uploaded
author bgruening
date Thu, 15 Aug 2013 03:39:14 -0400
parents
children
files mds_plot.py mds_plot.xml static/images/mds_plot.png test_data/mds_plot_on_sm_dat.png test_data/sm.dat tool_dependencies.xml
diffstat 6 files changed, 96 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mds_plot.py	Thu Aug 15 03:39:14 2013 -0400
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import argparse
+import os
+import sklearn.manifold
+import numpy
+import math
+import pylab
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(
+        description="""2D multidimenisnal scaling of NxN matrices with scatter plot"""
+        )
+
+    parser.add_argument("-i", "--input", dest="sm",
+                    required=True,
+                    help="Path to the input file.")
+    parser.add_argument("--oformat", default='png', help="Output format (png, svg)")
+    parser.add_argument("-o", "--output", dest="output_path",
+                    help="Path to the output file.")
+
+    args = parser.parse_args()
+    mds = sklearn.manifold.MDS( n_components=2, max_iter=300, eps=1e-6, dissimilarity='precomputed' )
+    data = numpy.fromfile( args.sm )
+    d = math.sqrt( len(data) )
+    sm = numpy.reshape( data, ( d,d ))
+    pos = mds.fit( sm ).embedding_
+    pylab.scatter( pos[:,0],pos[:,1] )
+    pylab.savefig( args.output_path, format=args.oformat )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mds_plot.xml	Thu Aug 15 03:39:14 2013 -0400
@@ -0,0 +1,52 @@
+<tool id="ctb_mds_plot" name="MDS Scatter Plot" version="0.1">
+    <description>of molecule similarity</description>
+    <requirements>
+        <requirement type="package" version="0.13.1">scikit_learn</requirement>
+        <requirement type="package" version="1.2.1">matplotlib</requirement>
+    </requirements>
+    <command interpreter='python'>
+        mds_plot.py
+            -i $infile
+            --oformat $oformat
+            -o $outfile
+    </command>
+    <inputs>
+        <param name="infile" type="data" format="binary" label="Similarity Matrix"/>
+        <param name='oformat' type='select' format='text' label="Format of the resulting picture">
+            <option value='png'>PNG</option>
+            <option value='svg'>SVG</option>
+        </param>
+    </inputs>
+    <outputs>
+        <data type="data" format="png" name="outfile" label="${tool.name} on ${on_string}"></data>
+    </outputs>
+    <tests>
+        <test>
+            <param name="infile" ftype="tabular" value="sm.dat" />
+            <output ftype="png" name="outfile" file='mds_plot_on_sm_dat.png' />
+        </test>
+    </tests>
+    <help>
+
+**Note**. You need an NxN similarity matrix as input. Use the NxN Clustering tool to generate one.
+
+**What it does**
+
+Scatter plot of similarity matrix after embeding in 2D coordinates using Multidimensional Scaling (MDS).
+
+-----
+
+**Example**
+
+* input::
+    Similarity Matrix
+
+* output::
+
+	Scatter plot
+
+.. image:: $PATH_TO_IMAGES/mds_plot.png
+
+    </help>
+
+</tool>
Binary file static/images/mds_plot.png has changed
Binary file test_data/mds_plot_on_sm_dat.png has changed
Binary file test_data/sm.dat has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Thu Aug 15 03:39:14 2013 -0400
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <package name="numpy" version="1.7.1">
+        <repository changeset_revision="74c21f9bdc39" name="package_numpy_1_7" owner="iuc" prior_installation_required="True" toolshed="http://toolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="matplotlib" version="1.2.1">
+        <repository changeset_revision="9d164359606b" name="package_matplotlib_1_2" owner="iuc" prior_installation_required="True" toolshed="http://toolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="scipy" version="0.12.0">
+        <repository changeset_revision="aa5180c893f5" name="package_scipy_0_12" owner="iuc" prior_installation_required="True" toolshed="http://toolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="scikit_learn" version="0.13.1">
+        <repository changeset_revision="76f69ae982b8" name="package_scikit_learn_0_13" owner="iuc" prior_installation_required="True" toolshed="http://toolshed.g2.bx.psu.edu" />
+    </package>
+</tool_dependency>