A Python package to turn arbitrary polynomial ODEs into a transcriptional network simulating it.
Project description
ode-to-transcription-network
ode2tn is a Python package to turn arbitrary polynomial ODEs into a transcriptional network simulating it.
See this paper for details: TODO
Installation
Type pip install ode2tn at the command line.
Usage
See the notebook.ipynb for more examples of usage.
The functions ode2tn and plot_tn are the main elements of the package.
ode2tn converts a system of arbitrary polynomial ODEs into another system of ODEs representing a transcriptional network as defined in the paper above.
Each variable $x$ in the original ODEs is represented by a pair of variables $x^\top,x^\bot$, whose ratio $x^\top / x^\bot$ follows the same dynamics in the transcriptional network as $x$ does in the original ODEs.
plot_tn does this conversion and then plots the ratios by default, although it can be customized what exactly is plotted;
see the documentation for gpac.plot for a description of all options.
Here is a typical way to call each function:
from math import pi
import numpy as np
import sympy as sp
from transform import plot_tn, ode2tn
x,y = sp.symbols('x y')
odes = { # odes dict maps each symbol to an expression for its time derivative
x: y-2,
y: -x+2,
}
inits = { # inits maps each symbol to its initial value
x: 2,
y: 1,
}
gamma = 2 # uniform decay constant; should be set sufficiently large that ???
beta = 1 # constant introduced to keep values from going to infinity or 0
t_eval = np.linspace(0, 6*pi, 1000)
tn_odes, tn_inits, tn_ratios = ode2tn(odes, inits, gamma, beta)
for sym, expr in tn_odes.items():
print(f"{sym}' = {expr}")
print(f'{tn_inits=}')
print(f'{tn_ratios=}')
plot_tn(odes, inits, gamma, beta, t_eval=t_eval)
This will print
x_t' = x_b*y_t/y_b - 2*x_t + x_t/x_b
x_b' = 2*x_b**2/x_t - 2*x_b + 1
y_t' = 2*y_b - 2*y_t + y_t/y_b
y_b' = -2*y_b + 1 + x_t*y_b**2/(x_b*y_t)
tn_inits={x_t: 2, x_b: 1, y_t: 1, y_b: 1}
tn_ratios={x: x_t/x_b, y: y_t/y_b}
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.
The function plot_tn above does this conversion and then plots the ratios.
Running the code above in a Jupyter notebook will print the above text and show this figure:
One could also hand the transcriptional network ODEs to gpac to integrate, if you want to directly access the data being plotted above.
The OdeResult object returned by gpac.integrate_odes is the same returned by scipy.integrate.solve_ivp, 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:
t_eval = np.linspace(0, 2*pi, 5)
sol = gp.integrate_odes(tn_odes, tn_inits, t_eval)
print(f'times = {sol.t}')
print(f'x_y = {sol.y[0]}')
print(f'x_b = {sol.y[1]}')
print(f'y_t = {sol.y[2]}')
print(f'y_b = {sol.y[3]}')
which would print
times = [0. 1.57079633 3.14159265 4.71238898 6.28318531]
x_y = [2. 1.78280757 3.67207594 2.80592514 1.71859172]
x_b = [1. 1.78425369 1.83663725 0.93260227 0.859926 ]
y_t = [1. 1.87324904 2.14156469 2.10338162 2.74383426]
y_b = [1. 0.93637933 0.71348949 1.05261915 2.78279691]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ode2tn-1.0.0.tar.gz.
File metadata
- Download URL: ode2tn-1.0.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f49c570f8055a4850b87b3790cf6f87d94d3fc19b349b99e3f9a2f4a64aa5b31
|
|
| MD5 |
a0cef7c9885de279498ca4bc6a19d11b
|
|
| BLAKE2b-256 |
bcc322716f1ae79b1e2573de4e4f7801e2e82878bf09b1a001e118a5430e758d
|
Provenance
The following attestation bundles were made for ode2tn-1.0.0.tar.gz:
Publisher:
python-publish.yml on UC-Davis-molecular-computing/ode-to-transcription-network
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ode2tn-1.0.0.tar.gz -
Subject digest:
f49c570f8055a4850b87b3790cf6f87d94d3fc19b349b99e3f9a2f4a64aa5b31 - Sigstore transparency entry: 199734283
- Sigstore integration time:
-
Permalink:
UC-Davis-molecular-computing/ode-to-transcription-network@7eca2fa3a2158c6263891bb33d26685e330e9a3e -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/UC-Davis-molecular-computing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7eca2fa3a2158c6263891bb33d26685e330e9a3e -
Trigger Event:
release
-
Statement type:
File details
Details for the file ode2tn-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ode2tn-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9a818f800c31edc7615d7e9f6af69e0be701f1059ede4738abe6ded7b6f4254
|
|
| MD5 |
5c7253c991e0aa38a8f3573b1c1275e6
|
|
| BLAKE2b-256 |
24a4e1c25b052f9cff473f96da66d5f9ce12654c4fde73c87084b37f8740566c
|
Provenance
The following attestation bundles were made for ode2tn-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on UC-Davis-molecular-computing/ode-to-transcription-network
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ode2tn-1.0.0-py3-none-any.whl -
Subject digest:
c9a818f800c31edc7615d7e9f6af69e0be701f1059ede4738abe6ded7b6f4254 - Sigstore transparency entry: 199734284
- Sigstore integration time:
-
Permalink:
UC-Davis-molecular-computing/ode-to-transcription-network@7eca2fa3a2158c6263891bb33d26685e330e9a3e -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/UC-Davis-molecular-computing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7eca2fa3a2158c6263891bb33d26685e330e9a3e -
Trigger Event:
release
-
Statement type: