ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/sphinx/_build/html/tutorial01.html
Revision: 54
Committed: Wed Feb 16 21:29:02 2011 UTC (8 years, 4 months ago) by clausted
File size: 39306 byte(s)
Log Message:
Added fit_module and mdl_module to sphinx documentation.
Line File contents
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
8 <title>OSPRAI Tutorial 1 &mdash; osprai-doc v0.5-110215 documentation</title>
9 <link rel="stylesheet" href="_static/default.css" type="text/css" />
10 <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
11 <script type="text/javascript">
12 var DOCUMENTATION_OPTIONS = {
13 URL_ROOT: '#',
14 VERSION: '0.5-110215',
15 COLLAPSE_MODINDEX: false,
16 FILE_SUFFIX: '.html',
17 HAS_SOURCE: true
18 };
19 </script>
20 <script type="text/javascript" src="_static/jquery.js"></script>
21 <script type="text/javascript" src="_static/doctools.js"></script>
22 <link rel="top" title="osprai-doc v0.5-110215 documentation" href="index.html" />
23 <link rel="next" title="The Application Program Interface" href="mainapi.html" />
24 <link rel="prev" title="Welcome to the OSPRAI documentation!" href="index.html" />
25 </head>
26 <body>
27 <div class="related">
28 <h3>Navigation</h3>
29 <ul>
30 <li class="right" style="margin-right: 10px">
31 <a href="genindex.html" title="General Index"
32 accesskey="I">index</a></li>
33 <li class="right" >
34 <a href="modindex.html" title="Global Module Index"
35 accesskey="M">modules</a> |</li>
36 <li class="right" >
37 <a href="mainapi.html" title="The Application Program Interface"
38 accesskey="N">next</a> |</li>
39 <li class="right" >
40 <a href="index.html" title="Welcome to the OSPRAI documentation!"
41 accesskey="P">previous</a> |</li>
42 <li><a href="index.html">osprai-doc v0.5-110215 documentation</a> &raquo;</li>
43 </ul>
44 </div>
45
46 <div class="document">
47 <div class="documentwrapper">
48 <div class="bodywrapper">
49 <div class="body">
50
51 <div class="section" id="osprai-tutorial-1">
52 <h1>OSPRAI Tutorial 1<a class="headerlink" href="#osprai-tutorial-1" title="Permalink to this headline">¶</a></h1>
53 <div class="section" id="viewing-data-from-an-spr-file">
54 <h2>Viewing data from an SPR file<a class="headerlink" href="#viewing-data-from-an-spr-file" title="Permalink to this headline">¶</a></h2>
55 <p>Analysis begins with viewing data generated by a biosensor instrument such as a Biacore or Plexera.
56 Launch a python interpreter such as the standard interpreter or IPython and navigate to the directory containing the OSPRAI code and example data files.
57 Enter the following commands to load and view an example data file:</p>
58 <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">osprai_one</span> <span class="kn">import</span> <span class="o">*</span>
59 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba1</span> <span class="o">=</span> <span class="n">readicmtxt</span><span class="p">(</span><span class="s">&quot;example-icm.txt&quot;</span><span class="p">)</span>
60 <span class="go">This ICM files has 6034 datapoints for 25 ROIs.</span>
61 <span class="gp">&gt;&gt;&gt; </span><span class="n">linegraph</span><span class="p">(</span><span class="n">ba1</span><span class="p">)</span>
62 </pre></div>
63 </div>
64 <img alt="_images/figure02.png" src="_images/figure02.png" />
65 <p>The first line imports all of the functions and data classes needed by the user.
66 Function <tt class="docutils literal"><span class="pre">readicmtxt()</span></tt> reads an SPR data file saved by the Plexera Instrument Control Software.
67 Other data formats are supported and described later.
68 A object of the class Biosensor_array (BA) is created named <tt class="docutils literal"><span class="pre">ba1</span></tt> containing the data.</p>
69 <p>Function <tt class="docutils literal"><span class="pre">linegraph()</span></tt> plots the data as a sensorgram&#8211;the SPR signal versus time.
70 This plot appears in a separate window.
71 At the lower left corner of the window are buttons for zooming, copying, and saving (PNG format).
72 These buttons will be familiar to matplotlib users.
73 At the lower right corner are three buttons for changing which ROIs are displayed.
74 While it is possible to display all ROIs in a BA object, a plot with 25 ROIs would be too cluttered.
75 By default, only the first six ROIs in the BA are shown.
76 Clicking the &#8220;Next6&#8221; button will change the plot to display ROIs 6-11 and a subsequent click on the &#8220;Prev6&#8221; button will display ROIs 0-5 again.
77 An arbitrary list of ROIs can be specified by clicking the &#8220;Choose...&#8221; button.
78 The window must be closed in order to continue the execution of Osparai commands</p>
79 </div>
80 <div class="section" id="calibration-and-background-subtraction">
81 <h2>Calibration and background subtraction<a class="headerlink" href="#calibration-and-background-subtraction" title="Permalink to this headline">¶</a></h2>
82 <p>Data produced by a biosensing instrument can be reported as angle shift, reflectance, wavelength shift, resonance units (RU), or other units.
83 This data can come from a single surface or channel, in which case the bulk refractive index changes of the samples and washes can be seen, or it may be the difference between two surfaces or channels.
84 The example file used here is uncalibrated and unreferenced.
85 Enter the following commands for calibration and referencing:</p>
86 <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span> <span class="o">=</span> <span class="n">calibrate</span><span class="p">(</span><span class="n">ba1</span><span class="p">,</span> <span class="n">ba1</span><span class="p">,</span> <span class="mi">2850</span><span class="p">,</span> <span class="mi">3120</span><span class="p">,</span> <span class="mi">1333000</span><span class="p">,</span> <span class="mi">1334000</span><span class="p">)</span>
87 <span class="gp">&gt;&gt;&gt; </span><span class="n">linegraph</span><span class="p">(</span><span class="n">ba2</span><span class="p">,</span> <span class="s">&quot;Calibrated SPR Data&quot;</span><span class="p">)</span>
88 <span class="go">.. image:: ./images/figure03a.png&quot;</span>
89 <span class="gp">&gt;&gt;&gt; </span><span class="n">bgset</span><span class="p">(</span><span class="n">ba2</span><span class="p">,</span> <span class="mi">16</span><span class="p">)</span>
90 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba3</span> <span class="o">=</span> <span class="n">bgsubt</span><span class="p">(</span><span class="n">ba2</span><span class="p">)</span>
91 <span class="gp">&gt;&gt;&gt; </span><span class="n">dotgraph</span><span class="p">(</span><span class="n">ba3</span><span class="p">,</span> <span class="s">&quot;Referenced SPR Data&quot;</span><span class="p">)</span>
92 </pre></div>
93 </div>
94 <img alt="_images/figure03b.png" src="_images/figure03b.png" />
95 <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">dualgraph</span><span class="p">(</span><span class="n">ba2</span><span class="p">,</span> <span class="n">ba3</span><span class="p">,</span> <span class="s">&quot;Unreferenced and Referenced SPR Data&quot;</span><span class="p">)</span>
96 </pre></div>
97 </div>
98 <img alt="_images/figure03c.png" src="_images/figure03c.png" />
99 <p>Function <tt class="docutils literal"><span class="pre">calibrate()</span></tt> uses the data in <tt class="docutils literal"><span class="pre">ba1</span></tt> to calibrate the data in <tt class="docutils literal"><span class="pre">ba1</span></tt> and place it in a new object <tt class="docutils literal"><span class="pre">ba2</span></tt>.
100 The two-point calibration uses the time points (t1,t2) where the refractive indices (n1,n2) are known.
101 In this case, we use t1=2850s with n1=1333000 μRIU, and t2=3120 with n2=1334000.
102 Function <tt class="docutils literal"><span class="pre">bgset()</span></tt> is used to specify one ROI as the reference for all ROIs in the ba object.
103 In this case, ROI number 16 is used.
104 No data is affected by this step.
105 To apply background subtraction, we call the <tt class="docutils literal"><span class="pre">bgsubt()</span></tt> function.
106 This creates a new object <tt class="docutils literal"><span class="pre">ba3</span></tt>.
107 Function <tt class="docutils literal"><span class="pre">dotgraph()</span></tt> provides a slightly different display, with dotted data points instead of continuous lines.
108 Function <tt class="docutils literal"><span class="pre">dualgraph()</span></tt> displays both dotted and continuous sensorgrams.
109 This feature is useful for comparing two related Biosensor_array objects of the same size.</p>
110 </div>
111 <div class="section" id="data-simulation">
112 <h2>Data simulation<a class="headerlink" href="#data-simulation" title="Permalink to this headline">¶</a></h2>
113 <p>Now we will create some simulated sensorgrams using a simple 1:1 interaction model.
114 <em>(the model is a reference to a function)</em>
115 <em>(the parameters are provided as a list of lists)</em></p>
116 <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">reset</span>
117 <span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">osprai_one</span> <span class="kn">import</span> <span class="o">*</span>
118 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span> <span class="o">=</span> <span class="p">{}</span>
119 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span><span class="p">[</span><span class="s">&#39;t1&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">30.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">30.0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">30.0</span><span class="p">,</span> <span class="n">fixed</span><span class="o">=</span><span class="s">&#39;fixed&#39;</span><span class="p">)</span>
120 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span><span class="p">[</span><span class="s">&#39;rmax&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">100.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">1000.0</span><span class="p">,</span> <span class="n">fixed</span><span class="o">=</span><span class="s">&#39;fixed&#39;</span><span class="p">)</span>
121 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span><span class="p">[</span><span class="s">&#39;conc&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">1e-5</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">1e-12</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">1e1</span><span class="p">,</span> <span class="n">fixed</span><span class="o">=</span><span class="s">&#39;fixed&#39;</span><span class="p">)</span>
122 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span><span class="p">[</span><span class="s">&#39;cofa&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">1e-10</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">1e10</span><span class="p">,</span> <span class="n">fixed</span><span class="o">=</span><span class="s">&#39;fixed&#39;</span><span class="p">)</span>
123 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span><span class="p">[</span><span class="s">&#39;kon&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">2e4</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">1e1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">1e10</span><span class="p">,</span> <span class="n">fixed</span><span class="o">=</span><span class="s">&#39;fixed&#39;</span><span class="p">)</span>
124 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span><span class="p">[</span><span class="s">&#39;t2&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">150.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">150.0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">150.0</span><span class="p">,</span> <span class="n">fixed</span><span class="o">=</span><span class="s">&#39;fixed&#39;</span><span class="p">)</span>
125 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span><span class="p">[</span><span class="s">&#39;koff&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">1e-2</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">1e-5</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">1e-1</span><span class="p">,</span> <span class="n">fixed</span><span class="o">=</span><span class="s">&#39;fixed&#39;</span><span class="p">)</span>
126 <span class="gp">&gt;&gt;&gt; </span><span class="n">dpar</span><span class="p">[</span><span class="s">&#39;t3&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">270.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">270.0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">270.0</span><span class="p">,</span> <span class="n">fixed</span><span class="o">=</span><span class="s">&#39;fixed&#39;</span><span class="p">)</span>
127 <span class="gp">&gt;&gt;&gt; </span><span class="k">print</span> <span class="n">dpar</span>
128 <span class="go">{&#39;cofa&#39;: {&#39;fixed&#39;: &#39;fixed&#39;, &#39;max&#39;: 10000000000.0, &#39;min&#39;: 1e-010, &#39;value</span>
129 <span class="go">&#39;conc&#39;: {&#39;fixed&#39;: &#39;fixed&#39;,&#39;max&#39;: 10.0,&#39;min&#39;: 1.0e-012,&#39;value&#39;: 1.0e-005},</span>
130 <span class="go">&#39;koff&#39;: {&#39;fixed&#39;: &#39;fixed&#39;,&#39;max&#39;: 0.1,&#39;min&#39;: 1.0e-005,&#39;value&#39;: 0.01},</span>
131 <span class="go">&#39;kon&#39;: {&#39;fixed&#39;: &#39;fixed&#39;,&#39;max&#39;: 10000000000.0,&#39;min&#39;: 10.0,&#39;value&#39;: 20000.0},</span>
132 <span class="go">&#39;rmax&#39;: {&#39;fixed&#39;: &#39;fixed&#39;, &#39;max&#39;: 1000.0, &#39;min&#39;: 1.0, &#39;value&#39;: 100.0},</span>
133 <span class="go">&#39;t1&#39;: {&#39;fixed&#39;: &#39;fixed&#39;, &#39;max&#39;: 30.0, &#39;min&#39;: 30.0, &#39;value&#39;: 30.0},</span>
134 <span class="go">&#39;t2&#39;: {&#39;fixed&#39;: &#39;fixed&#39;, &#39;max&#39;: 150.0, &#39;min&#39;: 150.0, &#39;value&#39;: 150.0},</span>
135 <span class="go">&#39;t3&#39;: {&#39;fixed&#39;: &#39;fixed&#39;, &#39;max&#39;: 270.0, &#39;min&#39;: 270.0, &#39;value&#39;: 270.0}}</span>
136 <span class="go">&gt;&gt;&gt;</span>
137 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba1</span> <span class="o">=</span> <span class="n">BiosensorArray</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">300</span><span class="p">)</span>
138 <span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">roi</span> <span class="ow">in</span> <span class="n">ba1</span><span class="o">.</span><span class="n">roi</span><span class="p">:</span>
139 <span class="gp">&gt;&gt;&gt; </span> <span class="n">roi</span><span class="o">.</span><span class="n">time</span> <span class="o">=</span> <span class="n">arange</span><span class="p">(</span><span class="mi">300</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span> <span class="c">## Samples every 1 second.</span>
140 <span class="gp">&gt;&gt;&gt; </span> <span class="n">roi</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">zeros</span><span class="p">(</span><span class="mi">300</span><span class="p">,</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span> <span class="o">+</span> <span class="mi">20</span> <span class="c">## Baseline signal is 20 units.</span>
141 <span class="gp">&gt;&gt;&gt; </span> <span class="n">roi</span><span class="o">.</span><span class="n">params</span> <span class="o">=</span> <span class="n">deepcopy</span><span class="p">(</span><span class="n">dpar</span><span class="p">)</span>
142 <span class="gp">&gt;&gt;&gt; </span> <span class="n">roi</span><span class="o">.</span><span class="n">model</span> <span class="o">=</span> <span class="n">simple1to1</span>
143 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba1</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;cofa&#39;</span><span class="p">][</span><span class="s">&#39;value&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="mi">27</span>
144 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba1</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;cofa&#39;</span><span class="p">][</span><span class="s">&#39;value&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="mi">9</span>
145 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba1</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;cofa&#39;</span><span class="p">][</span><span class="s">&#39;value&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="mi">3</span>
146 <span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">roi</span> <span class="ow">in</span> <span class="n">ba1</span><span class="o">.</span><span class="n">roi</span><span class="p">:</span>
147 <span class="gp">&gt;&gt;&gt; </span> <span class="n">roi</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">roi</span><span class="o">.</span><span class="n">model</span><span class="p">(</span><span class="n">roi</span><span class="o">.</span><span class="n">time</span><span class="p">,</span> <span class="n">roi</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">roi</span><span class="o">.</span><span class="n">params</span><span class="p">)</span>
148 <span class="gp">&gt;&gt;&gt; </span><span class="n">dotgraph</span><span class="p">(</span><span class="n">ba1</span><span class="p">,</span> <span class="s">&quot;Simulation&quot;</span><span class="p">)</span>
149 </pre></div>
150 </div>
151 <img alt="_images/figure04.png" src="_images/figure04.png" />
152 </div>
153 <div class="section" id="curve-fitting">
154 <h2>Curve-fitting<a class="headerlink" href="#curve-fitting" title="Permalink to this headline">¶</a></h2>
155 <p>Osprai uses a modified version of the Levenberg-Marquardt least-squares algorithm (LMA) for fitting parameters.
156 The function <tt class="docutils literal"><span class="pre">mcmla()</span></tt> provides LMA fitting on multiple curves with constrained parameters.
157 The use of constraints can improve speed and eliminate nonsense solutions such as negative values for binding kinetic rate parameters.
158 In this example, we constrain the <tt class="docutils literal"><span class="pre">rmax</span></tt> parameter to deliberately produce incorrect <tt class="docutils literal"><span class="pre">kon</span></tt> and <tt class="docutils literal"><span class="pre">koff</span></tt> parameter results:</p>
159 <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span> <span class="o">=</span> <span class="n">deepcopy</span><span class="p">(</span><span class="n">ba1</span><span class="p">)</span>
160 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;rmax&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s">&#39;value&#39;</span><span class="p">:</span><span class="mf">10.0</span><span class="p">,</span> <span class="s">&#39;min&#39;</span><span class="p">:</span><span class="mf">1.0</span><span class="p">,</span> <span class="s">&#39;max&#39;</span><span class="p">:</span><span class="mf">80.0</span><span class="p">,</span> <span class="s">&#39;fixed&#39;</span><span class="p">:</span><span class="s">&#39;float&#39;</span><span class="p">}</span>
161 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;kon&#39;</span><span class="p">][</span><span class="s">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;float&#39;</span>
162 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;koff&#39;</span><span class="p">][</span><span class="s">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;float&#39;</span>
163 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;rmax&#39;</span><span class="p">][</span><span class="s">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
164 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;kon&#39;</span><span class="p">][</span><span class="s">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
165 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;koff&#39;</span><span class="p">][</span><span class="s">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
166 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;rmax&#39;</span><span class="p">][</span><span class="s">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
167 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;kon&#39;</span><span class="p">][</span><span class="s">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
168 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="s">&#39;koff&#39;</span><span class="p">][</span><span class="s">&#39;fixed&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
169 <span class="gp">&gt;&gt;&gt; </span><span class="n">mclma</span><span class="p">(</span><span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">)</span>
170 <span class="gp">... </span><span class="mi">0</span> <span class="n">koff</span> <span class="mf">0.0100</span> <span class="n">kon</span> <span class="mf">20000.0000</span> <span class="n">rmax</span> <span class="mf">10.0000</span> <span class="mi">1</span> <span class="mi">2</span> <span class="n">ssq</span> <span class="mf">1477505.8</span>
171 <span class="go">0 koff 0.0100 kon 20000.0000 rmax 10.0000 1 2 ssq 1477505.8</span>
172 <span class="go">0 koff 0.0100 kon 20000.0000 rmax 10.0000 1 2 ssq 1477505.8</span>
173 <span class="go">0 koff 0.0100 kon 20000.0000 rmax 10.0000 1 2 ssq 1477505.8</span>
174 <span class="go">0 koff 0.0100 kon 20000.0039 rmax 10.0000 1 2 ssq 1477505.8</span>
175 <span class="go">0 koff 0.0100 kon 20000.0000 rmax 10.0000 1 2 ssq 1477505.8</span>
176 <span class="go">0 koff 0.0100 kon 19999.9870 rmax 79.9923 1 2 ssq 73019.8</span>
177 <span class="go">0 koff 0.0100 kon 19999.9870 rmax 79.9923 1 2 ssq 73019.8</span>
178 <span class="go">0 koff 0.0100 kon 19999.9909 rmax 79.9923 1 2 ssq 73019.8</span>
179 <span class="go">0 koff 0.0100 kon 19999.9870 rmax 79.9923 1 2 ssq 73019.8</span>
180 <span class="go">0 koff 0.0081 kon 29949.8389 rmax 80.0000 1 2 ssq 23159.0</span>
181 <span class="go">0 koff 0.0081 kon 29949.8389 rmax 80.0000 1 2 ssq 23159.0</span>
182 <span class="go">0 koff 0.0081 kon 29949.8446 rmax 80.0000 1 2 ssq 23159.0</span>
183 <span class="go">0 koff 0.0081 kon 29949.8389 rmax 80.0000 1 2 ssq 23159.0</span>
184 <span class="go">0 koff 0.0081 kon 28038.4215 rmax 80.0000 1 2 ssq 22549.1</span>
185 <span class="go">0 koff 0.0081 kon 28038.4215 rmax 80.0000 1 2 ssq 22549.1</span>
186 <span class="go">0 koff 0.0081 kon 28038.4268 rmax 80.0000 1 2 ssq 22549.1</span>
187 <span class="go">0 koff 0.0081 kon 28038.4215 rmax 80.0000 1 2 ssq 22549.1</span>
188 <span class="go">0 koff 0.0081 kon 28217.6911 rmax 80.0000 1 2 ssq 22541.4</span>
189 <span class="go">0 koff 0.0081 kon 28217.6911 rmax 80.0000 1 2 ssq 22541.4</span>
190 <span class="go">0 koff 0.0081 kon 28217.6965 rmax 80.0000 1 2 ssq 22541.4</span>
191 <span class="go">0 koff 0.0081 kon 28217.6911 rmax 80.0000 1 2 ssq 22541.4</span>
192 <span class="go">0 koff 0.0081 kon 28196.8328 rmax 80.0000 1 2 ssq 22541.3</span>
193 <span class="go">0 koff 0.0081 kon 28196.8328 rmax 80.0000 1 2 ssq 22541.3</span>
194 <span class="go">0 koff 0.0081 kon 28196.8382 rmax 80.0000 1 2 ssq 22541.3</span>
195 <span class="go">0 koff 0.0081 kon 28196.8328 rmax 80.0000 1 2 ssq 22541.3</span>
196 <span class="go">0 koff 0.0081 kon 28199.1282 rmax 80.0000 1 2 ssq 22541.3</span>
197 <span class="go">0 koff 0.0081 kon 28199.1282 rmax 80.0000 1 2 ssq 22541.3</span>
198 <span class="go">0 koff 0.0081 kon 28199.1335 rmax 80.0000 1 2 ssq 22541.3</span>
199 <span class="go">0 koff 0.0081 kon 28199.1282 rmax 80.0000 1 2 ssq 22541.3</span>
200 <span class="go">0 koff 0.0081 kon 28198.8747 rmax 80.0000 1 2 ssq 22541.3</span>
201
202 <span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">roi</span> <span class="ow">in</span> <span class="n">ba2</span><span class="o">.</span><span class="n">roi</span><span class="p">:</span>
203 <span class="gp">&gt;&gt;&gt; </span> <span class="n">roi</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">roi</span><span class="o">.</span><span class="n">model</span><span class="p">(</span><span class="n">roi</span><span class="o">.</span><span class="n">time</span><span class="p">,</span> <span class="n">roi</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">roi</span><span class="o">.</span><span class="n">params</span><span class="p">)</span>
204 <span class="gp">&gt;&gt;&gt; </span><span class="n">dualgraph</span><span class="p">(</span><span class="n">ba1</span><span class="p">,</span> <span class="n">ba2</span><span class="p">,</span> <span class="s">&quot;Fitted Data with an incorrect rmax constraint&quot;</span><span class="p">)</span>
205 </pre></div>
206 </div>
207 <img alt="_images/figure05a.png" src="_images/figure05a.png" />
208 <p>First, we make a copy of <tt class="docutils literal"><span class="pre">ba1</span></tt> using the <tt class="docutils literal"><span class="pre">deepcopy()</span></tt> function.
209 Next, we specify which parameters we wish to solve for by changing their &#8216;fixed&#8217; key from &#8216;fixed&#8217; to &#8216;float&#8217;.
210 All three ROIs in this BA have the same model and the same parameters, so we only set the parameters in one of the ROIs to &#8216;float&#8217;.
211 Here, we choose the the first ROI, <tt class="docutils literal"><span class="pre">roi[0]</span></tt>, and change &#8216;fixed&#8217; to &#8216;float&#8217; for &#8216;rmax&#8217;, &#8216;kon&#8217;, and &#8216;koff&#8217; parameters.
212 In addition, we specify that &#8216;rmax&#8217; will have a &#8216;max&#8217; value of 80.0.
213 Next, we specify that the &#8216;rmax&#8217;, &#8216;kon&#8217;, and &#8216;koff&#8217; values for <tt class="docutils literal"><span class="pre">roi[1]</span></tt> and <tt class="docutils literal"><span class="pre">roi[2]</span></tt> are the same as for <tt class="docutils literal"><span class="pre">roi[0]</span></tt>.
214 We do this by setting their &#8216;fixed&#8217; key to 0, a reference to <tt class="docutils literal"><span class="pre">roi[0]</span></tt>.</p>
215 <p>We call the curve-fitting function with <tt class="docutils literal"><span class="pre">mclma(ba2.roi)</span></tt>
216 This function will print out the values of the floating parameters and the sum-squared error after each iteration.
217 After 30 iterations, in this case, the algorithm converges upon a solution.
218 Since &#8216;rmax&#8217; was constrained to 80.0, with the real &#8216;rmax&#8217; is 100.0, the resulting best-fit kon is found to be high (28000 vs. 20000).
219 We then use a <tt class="docutils literal"><span class="pre">for</span></tt> loop to simulate the three sensorgrams in <tt class="docutils literal"><span class="pre">ba2</span></tt> using the fitted parameters.
220 Last, we plot both the original sensorgrams of <tt class="docutils literal"><span class="pre">ba1</span></tt> and the fitted sensorgrams of <tt class="docutils literal"><span class="pre">ba2</span></tt> using the <tt class="docutils literal"><span class="pre">dualgraph()</span></tt> function.</p>
221 </div>
222 <div class="section" id="file-format-conversion">
223 <h2>File format conversion<a class="headerlink" href="#file-format-conversion" title="Permalink to this headline">¶</a></h2>
224 <p>Functions are provided to read and write several Biacore and Plexera file formats.
225 Optionally, microarray annotations can be added to the SPR data from GAL or Key files.
226 These annotations are saved when data files are written, if the file format provides support.
227 Examples are given below:</p>
228 <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">ba</span> <span class="o">=</span> <span class="n">readbiosensor</span><span class="p">(</span><span class="s">&quot;example-biosensor.txt&quot;</span><span class="p">)</span>
229 <span class="go">This Biosensor file has 9 datapoints for 2 ROIs.</span>
230 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba</span> <span class="o">=</span> <span class="n">readicmtxt</span><span class="p">(</span><span class="s">&quot;example-icm.txt&quot;</span><span class="p">)</span>
231 <span class="go">This ICM file has 6034 datapoints for 25 ROIs.</span>
232 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba</span> <span class="o">=</span> <span class="n">readsprit</span><span class="p">(</span><span class="s">&quot;example-sprit.txt&quot;</span><span class="p">)</span>
233 <span class="go">This SPRit file has 9 datapoints for 2 ROIs.</span>
234 <span class="gp">&gt;&gt;&gt; </span><span class="n">ba</span> <span class="o">=</span> <span class="n">applykey</span><span class="p">(</span><span class="n">ba1</span><span class="p">,</span> <span class="s">&quot;example-key.tsv&quot;</span><span class="p">)</span>
235 <span class="gp">&gt;&gt;&gt; </span><span class="n">writesprit</span><span class="p">(</span><span class="n">ba</span><span class="p">,</span><span class="s">&quot;testwritesprit.txt&quot;</span><span class="p">)</span>
236 <span class="gp">&gt;&gt;&gt; </span><span class="n">writeclamp</span><span class="p">(</span><span class="n">ba</span><span class="p">,</span><span class="s">&quot;testwriteclamp.txt&quot;</span><span class="p">)</span>
237 <span class="gp">&gt;&gt;&gt; </span><span class="n">writebiosensor</span><span class="p">(</span><span class="n">ba</span><span class="p">,</span> <span class="s">&quot;testwritebiosensor.txt&quot;</span><span class="p">)</span>
238 </pre></div>
239 </div>
240 </div>
241 <div class="section" id="online-help">
242 <h2>Online help<a class="headerlink" href="#online-help" title="Permalink to this headline">¶</a></h2>
243 <p>The Python <tt class="docutils literal"><span class="pre">help()</span></tt> function can be used at any time to display the online documentation for all Osprai functions and classes.</p>
244 <div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">osprai_one</span>
245 <span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">osprai_one</span><span class="p">)</span>
246 <span class="go">Help on module osprai_one:</span>
247
248 <span class="go">NAME</span>
249 <span class="go"> osprai_one</span>
250
251 <span class="go">FILE</span>
252 <span class="go"> ( ...many pages of documentation follow... )</span>
253
254 <span class="gp">&gt;&gt;&gt; </span><span class="n">help</span><span class="p">(</span><span class="n">linegraph</span><span class="p">)</span>
255 <span class="go">Help on function linegraph in module vu_module:</span>
256
257 <span class="go">linegraph(baLine, title=&#39;&#39;)</span>
258 <span class="go"> Display signal vs time using continuous lines.</span>
259
260 <span class="go"> :param baLine: Object containing the data.</span>
261 <span class="go"> :type baLine: ba_class</span>
262 <span class="go"> :param title: Title to place above the graph.</span>
263 <span class="go"> :type title: str</span>
264 <span class="go"> :returns: nothing</span>
265 </pre></div>
266 </div>
267 </div>
268 </div>
269
270
271 </div>
272 </div>
273 </div>
274 <div class="sphinxsidebar">
275 <div class="sphinxsidebarwrapper">
276 <h3><a href="index.html">Table Of Contents</a></h3>
277 <ul>
278 <li><a class="reference external" href="#">OSPRAI Tutorial 1</a><ul>
279 <li><a class="reference external" href="#viewing-data-from-an-spr-file">Viewing data from an SPR file</a></li>
280 <li><a class="reference external" href="#calibration-and-background-subtraction">Calibration and background subtraction</a></li>
281 <li><a class="reference external" href="#data-simulation">Data simulation</a></li>
282 <li><a class="reference external" href="#curve-fitting">Curve-fitting</a></li>
283 <li><a class="reference external" href="#file-format-conversion">File format conversion</a></li>
284 <li><a class="reference external" href="#online-help">Online help</a></li>
285 </ul>
286 </li>
287 </ul>
288
289 <h4>Previous topic</h4>
290 <p class="topless"><a href="index.html"
291 title="previous chapter">Welcome to the OSPRAI documentation!</a></p>
292 <h4>Next topic</h4>
293 <p class="topless"><a href="mainapi.html"
294 title="next chapter">The Application Program Interface</a></p>
295 <h3>This Page</h3>
296 <ul class="this-page-menu">
297 <li><a href="_sources/tutorial01.txt"
298 rel="nofollow">Show Source</a></li>
299 </ul>
300 <div id="searchbox" style="display: none">
301 <h3>Quick search</h3>
302 <form class="search" action="search.html" method="get">
303 <input type="text" name="q" size="18" />
304 <input type="submit" value="Go" />
305 <input type="hidden" name="check_keywords" value="yes" />
306 <input type="hidden" name="area" value="default" />
307 </form>
308 <p class="searchtip" style="font-size: 90%">
309 Enter search terms or a module, class or function name.
310 </p>
311 </div>
312 <script type="text/javascript">$('#searchbox').show(0);</script>
313 </div>
314 </div>
315 <div class="clearer"></div>
316 </div>
317 <div class="related">
318 <h3>Navigation</h3>
319 <ul>
320 <li class="right" style="margin-right: 10px">
321 <a href="genindex.html" title="General Index"
322 >index</a></li>
323 <li class="right" >
324 <a href="modindex.html" title="Global Module Index"
325 >modules</a> |</li>
326 <li class="right" >
327 <a href="mainapi.html" title="The Application Program Interface"
328 >next</a> |</li>
329 <li class="right" >
330 <a href="index.html" title="Welcome to the OSPRAI documentation!"
331 >previous</a> |</li>
332 <li><a href="index.html">osprai-doc v0.5-110215 documentation</a> &raquo;</li>
333 </ul>
334 </div>
335 <div class="footer">
336 &copy; Copyright 2011, Christopher Lausted.
337 Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
338 </div>
339 </body>
340 </html>