File size: 37,610 Bytes
3c1a832
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8aa909
3c1a832
 
1e69bd6
3c1a832
 
0f61c92
3c1a832
 
e8aa909
3c1a832
 
 
e8aa909
3c1a832
 
e8aa909
3c1a832
 
e8aa909
3c1a832
e8aa909
3c1a832
 
e8aa909
3c1a832
e8aa909
3c1a832
 
 
e8aa909
3c1a832
 
e8aa909
3c1a832
 
e8aa909
3c1a832
e8aa909
3c1a832
 
 
 
 
e8aa909
3c1a832
 
 
 
 
 
 
 
 
 
 
e8aa909
3c1a832
 
 
 
 
e8aa909
3c1a832
 
 
 
 
 
 
 
 
 
 
e8aa909
3c1a832
e8aa909
 
 
 
 
 
 
 
 
 
 
 
 
 
3c1a832
 
 
e8aa909
 
3c1a832
 
e8aa909
3c1a832
 
 
 
 
 
 
 
 
 
 
 
 
 
e8aa909
3c1a832
e8aa909
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c1a832
e8aa909
3c1a832
 
 
 
 
 
e8aa909
3c1a832
 
 
 
 
 
e8aa909
3c1a832
 
 
 
 
 
e8aa909
3c1a832
 
 
e8aa909
 
3c1a832
 
 
 
 
 
 
 
e8aa909
3c1a832
 
 
 
e8aa909
3c1a832
e8aa909
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c1a832
 
 
 
 
e8aa909
3c1a832
 
e8aa909
3c1a832
e8aa909
3c1a832
 
 
 
 
 
 
 
 
 
 
 
e8aa909
3c1a832
0f61c92
3c1a832
 
 
 
 
 
 
 
 
 
 
e8aa909
3c1a832
e8aa909
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c1a832
 
 
 
 
 
e8aa909
3c1a832
e8aa909
 
 
3c1a832
e8aa909
 
3c1a832
 
 
 
 
 
 
 
 
 
 
 
 
e8aa909
3c1a832
e8aa909
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c1a832
 
 
e8aa909
3c1a832
 
 
e8aa909
3c1a832
 
 
e8aa909
3c1a832
 
 
 
 
 
 
 
 
 
 
 
 
e8aa909
3c1a832
e8aa909
3c1a832
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f61c92
3c1a832
e8aa909
3c1a832
e8aa909
 
 
 
 
3c1a832
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Protein binding kinetics\n",
    "\n",
    "The aim of these posts is to explore protein and ligand binding kinetics and how they can be calculated. \n",
    "\n",
    "We will use python to derive and visualization of steady-state concentration laws. \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Monomer - Dimer kinetics\n",
    "\n",
    "Lets start with the simple example of dimer formation from two identical protomers:\n",
    "\n",
    "$$\n",
    "\\ce{P1 + P1 <=>[k_{on}][k_{off}] P2}\n",
    "$$\n",
    "\n",
    "From the kinetic scheme above, we can write down the differential equations describing this system. These differential equations tell us how the concentrations of the reaction (in this case dimerization) change in time. \n",
    "\n",
    "$$\n",
    "\\frac{\\partial [P_1]}{\\partial t} = - 2 k_{on} [P_1][P_1] + 2 k_{off} [P_2]\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\frac{\\partial [P_2]}{\\partial t} =  k_{on} [P_1][P_1] - k_{off} [P_2]\n",
    "$$\n",
    "\n",
    "Where square brackets are used to indicate the concentration of the species, ie $[P_1]$ is the concentration of the monomer at a given time point $t$.\n",
    "\n",
    "To sanity check our results, we can multiply the second equation with -2, such that both right-hand sides become equal. We then find that:\n",
    "\n",
    "$$\n",
    "\\frac{\\partial [P_1]}{\\partial t} = - 2 \\frac{\\partial [P_2]}{\\partial t}\n",
    "$$\n",
    "\n",
    "When reading the equation above, for the equality to hold true, we find that the dimer $P_2$ must appear at _half_ the rate at which the monomer $P_1$ disappears. Cross-checking this with our chemical intuition this makes sense, since two monomers are required to make one dimer. \n",
    "\n",
    "In order to now find which concentrations of monomer and dimer are formed given how much protomer is in the tube, we need three more pieces of information. \n",
    "\n",
    "First, we are looking for the concentration of the monomer and dimer at _steady-state_: the system has reached equillibrium and no more changes in the concentration of either the monomer or the dimer occur. This means we can set both differential equations to zero. \n",
    "\n",
    "Second, we realize that the total amount of protomer in the tube never goes up or down; its either monomer or as one of the protomers in a dimer. The total amount of protomer is thus:\n",
    "\n",
    "$$\n",
    "[P_T] = [P_1] + 2[P_2]\n",
    "$$\n",
    "\n",
    "Since extinction coefficients are additive ($\\epsilon_{P_2} = 2\\epsilon_{P_1}$) the total protomer concentration can be measured directly by UV-VIS spectroscopy. \n",
    "\n",
    "Third, we need to have some value for the forward $k_{on}$ and backward rates $k_{off}$. These rates describe how fast the reaction takes place, but at the moment we are only interested in the steady-state concentrations. We can define a single new quantity which depends on the ratio of the forward and backward rates:\n",
    "\n",
    "$$\n",
    "K_d = \\frac{k_{off}}{k_{on}}\n",
    "$$\n",
    "\n",
    "If we look at our differential equations, the left-hand side describes the change of concentration of the monomer over time. The units are therefore molar per second ($M s^{-1}$). To make the units match on the left and right-hand side, we can deduce that the units of $k_{on}$ must be $M^{-1} s^{-1}$. Similarly, the units of $k_{off}$ are $s^{-1}$. From this unit analysis, we can see that the lifetime or off rate from a complex is independent of concentratation and we can recognize $K_d$ as the dissociation constant with units $M$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can now use [sympy](https://www.sympy.org/en/index.html) to do some mathematics and figure out what the steady-state concentrations are."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sympy as sp\n",
    "\n",
    "P1, P2, PT, k_on, k_off, kD = sp.symbols(\"P_1 P_2 P_T k_on k_off k_D\", positive=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now, we can solve the system of equations as we defined them above. Because of steady-state conditions, the differential equations are zero. We only use one here because the first is just the second multiplied by a constant factor, and thus does now have any additional information. To input equations into `sympy`, we must set the right hand side to zero and input the resulting left hand side:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{P_1: sqrt(k_D)*sqrt(8*P_T + k_D)/4 - k_D/4,\n",
       "  P_2: P_T/2 - sqrt(k_D)*sqrt(8*P_T + k_D)/8 + k_D/8,\n",
       "  k_off: k_D*k_on}]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sol = sp.solve(\n",
    "    [\n",
    "        -2 * k_on * P1 * P1 + 2 * k_off * P2,\n",
    "        P1 + 2 * P2 - PT,\n",
    "        (k_off / k_on) - kD,\n",
    "    ],\n",
    "    [P1, P2, k_on, k_off],\n",
    "    dict=True,\n",
    ")\n",
    "sol"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This returns a single solution, because we have told `sympy` that all input symbols are positive. We can have a look at the solution for the concentration of the dimer:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\frac{P_{T}}{2} - \\frac{\\sqrt{k_{D}} \\sqrt{8 P_{T} + k_{D}}}{8} + \\frac{k_{D}}{8}$"
      ],
      "text/plain": [
       "P_T/2 - sqrt(k_D)*sqrt(8*P_T + k_D)/8 + k_D/8"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sol[0][P2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can see that indeed the solution only depends on the dissociation constant $K_D$, and not the individual rates and indeed the 'mass balance' equation still holds ($P_1 + 2P_2 = P_T$), excercise for the reader."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, lets use [solara](https://solara.dev/) to quickly make an interactive component so that we can easily calculate the monomer and dimer concentrations, given a total protomer concentration $P_T$ and the dissociation constant. \n",
    "\n",
    "First, we take the symbolic solutions from `sympy` and lambdify them so that we can input numbers and calculate the output:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "solve_for = [P1, P2]\n",
    "inputs = [PT, kD]\n",
    "\n",
    "lambdas = {s: sp.lambdify(inputs, sol[0][s]) for s in solve_for}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Next, we make a `solara` component, where a user can input the values for $P_T$ and $K_{D}$ and directly obtain $P_1$ and $P_2$ at steady-state:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7b7432b1958f4bdb91256f7c93718220",
       "version_major": 2,
       "version_minor": 0
      },
      "text/html": [
       "Cannot show widget. You probably want to rerun the code cell above (<i>Click in the code cell, and press Shift+Enter <kbd>⇧</kbd>+<kbd>↩</kbd></i>)."
      ],
      "text/plain": [
       "Cannot show ipywidgets in text"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import solara\n",
    "\n",
    "@solara.component\n",
    "def Page():\n",
    "    PT = solara.use_reactive(10.)\n",
    "    kD = solara.use_reactive(1.)\n",
    "\n",
    "    ans = {k: ld(PT.value, kD.value) for k, ld in lambdas.items()}\n",
    "\n",
    "    solara.InputFloat('PT', value=PT)\n",
    "    solara.InputFloat('kD', value=kD)\n",
    "\n",
    "    for k, v in ans.items():\n",
    "        solara.Text(f'{k.name}: {v}')\n",
    "\n",
    "Page()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that the values are all unitless, so if we enter a dissociation constant of 1 $\\mu M$, the concentration $P_T$ should also be given in $\\mu M$, and the outputs are then $\\mu M$ as well. \n",
    "\n",
    "This little widget now tells us that if the monomer concentration if 10 times over the value of $k_D$, in the steady-state equillibrium one out of three species is still a monomer!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lets try if we can visualize the ratio of dimer to monomer over a larger range of concentrations. To do so we evalulate the monomer/dimer concentrations over a range spanning from 0.1 $k_D$ to 1000 $k_D$. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PT</th>\n",
       "      <th>P_1</th>\n",
       "      <th>P_2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.921311</td>\n",
       "      <td>0.078689</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.109750</td>\n",
       "      <td>0.915248</td>\n",
       "      <td>0.084752</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.120450</td>\n",
       "      <td>0.908825</td>\n",
       "      <td>0.091175</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.132194</td>\n",
       "      <td>0.902035</td>\n",
       "      <td>0.097965</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.145083</td>\n",
       "      <td>0.894871</td>\n",
       "      <td>0.105129</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         PT       P_1       P_2\n",
       "0  0.100000  0.921311  0.078689\n",
       "1  0.109750  0.915248  0.084752\n",
       "2  0.120450  0.908825  0.091175\n",
       "3  0.132194  0.902035  0.097965\n",
       "4  0.145083  0.894871  0.105129"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "\n",
    "# create a new function which calculates total molarity (monomer + dimer)\n",
    "ld_total = sp.lambdify(inputs, sol[0][P1] + sol[0][P2])\n",
    "\n",
    "# create a vector of PT values ranging from 0.1 times kD to 1000 times kD\n",
    "PT_values = np.logspace(-1, 3, endpoint=True, num=100)\n",
    "ans = {k: ld(PT_values, 1) / ld_total(PT_values, 1) for k, ld in lambdas.items()}\n",
    "\n",
    "# put the results in a dataframe, together with input PT values\n",
    "df = pd.DataFrame(dict(PT=PT_values) | {k.name: v for k, v in ans.items()})\n",
    "\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The resulting values are _fractions_ of monomer and dimer respectively, rather than their concentrations. We can plot the results with `altair`, adapting the [gallery example](https://altair-viz.github.io/gallery/multiline_tooltip_standard.html#gallery-multiline-tooltip-standard) for a multi-line tooltip graph. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<style>\n",
       "  #altair-viz-3a30d2050bb04b3bbbb1e571718d97a1.vega-embed {\n",
       "    width: 100%;\n",
       "    display: flex;\n",
       "  }\n",
       "\n",
       "  #altair-viz-3a30d2050bb04b3bbbb1e571718d97a1.vega-embed details,\n",
       "  #altair-viz-3a30d2050bb04b3bbbb1e571718d97a1.vega-embed details summary {\n",
       "    position: relative;\n",
       "  }\n",
       "</style>\n",
       "<div id=\"altair-viz-3a30d2050bb04b3bbbb1e571718d97a1\"></div>\n",
       "<script type=\"text/javascript\">\n",
       "  var VEGA_DEBUG = (typeof VEGA_DEBUG == \"undefined\") ? {} : VEGA_DEBUG;\n",
       "  (function(spec, embedOpt){\n",
       "    let outputDiv = document.currentScript.previousElementSibling;\n",
       "    if (outputDiv.id !== \"altair-viz-3a30d2050bb04b3bbbb1e571718d97a1\") {\n",
       "      outputDiv = document.getElementById(\"altair-viz-3a30d2050bb04b3bbbb1e571718d97a1\");\n",
       "    }\n",
       "    const paths = {\n",
       "      \"vega\": \"https://cdn.jsdelivr.net/npm/vega@5?noext\",\n",
       "      \"vega-lib\": \"https://cdn.jsdelivr.net/npm/vega-lib?noext\",\n",
       "      \"vega-lite\": \"https://cdn.jsdelivr.net/npm/[email protected]?noext\",\n",
       "      \"vega-embed\": \"https://cdn.jsdelivr.net/npm/vega-embed@6?noext\",\n",
       "    };\n",
       "\n",
       "    function maybeLoadScript(lib, version) {\n",
       "      var key = `${lib.replace(\"-\", \"\")}_version`;\n",
       "      return (VEGA_DEBUG[key] == version) ?\n",
       "        Promise.resolve(paths[lib]) :\n",
       "        new Promise(function(resolve, reject) {\n",
       "          var s = document.createElement('script');\n",
       "          document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "          s.async = true;\n",
       "          s.onload = () => {\n",
       "            VEGA_DEBUG[key] = version;\n",
       "            return resolve(paths[lib]);\n",
       "          };\n",
       "          s.onerror = () => reject(`Error loading script: ${paths[lib]}`);\n",
       "          s.src = paths[lib];\n",
       "        });\n",
       "    }\n",
       "\n",
       "    function showError(err) {\n",
       "      outputDiv.innerHTML = `<div class=\"error\" style=\"color:red;\">${err}</div>`;\n",
       "      throw err;\n",
       "    }\n",
       "\n",
       "    function displayChart(vegaEmbed) {\n",
       "      vegaEmbed(outputDiv, spec, embedOpt)\n",
       "        .catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));\n",
       "    }\n",
       "\n",
       "    if(typeof define === \"function\" && define.amd) {\n",
       "      requirejs.config({paths});\n",
       "      require([\"vega-embed\"], displayChart, err => showError(`Error loading script: ${err.message}`));\n",
       "    } else {\n",
       "      maybeLoadScript(\"vega\", \"5\")\n",
       "        .then(() => maybeLoadScript(\"vega-lite\", \"5.17.0\"))\n",
       "        .then(() => maybeLoadScript(\"vega-embed\", \"6\"))\n",
       "        .catch(showError)\n",
       "        .then(() => displayChart(vegaEmbed));\n",
       "    }\n",
       "  })({\"config\": {\"view\": {\"continuousWidth\": 300, \"continuousHeight\": 300}}, \"layer\": [{\"mark\": {\"type\": \"line\", \"interpolate\": \"basis\"}, \"encoding\": {\"color\": {\"field\": \"species\", \"type\": \"nominal\"}, \"x\": {\"field\": \"PT\", \"scale\": {\"type\": \"log\"}, \"title\": \"Ratio PT/kD\", \"type\": \"quantitative\"}, \"y\": {\"field\": \"y\", \"title\": \"Fraction of total\", \"type\": \"quantitative\"}}}, {\"mark\": {\"type\": \"point\"}, \"encoding\": {\"color\": {\"field\": \"species\", \"type\": \"nominal\"}, \"opacity\": {\"condition\": {\"param\": \"param_2\", \"value\": 1, \"empty\": false}, \"value\": 0}, \"x\": {\"field\": \"PT\", \"scale\": {\"type\": \"log\"}, \"title\": \"Ratio PT/kD\", \"type\": \"quantitative\"}, \"y\": {\"field\": \"y\", \"title\": \"Fraction of total\", \"type\": \"quantitative\"}}}, {\"mark\": {\"type\": \"rule\", \"color\": \"black\"}, \"encoding\": {\"opacity\": {\"condition\": {\"param\": \"param_2\", \"value\": 0.3, \"empty\": false}, \"value\": 0}, \"tooltip\": [{\"field\": \"PT\", \"format\": \".2f\", \"type\": \"quantitative\"}, {\"field\": \"P_1\", \"format\": \".2f\", \"type\": \"quantitative\"}, {\"field\": \"P_2\", \"format\": \".2f\", \"type\": \"quantitative\"}], \"x\": {\"field\": \"PT\", \"type\": \"quantitative\"}}, \"name\": \"view_2\", \"transform\": [{\"pivot\": \"species\", \"value\": \"y\", \"groupby\": [\"PT\"]}]}], \"data\": {\"name\": \"data-446f9e2ed8437d0111f079d2121109d1\"}, \"height\": 300, \"params\": [{\"name\": \"param_2\", \"select\": {\"type\": \"point\", \"fields\": [\"PT\"], \"nearest\": true, \"on\": \"pointerover\"}, \"views\": [\"view_2\"]}], \"width\": 600, \"$schema\": \"https://vega.github.io/schema/vega-lite/v5.17.0.json\", \"datasets\": {\"data-446f9e2ed8437d0111f079d2121109d1\": [{\"PT\": 0.1, \"species\": \"P_1\", \"y\": 0.9213106741667366}, {\"PT\": 0.10974987654930562, \"species\": \"P_1\", \"y\": 0.9152478142703887}, {\"PT\": 0.12045035402587821, \"species\": \"P_1\", \"y\": 0.9088252563655043}, {\"PT\": 0.1321941148466029, \"species\": \"P_1\", \"y\": 0.9020350932162419}, {\"PT\": 0.14508287784959398, \"species\": \"P_1\", \"y\": 0.8948707231715299}, {\"PT\": 0.1592282793341092, \"species\": \"P_1\", \"y\": 0.887326964051884}, {\"PT\": 0.17475284000076838, \"species\": \"P_1\", \"y\": 0.8794001529111963}, {\"PT\": 0.19179102616724888, \"species\": \"P_1\", \"y\": 0.8710882296412226}, {\"PT\": 0.2104904144512021, \"species\": \"P_1\", \"y\": 0.8623908028192255}, {\"PT\": 0.23101297000831597, \"species\": \"P_1\", \"y\": 0.8533091966764864}, {\"PT\": 0.2535364493970112, \"species\": \"P_1\", \"y\": 0.8438464785616561}, {\"PT\": 0.2782559402207124, \"species\": \"P_1\", \"y\": 0.8340074667631514}, {\"PT\": 0.30538555088334157, \"species\": \"P_1\", \"y\": 0.8237987190163906}, {\"PT\": 0.33516026509388425, \"species\": \"P_1\", \"y\": 0.813228502436007}, {\"PT\": 0.36783797718286343, \"species\": \"P_1\", \"y\": 0.8023067459666666}, {\"PT\": 0.40370172585965547, \"species\": \"P_1\", \"y\": 0.791044976730576}, {\"PT\": 0.4430621457583881, \"species\": \"P_1\", \"y\": 0.7794562418623244}, {\"PT\": 0.4862601580065355, \"species\": \"P_1\", \"y\": 0.7675550175641289}, {\"PT\": 0.533669923120631, \"species\": \"P_1\", \"y\": 0.7553571071923714}, {\"PT\": 0.5857020818056667, \"species\": \"P_1\", \"y\": 0.742879530207701}, {\"PT\": 0.6428073117284322, \"species\": \"P_1\", \"y\": 0.7301404037955845}, {\"PT\": 0.7054802310718644, \"species\": \"P_1\", \"y\": 0.7171588189022171}, {\"PT\": 0.7742636826811272, \"species\": \"P_1\", \"y\": 0.7039547123419793}, {\"PT\": 0.8497534359086445, \"species\": \"P_1\", \"y\": 0.6905487365260083}, {\"PT\": 0.9326033468832199, \"species\": \"P_1\", \"y\": 0.6769621282444622}, {\"PT\": 1.0235310218990263, \"species\": \"P_1\", \"y\": 0.6632165778136448}, {\"PT\": 1.1233240329780276, \"species\": \"P_1\", \"y\": 0.6493340997777712}, {\"PT\": 1.2328467394420666, \"species\": \"P_1\", \"y\": 0.6353369062367451}, {\"PT\": 1.3530477745798075, \"species\": \"P_1\", \"y\": 0.6212472837576913}, {\"PT\": 1.484968262254465, \"species\": \"P_1\", \"y\": 0.6070874747199139}, {\"PT\": 1.6297508346206444, \"species\": \"P_1\", \"y\": 0.5928795638405217}, {\"PT\": 1.7886495290574351, \"species\": \"P_1\", \"y\": 0.5786453705308084}, {\"PT\": 1.9630406500402715, \"species\": \"P_1\", \"y\": 0.5644063476409491}, {\"PT\": 2.1544346900318843, \"species\": \"P_1\", \"y\": 0.5501834870619822}, {\"PT\": 2.3644894126454084, \"species\": \"P_1\", \"y\": 0.5359972325687437}, {\"PT\": 2.5950242113997373, \"species\": \"P_1\", \"y\": 0.5218674002048792}, {\"PT\": 2.848035868435802, \"species\": \"P_1\", \"y\": 0.5078131064309908}, {\"PT\": 3.1257158496882367, \"species\": \"P_1\", \"y\": 0.493852704179271}, {\"PT\": 3.4304692863149193, \"species\": \"P_1\", \"y\": 0.48000372688273857}, {\"PT\": 3.764935806792469, \"species\": \"P_1\", \"y\": 0.4662828404747031}, {\"PT\": 4.132012400115339, \"species\": \"P_1\", \"y\": 0.45270580328479026}, {\"PT\": 4.5348785081285845, \"species\": \"P_1\", \"y\": 0.43928743369225387}, {\"PT\": 4.977023564332112, \"species\": \"P_1\", \"y\": 0.42604158533598346}, {\"PT\": 5.462277217684343, \"species\": \"P_1\", \"y\": 0.41298112962415334}, {\"PT\": 5.994842503189412, \"species\": \"P_1\", \"y\": 0.4001179452353983}, {\"PT\": 6.5793322465756825, \"species\": \"P_1\", \"y\": 0.3874629142582253}, {\"PT\": 7.220809018385467, \"species\": \"P_1\", \"y\": 0.3750259245764573}, {\"PT\": 7.924828983539178, \"species\": \"P_1\", \"y\": 0.3628158780761266}, {\"PT\": 8.697490026177835, \"species\": \"P_1\", \"y\": 0.3508407042235381}, {\"PT\": 9.545484566618342, \"species\": \"P_1\", \"y\": 0.33910737854522055}, {\"PT\": 10.476157527896651, \"species\": \"P_1\", \"y\": 0.32762194552806667}, {\"PT\": 11.497569953977369, \"species\": \"P_1\", \"y\": 0.3163895454519114}, {\"PT\": 12.61856883066021, \"species\": \"P_1\", \"y\": 0.30541444466676376}, {\"PT\": 13.848863713938732, \"species\": \"P_1\", \"y\": 0.2947000688324766}, {\"PT\": 15.199110829529348, \"species\": \"P_1\", \"y\": 0.28424903864930695}, {\"PT\": 16.68100537200059, \"species\": \"P_1\", \"y\": 0.27406320762302827}, {\"PT\": 18.307382802953697, \"species\": \"P_1\", \"y\": 0.2641437014274086}, {\"PT\": 20.09233002565048, \"species\": \"P_1\", \"y\": 0.2544909584493632}, {\"PT\": 22.051307399030456, \"species\": \"P_1\", \"y\": 0.24510477112727974}, {\"PT\": 24.201282647943835, \"species\": \"P_1\", \"y\": 0.2359843277203209}, {\"PT\": 26.560877829466868, \"species\": \"P_1\", \"y\": 0.2271282541753208}, {\"PT\": 29.150530628251786, \"species\": \"P_1\", \"y\": 0.21853465578766545}, {\"PT\": 31.992671377973846, \"species\": \"P_1\", \"y\": 0.2102011583827801}, {\"PT\": 35.111917342151344, \"species\": \"P_1\", \"y\": 0.20212494877505027}, {\"PT\": 38.535285937105314, \"species\": \"P_1\", \"y\": 0.1943028142908023}, {\"PT\": 42.29242874389499, \"species\": \"P_1\", \"y\": 0.1867311811709695}, {\"PT\": 46.41588833612782, \"species\": \"P_1\", \"y\": 0.17940615169700316}, {\"PT\": 50.9413801481638, \"species\": \"P_1\", \"y\": 0.17232353991018073}, {\"PT\": 55.90810182512229, \"species\": \"P_1\", \"y\": 0.16547890581953636}, {\"PT\": 61.35907273413176, \"species\": \"P_1\", \"y\": 0.15886758801703976}, {\"PT\": 67.34150657750828, \"species\": \"P_1\", \"y\": 0.1524847346402729}, {\"PT\": 73.90722033525783, \"species\": \"P_1\", \"y\": 0.14632533264264772}, {\"PT\": 81.11308307896873, \"species\": \"P_1\", \"y\": 0.14038423534913913}, {\"PT\": 89.02150854450393, \"species\": \"P_1\", \"y\": 0.1346561882915889}, {\"PT\": 97.70099572992257, \"species\": \"P_1\", \"y\": 0.12913585333189967}, {\"PT\": 107.22672220103243, \"species\": \"P_1\", \"y\": 0.12381783109393958}, {\"PT\": 117.68119524349991, \"species\": \"P_1\", \"y\": 0.11869668173579613}, {\"PT\": 129.1549665014884, \"species\": \"P_1\", \"y\": 0.11376694410323461}, {\"PT\": 141.7474162926806, \"species\": \"P_1\", \"y\": 0.10902315331294034}, {\"PT\": 155.56761439304722, \"species\": \"P_1\", \"y\": 0.10445985682045184}, {\"PT\": 170.7352647470692, \"species\": \"P_1\", \"y\": 0.10007162903274308}, {\"PT\": 187.3817422860385, \"species\": \"P_1\", \"y\": 0.09585308452929588}, {\"PT\": 205.65123083486534, \"species\": \"P_1\", \"y\": 0.0917988899583294}, {\"PT\": 225.70197196339214, \"species\": \"P_1\", \"y\": 0.08790377467673861}, {\"PT\": 247.70763559917114, \"species\": \"P_1\", \"y\": 0.08416254020333655}, {\"PT\": 271.85882427329426, \"species\": \"P_1\", \"y\": 0.0805700685553064}, {\"PT\": 298.364724028334, \"species\": \"P_1\", \"y\": 0.07712132953743882}, {\"PT\": 327.4549162877732, \"species\": \"P_1\", \"y\": 0.07381138705285176}, {\"PT\": 359.3813663804629, \"species\": \"P_1\", \"y\": 0.07063540450254992}, {\"PT\": 394.420605943766, \"species\": \"P_1\", \"y\": 0.06758864933944884}, {\"PT\": 432.87612810830615, \"species\": \"P_1\", \"y\": 0.06466649684044665}, {\"PT\": 475.0810162102798, \"species\": \"P_1\", \"y\": 0.061864433157825666}, {\"PT\": 521.400828799969, \"species\": \"P_1\", \"y\": 0.05917805770877593}, {\"PT\": 572.236765935022, \"species\": \"P_1\", \"y\": 0.0566030849591937}, {\"PT\": 628.029144183426, \"species\": \"P_1\", \"y\": 0.05413534565517292}, {\"PT\": 689.2612104349702, \"species\": \"P_1\", \"y\": 0.05177078755281282}, {\"PT\": 756.463327554629, \"species\": \"P_1\", \"y\": 0.04950547569414219}, {\"PT\": 830.2175681319752, \"species\": \"P_1\", \"y\": 0.04733559227414581}, {\"PT\": 911.1627561154896, \"species\": \"P_1\", \"y\": 0.045257436141088785}, {\"PT\": 1000.0, \"species\": \"P_1\", \"y\": 0.04326742196959632}, {\"PT\": 0.1, \"species\": \"P_2\", \"y\": 0.07868932583326321}, {\"PT\": 0.10974987654930562, \"species\": \"P_2\", \"y\": 0.08475218572961124}, {\"PT\": 0.12045035402587821, \"species\": \"P_2\", \"y\": 0.09117474363449568}, {\"PT\": 0.1321941148466029, \"species\": \"P_2\", \"y\": 0.09796490678375804}, {\"PT\": 0.14508287784959398, \"species\": \"P_2\", \"y\": 0.10512927682846993}, {\"PT\": 0.1592282793341092, \"species\": \"P_2\", \"y\": 0.11267303594811592}, {\"PT\": 0.17475284000076838, \"species\": \"P_2\", \"y\": 0.12059984708880354}, {\"PT\": 0.19179102616724888, \"species\": \"P_2\", \"y\": 0.12891177035877757}, {\"PT\": 0.2104904144512021, \"species\": \"P_2\", \"y\": 0.1376091971807744}, {\"PT\": 0.23101297000831597, \"species\": \"P_2\", \"y\": 0.14669080332351347}, {\"PT\": 0.2535364493970112, \"species\": \"P_2\", \"y\": 0.1561535214383439}, {\"PT\": 0.2782559402207124, \"species\": \"P_2\", \"y\": 0.1659925332368486}, {\"PT\": 0.30538555088334157, \"species\": \"P_2\", \"y\": 0.17620128098360954}, {\"PT\": 0.33516026509388425, \"species\": \"P_2\", \"y\": 0.18677149756399297}, {\"PT\": 0.36783797718286343, \"species\": \"P_2\", \"y\": 0.19769325403333335}, {\"PT\": 0.40370172585965547, \"species\": \"P_2\", \"y\": 0.20895502326942395}, {\"PT\": 0.4430621457583881, \"species\": \"P_2\", \"y\": 0.22054375813767554}, {\"PT\": 0.4862601580065355, \"species\": \"P_2\", \"y\": 0.2324449824358711}, {\"PT\": 0.533669923120631, \"species\": \"P_2\", \"y\": 0.24464289280762855}, {\"PT\": 0.5857020818056667, \"species\": \"P_2\", \"y\": 0.257120469792299}, {\"PT\": 0.6428073117284322, \"species\": \"P_2\", \"y\": 0.26985959620441546}, {\"PT\": 0.7054802310718644, \"species\": \"P_2\", \"y\": 0.2828411810977828}, {\"PT\": 0.7742636826811272, \"species\": \"P_2\", \"y\": 0.2960452876580207}, {\"PT\": 0.8497534359086445, \"species\": \"P_2\", \"y\": 0.3094512634739916}, {\"PT\": 0.9326033468832199, \"species\": \"P_2\", \"y\": 0.3230378717555378}, {\"PT\": 1.0235310218990263, \"species\": \"P_2\", \"y\": 0.33678342218635515}, {\"PT\": 1.1233240329780276, \"species\": \"P_2\", \"y\": 0.3506659002222288}, {\"PT\": 1.2328467394420666, \"species\": \"P_2\", \"y\": 0.36466309376325495}, {\"PT\": 1.3530477745798075, \"species\": \"P_2\", \"y\": 0.37875271624230866}, {\"PT\": 1.484968262254465, \"species\": \"P_2\", \"y\": 0.39291252528008624}, {\"PT\": 1.6297508346206444, \"species\": \"P_2\", \"y\": 0.40712043615947846}, {\"PT\": 1.7886495290574351, \"species\": \"P_2\", \"y\": 0.42135462946919144}, {\"PT\": 1.9630406500402715, \"species\": \"P_2\", \"y\": 0.4355936523590508}, {\"PT\": 2.1544346900318843, \"species\": \"P_2\", \"y\": 0.4498165129380179}, {\"PT\": 2.3644894126454084, \"species\": \"P_2\", \"y\": 0.4640027674312564}, {\"PT\": 2.5950242113997373, \"species\": \"P_2\", \"y\": 0.4781325997951208}, {\"PT\": 2.848035868435802, \"species\": \"P_2\", \"y\": 0.49218689356900924}, {\"PT\": 3.1257158496882367, \"species\": \"P_2\", \"y\": 0.5061472958207289}, {\"PT\": 3.4304692863149193, \"species\": \"P_2\", \"y\": 0.5199962731172615}, {\"PT\": 3.764935806792469, \"species\": \"P_2\", \"y\": 0.533717159525297}, {\"PT\": 4.132012400115339, \"species\": \"P_2\", \"y\": 0.5472941967152098}, {\"PT\": 4.5348785081285845, \"species\": \"P_2\", \"y\": 0.5607125663077462}, {\"PT\": 4.977023564332112, \"species\": \"P_2\", \"y\": 0.5739584146640166}, {\"PT\": 5.462277217684343, \"species\": \"P_2\", \"y\": 0.5870188703758467}, {\"PT\": 5.994842503189412, \"species\": \"P_2\", \"y\": 0.5998820547646017}, {\"PT\": 6.5793322465756825, \"species\": \"P_2\", \"y\": 0.6125370857417747}, {\"PT\": 7.220809018385467, \"species\": \"P_2\", \"y\": 0.6249740754235427}, {\"PT\": 7.924828983539178, \"species\": \"P_2\", \"y\": 0.6371841219238735}, {\"PT\": 8.697490026177835, \"species\": \"P_2\", \"y\": 0.6491592957764619}, {\"PT\": 9.545484566618342, \"species\": \"P_2\", \"y\": 0.6608926214547796}, {\"PT\": 10.476157527896651, \"species\": \"P_2\", \"y\": 0.6723780544719333}, {\"PT\": 11.497569953977369, \"species\": \"P_2\", \"y\": 0.6836104545480887}, {\"PT\": 12.61856883066021, \"species\": \"P_2\", \"y\": 0.6945855553332363}, {\"PT\": 13.848863713938732, \"species\": \"P_2\", \"y\": 0.7052999311675234}, {\"PT\": 15.199110829529348, \"species\": \"P_2\", \"y\": 0.7157509613506929}, {\"PT\": 16.68100537200059, \"species\": \"P_2\", \"y\": 0.7259367923769716}, {\"PT\": 18.307382802953697, \"species\": \"P_2\", \"y\": 0.7358562985725914}, {\"PT\": 20.09233002565048, \"species\": \"P_2\", \"y\": 0.7455090415506367}, {\"PT\": 22.051307399030456, \"species\": \"P_2\", \"y\": 0.7548952288727201}, {\"PT\": 24.201282647943835, \"species\": \"P_2\", \"y\": 0.7640156722796789}, {\"PT\": 26.560877829466868, \"species\": \"P_2\", \"y\": 0.7728717458246792}, {\"PT\": 29.150530628251786, \"species\": \"P_2\", \"y\": 0.7814653442123345}, {\"PT\": 31.992671377973846, \"species\": \"P_2\", \"y\": 0.7897988416172199}, {\"PT\": 35.111917342151344, \"species\": \"P_2\", \"y\": 0.7978750512249496}, {\"PT\": 38.535285937105314, \"species\": \"P_2\", \"y\": 0.8056971857091976}, {\"PT\": 42.29242874389499, \"species\": \"P_2\", \"y\": 0.8132688188290305}, {\"PT\": 46.41588833612782, \"species\": \"P_2\", \"y\": 0.8205938483029968}, {\"PT\": 50.9413801481638, \"species\": \"P_2\", \"y\": 0.8276764600898192}, {\"PT\": 55.90810182512229, \"species\": \"P_2\", \"y\": 0.8345210941804637}, {\"PT\": 61.35907273413176, \"species\": \"P_2\", \"y\": 0.8411324119829602}, {\"PT\": 67.34150657750828, \"species\": \"P_2\", \"y\": 0.8475152653597271}, {\"PT\": 73.90722033525783, \"species\": \"P_2\", \"y\": 0.8536746673573522}, {\"PT\": 81.11308307896873, \"species\": \"P_2\", \"y\": 0.8596157646508609}, {\"PT\": 89.02150854450393, \"species\": \"P_2\", \"y\": 0.8653438117084111}, {\"PT\": 97.70099572992257, \"species\": \"P_2\", \"y\": 0.8708641466681002}, {\"PT\": 107.22672220103243, \"species\": \"P_2\", \"y\": 0.8761821689060604}, {\"PT\": 117.68119524349991, \"species\": \"P_2\", \"y\": 0.8813033182642038}, {\"PT\": 129.1549665014884, \"species\": \"P_2\", \"y\": 0.8862330558967654}, {\"PT\": 141.7474162926806, \"species\": \"P_2\", \"y\": 0.8909768466870598}, {\"PT\": 155.56761439304722, \"species\": \"P_2\", \"y\": 0.8955401431795483}, {\"PT\": 170.7352647470692, \"species\": \"P_2\", \"y\": 0.8999283709672571}, {\"PT\": 187.3817422860385, \"species\": \"P_2\", \"y\": 0.9041469154707042}, {\"PT\": 205.65123083486534, \"species\": \"P_2\", \"y\": 0.9082011100416706}, {\"PT\": 225.70197196339214, \"species\": \"P_2\", \"y\": 0.9120962253232613}, {\"PT\": 247.70763559917114, \"species\": \"P_2\", \"y\": 0.9158374597966633}, {\"PT\": 271.85882427329426, \"species\": \"P_2\", \"y\": 0.9194299314446935}, {\"PT\": 298.364724028334, \"species\": \"P_2\", \"y\": 0.9228786704625612}, {\"PT\": 327.4549162877732, \"species\": \"P_2\", \"y\": 0.9261886129471482}, {\"PT\": 359.3813663804629, \"species\": \"P_2\", \"y\": 0.9293645954974501}, {\"PT\": 394.420605943766, \"species\": \"P_2\", \"y\": 0.932411350660551}, {\"PT\": 432.87612810830615, \"species\": \"P_2\", \"y\": 0.9353335031595534}, {\"PT\": 475.0810162102798, \"species\": \"P_2\", \"y\": 0.9381355668421743}, {\"PT\": 521.400828799969, \"species\": \"P_2\", \"y\": 0.9408219422912241}, {\"PT\": 572.236765935022, \"species\": \"P_2\", \"y\": 0.9433969150408062}, {\"PT\": 628.029144183426, \"species\": \"P_2\", \"y\": 0.9458646543448271}, {\"PT\": 689.2612104349702, \"species\": \"P_2\", \"y\": 0.9482292124471873}, {\"PT\": 756.463327554629, \"species\": \"P_2\", \"y\": 0.9504945243058579}, {\"PT\": 830.2175681319752, \"species\": \"P_2\", \"y\": 0.9526644077258541}, {\"PT\": 911.1627561154896, \"species\": \"P_2\", \"y\": 0.9547425638589112}, {\"PT\": 1000.0, \"species\": \"P_2\", \"y\": 0.9567325780304037}]}}, {\"mode\": \"vega-lite\"});\n",
       "</script>"
      ],
      "text/plain": [
       "alt.LayerChart(...)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import altair as alt\n",
    "\n",
    "source = df.melt(\"PT\", var_name=\"species\", value_name=\"y\")\n",
    "\n",
    "# Create a selection that chooses the nearest point & selects based on x-value\n",
    "nearest = alt.selection_point(nearest=True, on=\"pointerover\",\n",
    "                              fields=[\"PT\"], empty=False)\n",
    "\n",
    "# The basic line\n",
    "line = alt.Chart(source).mark_line(interpolate=\"basis\").encode(\n",
    "    x=alt.X(\"PT:Q\", scale=alt.Scale(type=\"log\"), title='Ratio PT/kD'),\n",
    "    y=alt.Y(\"y:Q\", title='Fraction of total'),\n",
    "    color=\"species:N\",\n",
    ")\n",
    "\n",
    "# Draw points on the line, and highlight based on selection\n",
    "points = line.mark_point().encode(\n",
    "    opacity=alt.condition(nearest, alt.value(1), alt.value(0))\n",
    ")\n",
    "\n",
    "# Draw a rule at the location of the selection\n",
    "rules = alt.Chart(source).transform_pivot(\n",
    "    \"species\",\n",
    "    value=\"y\",\n",
    "    groupby=[\"PT\"]\n",
    ").mark_rule(color=\"black\").encode(\n",
    "    x=\"PT:Q\",\n",
    "    opacity=alt.condition(nearest, alt.value(0.3), alt.value(0)),\n",
    "    tooltip=[alt.Tooltip(c, type=\"quantitative\", format=\".2f\") for c in df.columns],\n",
    ").add_params(nearest)\n",
    "\n",
    "\n",
    "# Put the five layers into a chart and bind the data\n",
    "alt.layer(\n",
    "    line, points, rules\n",
    ").properties(\n",
    "    width=600, height=300\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From the graph, we can see that if we are at $k_D$, the ratio monomer to dimer is two-to-one, and 50% dimerization is reached at 3 times $k_D$, and for 95% saturation we need to be at > 500 times $k_D$!\n",
    "\n",
    "So what about the '10x above $k_D$ is full complex formation' rule? This rule only applies some situations where we study the binding between different partners, such as the formation of an enzyme-ligand complex, and will be the subject of the next post (to be published).  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Meanwhile, we can think about _why_ its so hard to reach full dimerization even if concentrations used are far higher than the dissociation constant. If we think about the reaction from an maximum entropy point of view, out intuition might tell us that the entropic equivalent of making all promomers into a dimer is the equivalent of putting all 'air molecules' into one corner of the room: it has a vanishingly low probability of happing because its so far away from the maximium entropy state of the system. \n",
    "\n",
    "Second, a closer look at the differential equation describing the change of $[P_2]$ also tells us the answer. There are two terms in this equation: one is positive and depends on $[P_1]$, the second is negative and depends on $[P_2]$. Therefore, even when there is a lot of total protomer $[P_T]$ compared to the $k_D$, as more and more dimer is formed $[P_1]$ will go down while $[P_2]$ goes up. Thus the positive term becomes smaller while the negative term becomes bigger, slowing down the formation of dimer, and equillibrium is reached at a point with still a large fraction of $P_1$ in solution.   "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv-py311",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}