ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/osprai_one.html
Revision: 24
Committed: Wed Apr 28 01:00:17 2010 UTC (9 years, 6 months ago) by clausted
File size: 13622 byte(s)
Log Message:
Added copyinterval() to cal_module.  This cuts out a slice of SPR data between two timepoints and puts it in a new ba object.  
Line File contents
1 <HTML>
2 <HEAD>
3 <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
4 <TITLE>The OSPRAI Reference</TITLE>
5 <META NAME="AUTHOR" CONTENT="Christopher Lausted">
6 </HEAD>
7
8 <BODY LANG="en-US" TEXT="#000000" LINK="#0000ff" DIR="LTR">
9 <FONT FACE="Courier New, monospace">osprai_one.py</FONT>
10
11 <H2>Name</H2>
12 OSPRAI - Convert the data exported from SPRit, Plexera ICM and Plexera DAM to Clamp and Biosensor format.
13 Tools are provided for plotting, calibration, and curvefitting,
14
15 <H2>Details</H2>
16 <H3>Requirements</H3>
17 Python 2.4+ and the following modules: sys, time, os, numpy, matplotlib, python-tk, xlrd
18 <H3>Suggested</H3>
19 Ipython, PythonXY (Windows only)
20 <H3>License </H3>
21 GNU General Public License Version 2
22
23
24 <H2>Data class objects</H2>
25
26 <pre>
27 Examples:
28 #ba1 = BiosensorArray(800,1500) ## Allocate object with 800 spots of 1500 time points.
29 #ba1.roi[799].time[1499] = 7502.1 ## Set time in seconds.
30 #ba1.roi[799].value[1499] = 0.50 ## Set SPR reflectance signal.
31 #ba1.roi[799].name = "anti-IgG" ## Set name of microarray feature.
32 </pre>
33
34
35 <H2>OSPRAI functions</H2>
36
37 <H3> File Input/Output </H3>
38
39 <pre>
40 def readsprit(fname):
41
42 Read a SPRit text file into a ba class.
43 It has two tab-delimited columns and two header lines.
44 Here is a very simple example with 2 rois and 3 datapoints:
45
46 Elapsed Time (Seconds) Average Intensity (Pixel Intensity)
47 BEGIN
48 0.000000e+000 2.863145e+003
49 5.013000e+000 2.863367e+003
50 1.002500e+001 2.862950e+003
51 0.000000e+000 2.862875e+003
52 5.013000e+000 2.862510e+003
53
54
55
56 def writesprit(ba0, fname):
57
58 Write a ba class to a SPRit text file.
59
60
61 def readclamp(fname):
62
63 Read a Clamp text file into a ba class.
64 It has two tab-delimited columns per SPR flowcell/roi..
65 It has a varying number of header lines with injection information.
66 Here is a very simple example with 2 rois and 3 datapoints:
67
68 Vers 3.41 Data
69 Conc1 0 0 0 0
70 Start1 301.5 301.5 301.5 301.5
71 Stop1 949.8 949.8 949.8 949.8
72 RInd1 0 0 0 0
73 Conc2 0 0 0 0
74 Start2 986.4 0 0 0
75 Stop2 1626 0 0 0
76 RInd2 0 0 0 0
77 Flow 1 1 1 1
78 Time1 Data1 Time2 Data2
79 0.094 0.062 0.094 0.053
80 1.094 0.026 1.094 0.05
81 2.094 0.119 2.094 0.055
82
83 (This feature is still under construction.)
84
85
86 def writeclamp(ba0, fname):
87
88 Write a ba class to a Clamp text file.
89
90
91
92 def readicmtxt(fname):
93
94 Read a ICM text file into a ba class.
95 Here is a very simple example of the tab-delimited format:
96
97 03/05/2010 13:37:21.312 249.408 0.000 0.000
98 03/05/2010 13:37:22.312 249.306 0.000 0.000
99
100
101 def readbiosensor(fname):
102
103 Read a Biacore-style text file into a ba class.
104 Here is a very simple example of the tab-delimited format:
105
106 Ab1 Fc=4- 1_X Ab1 Fc=4 -1_Y Ab2 Fc=4 -1_X Ab2 Fc=4 -1_Y
107 13.1 23.7644 93.1 0.713912
108 13.6 23.4265 93.6 0.0541172
109 14.1 23.1625 94.1 0.332768
110 14.6 23.5752 94.6 0.849459
111
112
113 def writebiosensor(ba0, fname):
114
115 Write a ba class to a Biosensor text file.
116
117
118
119 def applygal(ba0, fname):
120
121 Read a Gal file and apply its microarray information.
122
123 (This feature is still under construction.)
124
125
126 def applykey(ba0, fname):
127
128 Read a Key file and apply its microarray information.
129 Multiple background ROIs are not yet supported.
130 Here is a very simple example :
131
132 No. Description1 Description2 Background ROI Col Row
133 1 Rat TNF Antibody01 2 1 1
134 2 ratIgG Antibody02 4 2 1
135 3 Hum TNF Antibody03 4 3 1
136 4 humIgG Antibody04 2 4 1
137
138 </pre>
139
140
141 <H3> Data plotting </H3>
142
143 <pre>
144 Example:
145 #import vu_module as vu
146 #io_module as io
147 #ba1 = io.readsprit("spritdata.txt")
148 #vu.dotgraph(ba1, "Title")
149 #vu.linegraph(ba1, "Title")
150 #vu.dualgraph(ba1, ba2, "Title")
151 #vu.scatterplot(ba1, t1, t2, t3, t4, title)
152
153
154 def linegraph(baLine, title=""):
155
156 Graph data of baLine using lines.
157
158
159 def dotgraph(baDot, title=""):
160
161 Graph data of baDot using dots.
162
163
164 def dualgraph(baDot, baLine, title=""):
165
166 Graph data using dots and lines.
167
168
169 def scatterplot(ba0, t1, t2, t3, t4, title):
170
171 Plot binding changes between (t4-t3) versus (t2-t1).
172 Also print the results to the standard output.
173
174 </pre>
175
176
177
178 <H3> Data calibration and adjustment </H3>
179
180 <pre>
181
182 Example:
183 #import cal_module as cal
184 #io_module as io
185 #baC = io.readsprit("calibrationdata.txt")
186 #ba1 = io.readsprit("spritdata.txt")
187 #ba2 = cal.calibrate(ba1, baCal, t1, t2, n1, n2)
188 #cal.bgset(ba2, bgroi)
189 #ba3 = cal.bgsubt(ba2)
190
191
192 def calibrate(ba0, baCal, t1, t2, n1=1335700, n2=1336600):
193
194 Use data in baCal to calibrate ba0.
195 A simple two-point linear calibration using timepoints t1 and t2 and
196 corresponding refractive indices n1 and n2. If n1 and n2 are not given,
197 assume 1x PBS (n1=1335700uRIU) and 2xPBS (n2=1336600uRIU).
198 Average 30 seconds of data (t-15 to 5+15 seconds).
199 The ba object returned will remember the slopes and intercepts used.
200
201
202 def bgsubt(ba0):
203
204 Apply the background subtraction and return a new ba object.
205
206
207 def bgset(ba0, i):
208
209 Set i as the background ROI for all of the ROIs.
210
211
212 def copyinterval(ba0, t1, t2):
213
214 Copy data from the interval between t1 and t2 and return a new ba object.
215
216 </pre>
217
218
219 <H3> Curve fitting by least squares </H3>
220
221 <pre>
222 Example:
223 #import fit_module as fit
224 #import mdl_module as mdl
225 #ba1.roi[0].model = mdl.drift
226 #ba1.roi[0].params = {'rate': {'value':1, 'min':-100.0, 'max':100.0, 'fixed':False} }
227 #success = lma(ba1.roi[0])
228 #for i in ba1.roi: lma(i)
229
230
231 def lma(roi):
232
233 Normal Levenberg-Marquart fitting based on SciPy.
234 This function takes a single ba_class RegionOfInterest object (roi).
235 It modifies roi.params in place. It returns the number of iterations completed.
236
237
238 def clma(roi):
239
240 Constrained Levenberg-Marquart Algorithm fitting based on SciPy.
241 This function takes a single ba_class RegionOfInterest object (roi).
242 It modifies roi.params in place. It returns the number of iterations completed.
243
244 </pre>
245
246
247 <H3> Example models of surface binding </H3>
248
249 <pre>
250 Examples:
251 #import mdl_module as mdl
252 #import numpy as np
253 #times = np.arange(100)
254 #data = np.zeros(100)
255 #
256 #params1 = dict(rate=dict(value=1.0, min=-100.0, max=100.0, fixed=True))
257 #data1 = drift(time, data, param1)
258 #
259 #param2 = {'t1': {'value':30.0, 'min':30.0, 'max':30.0, 'fixed':True} }
260 #param2['rmax'] = {'value': 100.0}
261 #param2['conc'] = {'value': 1e-6}
262 #param2['kon'] = {'value': 2e4}
263 #param2['t2'] = {'value': 150.0}
264 #param2['koff'] = {'value': 1e-3}
265 #param2['t3'] = {'value': 270.0}
266 #data2 = simple1to1(time, data, param2)
267
268
269 def drift(time, data, params):
270
271 This function simply models a constant signal drift in units/second.
272 It requires numpy arrays of times and starting data values,
273 It only requires one parameter in the params list.
274 params['rate']['value']
275
276
277 def simple1to1(time, data, params):
278
279 This function simply models a 1:1 interaction
280 It requires numpy arrays of times and starting data values,
281 params['t1']['value'] is time of injection for binding
282 params['rmax']['value'] is maximum response.
283 params['conc']['value'] is time of concentration of analyte
284 params['kon']['value'] is on-rate of analyte
285 params['t2']['value'] is time of end binding / begin washing
286 params['koff']['value'] is off-rate of analyte
287 params['t3']['value'] is time end of washing / data fitting.
288
289 </pre>
290
291
292
293
294 <H2>File formats</H2>
295
296 <H3>GAL file format</H3>
297 <UL>
298 <LI>There are eight columns for the gal file.
299 <LI>The first three columns identify the position, and (Block, Row, Column) is the unique identity for each ROI.
300 <LI>The fourth column (&ldquo;Name&rdquo;) is the name of the immobilized protein.
301 <LI>The fifth column (&ldquo;ID&rdquo;) is the spot number, which is calculated from the first three column, by the formula (Block-1)*blocksize + (Row-1)*rowsize + Column
302 <LI>The sixth column (&ldquo;Set&rdquo;) indicates the concentration of the immobilized protein.
303 <LI>The seventh column (&ldquo;Family&rdquo;) is not used by Converter.
304 <LI>The eighth column &ldquo;Group&rdquo; is filled with the background id for each ROI, in the form of &ldquo;(Block, Row, Column)&rdquo;.
305 If a ROI has more than one background spots, separate those spots with <B>semicolon plus space</B>, and the average can be taken as the background.
306 </UL>
307 <BR>
308
309 An example is given below.
310 <BR>
311
312 <TABLE WIDTH=591 BORDER=1 BORDERCOLOR="#000000" CELLPADDING=7 CELLSPACING=0>
313 <COL WIDTH=40>
314 <COL WIDTH=33>
315 <COL WIDTH=48>
316 <COL WIDTH=54>
317 <COL WIDTH=56>
318 <COL WIDTH=64>
319 <COL WIDTH=57>
320 <COL WIDTH=124>
321 <TR VALIGN=TOP>
322 <TD WIDTH=40> Block </TD>
323 <TD WIDTH=33> Row </TD>
324 <TD WIDTH=48>Column</TD>
325 <TD WIDTH=54>Name</TD>
326 <TD WIDTH=56>ID</TD>
327 <TD WIDTH=64>Set/Conc</TD>
328 <TD WIDTH=57>Family</TD>
329 <TD WIDTH=124>Group/Backgroud</TD>
330 </TR>
331 <TR VALIGN=TOP>
332 <TD WIDTH=40>1</TD>
333 <TD WIDTH=33>1</TD>
334 <TD WIDTH=48>1</TD>
335 <TD WIDTH=54>TBA3-2</TD>
336 <TD WIDTH=56>Spot1</TD>
337 <TD WIDTH=64>100nM</TD>
338 <TD WIDTH=57>0</TD>
339 <TD WIDTH=124>&quot;1,1,1; 1,1,2&quot;</TD>
340 </TR>
341 <TR VALIGN=TOP>
342 <TD WIDTH=40>1</TD>
343 <TD WIDTH=33>1</TD>
344 <TD WIDTH=48>2</TD>
345 <TD WIDTH=54>Mix2-4</TD>
346 <TD WIDTH=56>Spot2</TD>
347 <TD WIDTH=64>100nM</TD>
348 <TD WIDTH=57>0</TD>
349 <TD WIDTH=124>&quot;1,1,2; 1,1,3&quot;</TD>
350 </TR>
351 </TABLE>
352 <BR>
353
354 <H3>Protocol file format</H3>
355 The protocol file is the same as the analyte table generated by ICM software.
356 An example is given below.
357 <BR>
358
359 <TABLE WIDTH=591 BORDER=1 BORDERCOLOR="#000000" CELLPADDING=7 CELLSPACING=0>
360 <COL WIDTH=43>
361 <COL WIDTH=66>
362 <COL WIDTH=72>
363 <COL WIDTH=44>
364 <COL WIDTH=61>
365 <COL WIDTH=66>
366 <COL WIDTH=39>
367 <COL WIDTH=33>
368 <COL WIDTH=38>
369 <TR VALIGN=TOP>
370 <TD WIDTH=43 HEIGHT=2>Location</TD>
371 <TD WIDTH=66>Name</TD>
372 <TD WIDTH=72>Concentration (mol/L)</TD>
373 <TD WIDTH=44>Flow Rate (ul/sec)</TD>
374 <TD WIDTH=61>Association Duration (sec)</TD>
375 <TD WIDTH=66>Dissociation Duration (sec)
376 </TD>
377 <TD WIDTH=39>Analyte Series</TD>
378 <TD WIDTH=33>Buffer Blank Series</TD>
379 <TD WIDTH=38>Working Volume (uL)</TD>
380 </TR>
381 <TR VALIGN=TOP>
382 <TD WIDTH=43 HEIGHT=3>A1</TD>
383 <TD WIDTH=66>Calibration1</TD>
384 <TD WIDTH=72>1.00E-06</TD>
385 <TD WIDTH=44>5</TD>
386 <TD WIDTH=61>60</TD>
387 <TD WIDTH=66>60</TD>
388 <TD WIDTH=39>1</TD>
389 <TD WIDTH=33>1</TD>
390 <TD WIDTH=38>310</TD>
391 </TR>
392 <TR VALIGN=TOP>
393 <TD WIDTH=43 HEIGHT=3>A2</TD>
394 <TD WIDTH=66>Calibration2</TD>
395 <TD WIDTH=72>2.00E-06</TD>
396 <TD WIDTH=44>5</TD>
397 <TD WIDTH=61>60</TD>
398 <TD WIDTH=66>60</TD>
399 <TD WIDTH=39>1</TD>
400 <TD WIDTH=33>1</TD>
401 <TD WIDTH=38>310</TD>
402 </TR>
403 <TR VALIGN=TOP>
404 <TD WIDTH=43 HEIGHT=3>A3</TD>
405 <TD WIDTH=66>Sample 1</TD>
406 <TD WIDTH=72>5.00E-10</TD>
407 <TD WIDTH=44>5</TD>
408 <TD WIDTH=61>60</TD>
409 <TD WIDTH=66>60</TD>
410 <TD WIDTH=39>1</TD>
411 <TD WIDTH=33>1</TD>
412 <TD WIDTH=38>310</TD>
413 </TR>
414 <TR VALIGN=TOP>
415 <TD WIDTH=43 HEIGHT=2>A4</TD>
416 <TD WIDTH=66>Sample 2</TD>
417 <TD WIDTH=72>2.50E-09</TD>
418 <TD WIDTH=44>5</TD>
419 <TD WIDTH=61>60</TD>
420 <TD WIDTH=66>60</TD>
421 <TD WIDTH=39>1</TD>
422 <TD WIDTH=33>1</TD>
423 <TD WIDTH=38>310</TD>
424 </TR>
425 </TABLE>
426 <BR>
427
428
429 <H3>Key file format</H3>
430 <UL>
431 <LI>Four columns are required in the key file.
432 <LI>The first column (&ldquo;ID&rdquo;) is the unique identity for each ROI.
433 <LI>The second column (&ldquo;Name&rdquo;) is the name of the immobilized protein.
434 <LI>The third column (&ldquo;Concentration&rdquo;) is the concentration of the immobilized protein.
435 <LI>The fourth column (&ldquo;Background&rdquo;) is the background spot idfor each ROI.
436 If a ROI has more than one background spots, separate those spots with <B>semicolon plus space</B>, and the average can be taken as the background.
437 <LI>More columns are optional, but are not read by the converter.
438 </UL>
439 <BR>
440
441 An example is given below.
442 <TABLE WIDTH=507 BORDER=1 BORDERCOLOR="#000000" CELLPADDING=7 CELLSPACING=0>
443 <COL WIDTH=23>
444 <COL WIDTH=75>
445 <COL WIDTH=106>
446 <COL WIDTH=102>
447 <COL WIDTH=46>
448 <COL WIDTH=70>
449 <TR VALIGN=TOP>
450 <TD WIDTH=23>ID</TD>
451 <TD WIDTH=75>Name</TD>
452 <TD WIDTH=106>Concentration</TD>
453 <TD WIDTH=102>Background</TD>
454 <TD WIDTH=46>Col</TD>
455 <TD WIDTH=70>Row</TD>
456 </TR>
457 <TR VALIGN=TOP>
458 <TD WIDTH=23>1</TD>
459 <TD WIDTH=75>TBA2-1</TD>
460 <TD WIDTH=106>1uM</TD>
461 <TD WIDTH=102>10</TD>
462 <TD WIDTH=46>1</TD>
463 <TD WIDTH=70>1</TD>
464 </TR>
465 <TR VALIGN=TOP>
466 <TD WIDTH=23>2</TD>
467 <TD WIDTH=75>TBA3-1</TD>
468 <TD WIDTH=106>1uM</TD>
469 <TD WIDTH=102>10; 11</TD>
470 <TD WIDTH=46>2</TD>
471 <TD WIDTH=70>1</TD>
472 </TR>
473 </TABLE>
474 <BR>
475
476
477 </BODY>
478 </HTML>