ode2tn 1.0.2__py3-none-any.whl → 1.0.3__py3-none-any.whl
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/transform.py +8 -0
- {ode2tn-1.0.2.dist-info → ode2tn-1.0.3.dist-info}/METADATA +33 -12
- ode2tn-1.0.3.dist-info/RECORD +7 -0
- ode2tn-1.0.2.dist-info/RECORD +0 -7
- {ode2tn-1.0.2.dist-info → ode2tn-1.0.3.dist-info}/WHEEL +0 -0
- {ode2tn-1.0.2.dist-info → ode2tn-1.0.3.dist-info}/licenses/LICENSE +0 -0
- {ode2tn-1.0.2.dist-info → ode2tn-1.0.3.dist-info}/top_level.txt +0 -0
ode2tn/transform.py
CHANGED
@@ -18,6 +18,7 @@ def plot_tn(
|
|
18
18
|
scale: float = 1.0,
|
19
19
|
t_span: tuple[float, float] | None = None,
|
20
20
|
show_factors: bool = False,
|
21
|
+
latex_legend: bool = True,
|
21
22
|
resets: dict[float, dict[sp.Symbol | str, float]] | None = None,
|
22
23
|
dependent_symbols: dict[sp.Symbol | str, sp.Expr | str] | None = None,
|
23
24
|
figure_size: tuple[float, float] = (10, 3),
|
@@ -61,6 +62,12 @@ def plot_tn(
|
|
61
62
|
`symbols_to_plot` to ``[ratios, factors]``, where ratios is a list of dependent symbols
|
62
63
|
`x=x_top/x_bot`, and factors is a list of symbols with the transcription factors `x_top`, `x_bot`,
|
63
64
|
for each original variable `x`.
|
65
|
+
latex_legend: If True, surround each symbol name with dollar signs, unless it is already surrounded with them,
|
66
|
+
so that the legend is interpreted as LaTeX. If this is True, then the symbol name must either
|
67
|
+
start and end with `$`, or neither start nor end with `$`. Unlike in the gpac package, this is True
|
68
|
+
by default. The names of transcription factors are automatically surrounded by dollar signs.
|
69
|
+
This option makes sure the legend showing original variables (or dependent symbols) also have `$` added
|
70
|
+
so as to be interpreted as LaTeX.
|
64
71
|
resets:
|
65
72
|
If specified, this is a dict mapping times to "configurations"
|
66
73
|
(i.e., dict mapping symbols/str to values).
|
@@ -112,6 +119,7 @@ def plot_tn(
|
|
112
119
|
dependent_symbols=dependent_symbols_tn,
|
113
120
|
resets=resets,
|
114
121
|
figure_size=figure_size,
|
122
|
+
latex_legend=latex_legend,
|
115
123
|
symbols_to_plot=symbols_to_plot,
|
116
124
|
legend=legend,
|
117
125
|
show=show,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ode2tn
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.3
|
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
|
@@ -52,31 +52,52 @@ inits = { # inits maps each symbol to its initial value
|
|
52
52
|
}
|
53
53
|
gamma = 2 # uniform decay constant; should be set sufficiently large that ???
|
54
54
|
beta = 1 # constant introduced to keep values from going to infinity or 0
|
55
|
-
|
56
|
-
|
55
|
+
tn_odes, tn_inits, tn_syms = ode2tn(odes, inits, gamma=gamma, beta=beta)
|
56
|
+
gp.display_odes(tn_odes)
|
57
|
+
print(f'{tn_inits=}')
|
58
|
+
print(f'{tn_syms=}')
|
57
59
|
```
|
58
60
|
|
59
|
-
|
61
|
+
When run in a Jupyter notebook, this will show
|
62
|
+
|
63
|
+

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

|
75
93
|
|
76
|
-
|
94
|
+
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).
|
95
|
+
If left unspecified, it defaults to `False` and plots only the original values (ratios of pairs of transcription factors, $x,y$ above).
|
96
|
+
|
97
|
+
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
98
|
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
99
|
|
79
|
-
```
|
100
|
+
```python
|
80
101
|
t_eval = np.linspace(0, 2*pi, 5)
|
81
102
|
sol = gp.integrate_odes(tn_odes, tn_inits, t_eval)
|
82
103
|
print(f'times = {sol.t}')
|
@@ -0,0 +1,7 @@
|
|
1
|
+
ode2tn/__init__.py,sha256=b_mINIsNfCWzgG7QVYMsRsWKDLvp2QKFAzRqWtYqwDA,30
|
2
|
+
ode2tn/transform.py,sha256=8GciVR2iGRRWgKyvPoYoQ5TZjKrOdNyzaH_ZukJiVsw,16829
|
3
|
+
ode2tn-1.0.3.dist-info/licenses/LICENSE,sha256=VV9UH0kkG-2edZvwJOqgtN12bZIzs2vn9_cq1SjoUJc,1091
|
4
|
+
ode2tn-1.0.3.dist-info/METADATA,sha256=RbwHIvSA6PgVWV9I57Fs9n2OdU7ocksS65YPaxs7174,4882
|
5
|
+
ode2tn-1.0.3.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
6
|
+
ode2tn-1.0.3.dist-info/top_level.txt,sha256=fPQ9s5yLIYfazJS7wBBfU9EsWa9RGALq8VL-wUYRlao,7
|
7
|
+
ode2tn-1.0.3.dist-info/RECORD,,
|
ode2tn-1.0.2.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
ode2tn/__init__.py,sha256=b_mINIsNfCWzgG7QVYMsRsWKDLvp2QKFAzRqWtYqwDA,30
|
2
|
-
ode2tn/transform.py,sha256=8gQVHaCRTdiACQPZdkB3OPfc2KOZTA3YwMgbXDDnNkE,16155
|
3
|
-
ode2tn-1.0.2.dist-info/licenses/LICENSE,sha256=VV9UH0kkG-2edZvwJOqgtN12bZIzs2vn9_cq1SjoUJc,1091
|
4
|
-
ode2tn-1.0.2.dist-info/METADATA,sha256=MSGeKttEB-ImlNvBof07AeyxR1rOCBf48tUNinaIgS0,4095
|
5
|
-
ode2tn-1.0.2.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
6
|
-
ode2tn-1.0.2.dist-info/top_level.txt,sha256=fPQ9s5yLIYfazJS7wBBfU9EsWa9RGALq8VL-wUYRlao,7
|
7
|
-
ode2tn-1.0.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|