ode2tn 1.0.2__tar.gz → 1.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ode2tn-1.0.2 → ode2tn-1.0.4}/PKG-INFO +45 -23
- {ode2tn-1.0.2 → ode2tn-1.0.4}/README.md +44 -22
- ode2tn-1.0.4/ode2tn/__init__.py +8 -0
- ode2tn-1.0.4/ode2tn/transform.py +676 -0
- {ode2tn-1.0.2 → ode2tn-1.0.4}/ode2tn.egg-info/PKG-INFO +45 -23
- {ode2tn-1.0.2 → ode2tn-1.0.4}/pyproject.toml +6 -1
- ode2tn-1.0.2/ode2tn/__init__.py +0 -1
- ode2tn-1.0.2/ode2tn/transform.py +0 -379
- {ode2tn-1.0.2 → ode2tn-1.0.4}/LICENSE +0 -0
- {ode2tn-1.0.2 → ode2tn-1.0.4}/ode2tn.egg-info/SOURCES.txt +0 -0
- {ode2tn-1.0.2 → ode2tn-1.0.4}/ode2tn.egg-info/dependency_links.txt +0 -0
- {ode2tn-1.0.2 → ode2tn-1.0.4}/ode2tn.egg-info/requires.txt +0 -0
- {ode2tn-1.0.2 → ode2tn-1.0.4}/ode2tn.egg-info/top_level.txt +0 -0
- {ode2tn-1.0.2 → ode2tn-1.0.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ode2tn
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.4
|
4
4
|
Summary: A Python package to turn arbitrary polynomial ODEs into a transcriptional network simulating it.
|
5
5
|
Author-email: Dave Doty <doty@ucdavis.edu>
|
6
6
|
License-Expression: MIT
|
@@ -14,7 +14,7 @@ Requires-Dist: scipy>=1.15
|
|
14
14
|
Requires-Dist: sympy>=1.13
|
15
15
|
Dynamic: license-file
|
16
16
|
|
17
|
-
#
|
17
|
+
# ode2tn
|
18
18
|
ode2tn is a Python package to compile arbitrary polynomial ODEs into a transcriptional network simulating the ODEs.
|
19
19
|
|
20
20
|
See this paper for details: TODO
|
@@ -25,11 +25,11 @@ Type `pip install ode2tn` at the command line.
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
-
See the [notebook.ipynb](notebook.ipynb) for more examples of usage.
|
28
|
+
See the [notebook.ipynb](notebook.ipynb) (relative link on GitHub; will not work on other sites like pypi.org) for more examples of usage, including all the examples discussed in the paper.
|
29
29
|
|
30
30
|
The functions `ode2tn` and `plot_tn` are the main elements of the package.
|
31
31
|
`ode2tn` converts a system of arbitrary polynomial ODEs into another system of ODEs representing a transcriptional network as defined in the paper above.
|
32
|
-
Each variable $x$ in the original ODEs is represented by a pair of variables $x^\top,x^\bot$, whose ratio
|
32
|
+
Each variable $x$ in the original ODEs is represented by a pair of variables $x^\top,x^\bot$, whose ratio $\frac{x^\top}{x^\bot}$ follows the same dynamics in the transcriptional network as $x$ does in the original ODEs.
|
33
33
|
`plot_tn` does this conversion and then plots the ratios by default, although it can be customized what exactly is plotted;
|
34
34
|
see the documentation for [gpac.plot](https://gpac.readthedocs.io/en/latest/#gpac.ode.plot) for a description of all options.
|
35
35
|
|
@@ -42,41 +42,63 @@ import sympy as sp
|
|
42
42
|
from transform import plot_tn, ode2tn
|
43
43
|
|
44
44
|
x,y = sp.symbols('x y')
|
45
|
-
odes = {
|
46
|
-
x: y-2,
|
47
|
-
y: -x+2,
|
45
|
+
odes = { # odes dict maps each symbol to an expression for its time derivative
|
46
|
+
x: y-2, # dx/dt = y-2
|
47
|
+
y: -x+2, # dy/dt = -x+2
|
48
48
|
}
|
49
|
-
inits = {
|
50
|
-
x: 2,
|
51
|
-
y: 1,
|
49
|
+
inits = { # inits maps each symbol to its initial value
|
50
|
+
x: 2, # x(0) = 2
|
51
|
+
y: 1, # y(0) = 1
|
52
52
|
}
|
53
|
-
gamma = 2
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
gamma = 2 # uniform decay constant; should have gamma > max q^-;
|
54
|
+
# see proof of main Theorem in paper for what q^- is
|
55
|
+
beta = 1 # constant introduced to keep values from going to infinity or 0
|
56
|
+
tn_odes, tn_inits, tn_syms = ode2tn(odes, inits, gamma=gamma, beta=beta)
|
57
|
+
gp.display_odes(tn_odes) # displays nice rendered LaTeX in Jupyter notebook
|
58
|
+
print(f'{tn_inits=}')
|
59
|
+
print(f'{tn_syms=}')
|
57
60
|
```
|
58
61
|
|
59
|
-
|
62
|
+
When run in a Jupyter notebook, this will show
|
63
|
+
|
64
|
+

|
65
|
+
|
66
|
+
showing that the variables `x` and `y` have been replace by pairs `x_t,x_b` and `y_t,y_b`, whose ratios `x_t/x_b` and `y_t/y_b` will track the values of the original variable `x` and `y` over time.
|
60
67
|
|
68
|
+
If not in a Jupyter notebook, one could also inspect the transcriptional network ODEs via
|
69
|
+
```python
|
70
|
+
for var, ode in tn_odes.items():
|
71
|
+
print(f"{var}' = {ode}")
|
72
|
+
```
|
73
|
+
which would print a text-based version of the equations:
|
61
74
|
```
|
62
75
|
x_t' = x_b*y_t/y_b - 2*x_t + x_t/x_b
|
63
76
|
x_b' = 2*x_b**2/x_t - 2*x_b + 1
|
64
77
|
y_t' = 2*y_b - 2*y_t + y_t/y_b
|
65
78
|
y_b' = -2*y_b + 1 + x_t*y_b**2/(x_b*y_t)
|
66
|
-
tn_inits={x_t: 2, x_b: 1, y_t: 1, y_b: 1}
|
67
|
-
tn_syms={x: (x_t, x_b), y: (y_t, y_b)}
|
68
79
|
```
|
69
80
|
|
70
|
-
|
71
|
-
|
72
|
-
Running the code above in a Jupyter notebook will print the above text and show this figure:
|
81
|
+
The function `plot_tn` above does this conversion on the *original* odes and then plots the ratios.
|
82
|
+
Running
|
73
83
|
|
74
|
-
|
84
|
+
```python
|
85
|
+
t_eval = np.linspace(0, 6*pi, 1000)
|
86
|
+
# note below it is odes and inits, not tn_odes and tn_inits
|
87
|
+
# plot_tn calls ode2tn to convert the ODEs before plotting
|
88
|
+
plot_tn(odes, inits, gamma=gamma, beta=beta, t_eval=t_eval, show_factors=True)
|
89
|
+
```
|
90
|
+
|
91
|
+
in a Jupyter notebook will show this figure:
|
75
92
|
|
76
|
-
|
93
|
+

|
94
|
+
|
95
|
+
The parameter `show_factors` above indicates to show a second subplot with the underlying transcription factors ($x^\top, x^\bot, y^\top, y^\bot$ above).
|
96
|
+
If left unspecified, it defaults to `False` and plots only the original values (ratios of pairs of transcription factors, $x,y$ above).
|
97
|
+
|
98
|
+
One could also hand the transcriptional network ODEs to [gpac](https://github.com/UC-Davis-molecular-computing/gpac) to integrate, if you want to directly access the data being plotted above.
|
77
99
|
The `OdeResult` object returned by `gpac.integrate_odes` is the same returned by [`scipy.integrate.solve_ivp`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html), where the return value `sol` has a field `sol.y` that has the values of the variables in the order they were inserted into `tn_odes`, which will be the same as the order in which the original variables `x` and `y` were inserted, with `x_t` coming before `x_b`:
|
78
100
|
|
79
|
-
```
|
101
|
+
```python
|
80
102
|
t_eval = np.linspace(0, 2*pi, 5)
|
81
103
|
sol = gp.integrate_odes(tn_odes, tn_inits, t_eval)
|
82
104
|
print(f'times = {sol.t}')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# ode2tn
|
2
2
|
ode2tn is a Python package to compile arbitrary polynomial ODEs into a transcriptional network simulating the ODEs.
|
3
3
|
|
4
4
|
See this paper for details: TODO
|
@@ -9,11 +9,11 @@ Type `pip install ode2tn` at the command line.
|
|
9
9
|
|
10
10
|
## Usage
|
11
11
|
|
12
|
-
See the [notebook.ipynb](notebook.ipynb) for more examples of usage.
|
12
|
+
See the [notebook.ipynb](notebook.ipynb) (relative link on GitHub; will not work on other sites like pypi.org) for more examples of usage, including all the examples discussed in the paper.
|
13
13
|
|
14
14
|
The functions `ode2tn` and `plot_tn` are the main elements of the package.
|
15
15
|
`ode2tn` converts a system of arbitrary polynomial ODEs into another system of ODEs representing a transcriptional network as defined in the paper above.
|
16
|
-
Each variable $x$ in the original ODEs is represented by a pair of variables $x^\top,x^\bot$, whose ratio
|
16
|
+
Each variable $x$ in the original ODEs is represented by a pair of variables $x^\top,x^\bot$, whose ratio $\frac{x^\top}{x^\bot}$ follows the same dynamics in the transcriptional network as $x$ does in the original ODEs.
|
17
17
|
`plot_tn` does this conversion and then plots the ratios by default, although it can be customized what exactly is plotted;
|
18
18
|
see the documentation for [gpac.plot](https://gpac.readthedocs.io/en/latest/#gpac.ode.plot) for a description of all options.
|
19
19
|
|
@@ -26,41 +26,63 @@ import sympy as sp
|
|
26
26
|
from transform import plot_tn, ode2tn
|
27
27
|
|
28
28
|
x,y = sp.symbols('x y')
|
29
|
-
odes = {
|
30
|
-
x: y-2,
|
31
|
-
y: -x+2,
|
29
|
+
odes = { # odes dict maps each symbol to an expression for its time derivative
|
30
|
+
x: y-2, # dx/dt = y-2
|
31
|
+
y: -x+2, # dy/dt = -x+2
|
32
32
|
}
|
33
|
-
inits = {
|
34
|
-
x: 2,
|
35
|
-
y: 1,
|
33
|
+
inits = { # inits maps each symbol to its initial value
|
34
|
+
x: 2, # x(0) = 2
|
35
|
+
y: 1, # y(0) = 1
|
36
36
|
}
|
37
|
-
gamma = 2
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
gamma = 2 # uniform decay constant; should have gamma > max q^-;
|
38
|
+
# see proof of main Theorem in paper for what q^- is
|
39
|
+
beta = 1 # constant introduced to keep values from going to infinity or 0
|
40
|
+
tn_odes, tn_inits, tn_syms = ode2tn(odes, inits, gamma=gamma, beta=beta)
|
41
|
+
gp.display_odes(tn_odes) # displays nice rendered LaTeX in Jupyter notebook
|
42
|
+
print(f'{tn_inits=}')
|
43
|
+
print(f'{tn_syms=}')
|
41
44
|
```
|
42
45
|
|
43
|
-
|
46
|
+
When run in a Jupyter notebook, this will show
|
47
|
+
|
48
|
+

|
49
|
+
|
50
|
+
showing that the variables `x` and `y` have been replace by pairs `x_t,x_b` and `y_t,y_b`, whose ratios `x_t/x_b` and `y_t/y_b` will track the values of the original variable `x` and `y` over time.
|
44
51
|
|
52
|
+
If not in a Jupyter notebook, one could also inspect the transcriptional network ODEs via
|
53
|
+
```python
|
54
|
+
for var, ode in tn_odes.items():
|
55
|
+
print(f"{var}' = {ode}")
|
56
|
+
```
|
57
|
+
which would print a text-based version of the equations:
|
45
58
|
```
|
46
59
|
x_t' = x_b*y_t/y_b - 2*x_t + x_t/x_b
|
47
60
|
x_b' = 2*x_b**2/x_t - 2*x_b + 1
|
48
61
|
y_t' = 2*y_b - 2*y_t + y_t/y_b
|
49
62
|
y_b' = -2*y_b + 1 + x_t*y_b**2/(x_b*y_t)
|
50
|
-
tn_inits={x_t: 2, x_b: 1, y_t: 1, y_b: 1}
|
51
|
-
tn_syms={x: (x_t, x_b), y: (y_t, y_b)}
|
52
63
|
```
|
53
64
|
|
54
|
-
|
55
|
-
|
56
|
-
Running the code above in a Jupyter notebook will print the above text and show this figure:
|
65
|
+
The function `plot_tn` above does this conversion on the *original* odes and then plots the ratios.
|
66
|
+
Running
|
57
67
|
|
58
|
-
|
68
|
+
```python
|
69
|
+
t_eval = np.linspace(0, 6*pi, 1000)
|
70
|
+
# note below it is odes and inits, not tn_odes and tn_inits
|
71
|
+
# plot_tn calls ode2tn to convert the ODEs before plotting
|
72
|
+
plot_tn(odes, inits, gamma=gamma, beta=beta, t_eval=t_eval, show_factors=True)
|
73
|
+
```
|
74
|
+
|
75
|
+
in a Jupyter notebook will show this figure:
|
59
76
|
|
60
|
-
|
77
|
+

|
78
|
+
|
79
|
+
The parameter `show_factors` above indicates to show a second subplot with the underlying transcription factors ($x^\top, x^\bot, y^\top, y^\bot$ above).
|
80
|
+
If left unspecified, it defaults to `False` and plots only the original values (ratios of pairs of transcription factors, $x,y$ above).
|
81
|
+
|
82
|
+
One could also hand the transcriptional network ODEs to [gpac](https://github.com/UC-Davis-molecular-computing/gpac) to integrate, if you want to directly access the data being plotted above.
|
61
83
|
The `OdeResult` object returned by `gpac.integrate_odes` is the same returned by [`scipy.integrate.solve_ivp`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html), where the return value `sol` has a field `sol.y` that has the values of the variables in the order they were inserted into `tn_odes`, which will be the same as the order in which the original variables `x` and `y` were inserted, with `x_t` coming before `x_b`:
|
62
84
|
|
63
|
-
```
|
85
|
+
```python
|
64
86
|
t_eval = np.linspace(0, 2*pi, 5)
|
65
87
|
sol = gp.integrate_odes(tn_odes, tn_inits, t_eval)
|
66
88
|
print(f'times = {sol.t}')
|