plot the parameter vector in a useful way
authorong <ong@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Wed, 16 Jan 2008 15:42:54 +0000 (15:42 +0000)
committerong <ong@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Wed, 16 Jan 2008 15:42:54 +0000 (15:42 +0000)
git-svn-id: http://svn.tuebingen.mpg.de/ag-raetsch/projects/QPalma@7398 e1793c9e-67f9-0310-80fc-b846ff1f7b36

tools/plot_param.py [new file with mode: 0644]

diff --git a/tools/plot_param.py b/tools/plot_param.py
new file mode 100644 (file)
index 0000000..f1c921c
--- /dev/null
@@ -0,0 +1,65 @@
+
+"""A tool to visualise the parameter vector of QPalma"""
+
+import pylab
+import cPickle
+import numpy
+import sys
+
+from set_param_palma import set_param_palma
+import Configuration
+
+# remember to check for consistency with Configuration.py
+
+# some variables for testing
+#filename = 'param_1.pickle'
+#train_with_intronlengthinformation = 1
+
+
+
+def plot_param(filename,train_with_intronlengthinformation=1):
+    """Load filename, and plot 3 figures:
+       - match matrix
+       - acceptor and donor scores
+       - intron length scores
+    """
+    param = cPickle.load(open(filename))
+    [h,d,a,mmatrix,qualityPlifs] = set_param_palma(param,train_with_intronlengthinformation)
+    pylab.imshow(numpy.reshape(mmatrix,Configuration.sizeMatchmatrix),\
+                 cmap=pylab.cm.summer,interpolation='nearest')
+
+    pylab.figure()
+    pylab.plot(a.limits,a.penalties,'bd-',label='Acceptor',hold=True)
+    pylab.plot(d.limits,d.penalties,'ro--',label='Donor')
+    pylab.xlabel('SVM output')
+    pylab.ylabel('transition score')
+    pylab.legend()
+
+    pylab.figure()
+    pylab.plot(h.limits,h.penalties,'k+-')
+    pylab.xlabel('intron length')
+    pylab.ylabel('transition score')
+
+    pylab.figure()
+    for plif in qualityPlifs:
+        pylab.plot(plif.limits,plif.penalties,'b^-',hold=True)
+    pylab.xlabel('quality value')
+    pylab.ylabel('transition score')
+    
+
+if __name__ == '__main__':
+    twil = 1
+    if len(sys.argv) < 2:
+        print 'usage: python plot_param.py paramfile.pickle [train_with_intronlengthinformation]'
+        exit()
+    elif len(sys.argv) == 3:
+        twil = sys.argv[2]
+    filename = sys.argv[1]
+
+    plot_param(filename,twil)
+    try:
+        dummy = input('Hit enter when finished.')
+    except:
+        exit()
+
+