| Name | jsmfsb JSON |
| Version |
1.0.0
JSON |
| download |
| home_page | None |
| Summary | Python+JAX code relating to the textbook, Stochastic modelling for systems biology, third edition |
| upload_time | 2024-09-08 15:35:35 |
| maintainer | None |
| docs_url | None |
| author | None |
| requires_python | >=3.8 |
| license | None |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# JAX-SMfSB (jsmfsb)
## SMfSB code in Python+JAX
Python code relating to the book [Stochastic Modelling for Systems Biology, third edition](https://github.com/darrenjw/smfsb/).
There is a regular Python+Numpy package on PyPI, [smfsb](https://pypi.org/project/smfsb/), which has complete coverage of the book. If you are new to the book and/or this codebase, that might be a simpler place to start.
*This* package covers all of the *core simulation and inference algorithms* from the book, including the parsing of SBML and SBML-shorthand models. These core algorithms will run very fast, using [JAX](https://jax.readthedocs.io/). Computationally intensive algorithms will typically run between 50 and 150 times faster than they would using the regular `smfsb` package, even without a GPU (but YMMV). You must install JAX (which is system dependent), before attempting to install this package. See the [JAX documentation](https://jax.readthedocs.io/en/latest/installation.html) for details, but for a CPU-only installation, it should be as simple as `pip install jax`.
Once you have JAX installed and working correctly, you can install this package with:
```bash
pip install jsmfsb
```
You can test that your installation is working with the following example.
```python
import jax
import jsmfsb
lvmod = jsmfsb.models.lv()
step = lvmod.stepGillespie()
k0 = jax.random.key(42)
out = jsmfsb.simTs(k0, lvmod.m, 0, 30, 0.1, step)
assert(out.shape == (300, 2))
```
If you have `matplotlib` installed (`pip install matplotlib`), then you can also plot the results with:
```python
import matplotlib.pyplot as plt
fig, axis = plt.subplots()
for i in range(2):
axis.plot(range(out.shape[0]), out[:,i])
axis.legend(lvmod.n)
fig.savefig("lv.pdf")
```
The API for this package is very similar to that of the `smfsb` package. The main difference is that non-deterministic (random) functions have an extra argument (typically the first argument) that corresponds to a JAX random number key. See the [relevant section](https://jax.readthedocs.io/en/latest/random-numbers.html) of the JAX documentation for further information regarding random numbers in JAX code.
For further information, see the [demo directory](https://github.com/darrenjw/jax-smfsb/tree/main/demos) and the [API documentation](https://jax-smfsb.readthedocs.io/en/latest/index.html). Within the demos directory, see [shbuild.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/shbuild.py) for an example of how to specify a (SEIR epidemic) model using SBML-shorthand and [stepCLE2Df.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/stepCLE2Df.py) for a 2-d reaction-diffusion simulation. For parameter inference (from time course data), see [abc-cal.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/abc-cal.py) for ABC inference, [abcSmc.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/abcSmc.py) for ABC-SMC inference and [pmmh.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/pmmh.py) for particle marginal Metropolis-Hastings MCMC-based inference. There are many other demos besides these.
You can view this package on [GitHub](https://github.com/darrenjw/jax-smfsb) or [PyPI](https://pypi.org/project/jsmfsb/).
**Copyright (C) 2024 Darren J Wilkinson**
Raw data
{
"_id": null,
"home_page": null,
"name": "jsmfsb",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Darren Wilkinson <darrenjwilkinson@btinternet.com>",
"download_url": "https://files.pythonhosted.org/packages/e7/03/806294edea64ddb013092986d92b20b142a7b7bfe8a5f8796d4c1262a56a/jsmfsb-1.0.0.tar.gz",
"platform": null,
"description": "# JAX-SMfSB (jsmfsb)\n\n## SMfSB code in Python+JAX\n\nPython code relating to the book [Stochastic Modelling for Systems Biology, third edition](https://github.com/darrenjw/smfsb/).\n\nThere is a regular Python+Numpy package on PyPI, [smfsb](https://pypi.org/project/smfsb/), which has complete coverage of the book. If you are new to the book and/or this codebase, that might be a simpler place to start.\n\n*This* package covers all of the *core simulation and inference algorithms* from the book, including the parsing of SBML and SBML-shorthand models. These core algorithms will run very fast, using [JAX](https://jax.readthedocs.io/). Computationally intensive algorithms will typically run between 50 and 150 times faster than they would using the regular `smfsb` package, even without a GPU (but YMMV). You must install JAX (which is system dependent), before attempting to install this package. See the [JAX documentation](https://jax.readthedocs.io/en/latest/installation.html) for details, but for a CPU-only installation, it should be as simple as `pip install jax`.\n\nOnce you have JAX installed and working correctly, you can install this package with:\n```bash\npip install jsmfsb\n```\n\nYou can test that your installation is working with the following example.\n```python\nimport jax\nimport jsmfsb\n\nlvmod = jsmfsb.models.lv()\nstep = lvmod.stepGillespie()\nk0 = jax.random.key(42)\nout = jsmfsb.simTs(k0, lvmod.m, 0, 30, 0.1, step)\nassert(out.shape == (300, 2))\n```\n\nIf you have `matplotlib` installed (`pip install matplotlib`), then you can also plot the results with:\n```python\nimport matplotlib.pyplot as plt\nfig, axis = plt.subplots()\nfor i in range(2):\n\taxis.plot(range(out.shape[0]), out[:,i])\n\naxis.legend(lvmod.n)\nfig.savefig(\"lv.pdf\")\n```\n\nThe API for this package is very similar to that of the `smfsb` package. The main difference is that non-deterministic (random) functions have an extra argument (typically the first argument) that corresponds to a JAX random number key. See the [relevant section](https://jax.readthedocs.io/en/latest/random-numbers.html) of the JAX documentation for further information regarding random numbers in JAX code.\n\nFor further information, see the [demo directory](https://github.com/darrenjw/jax-smfsb/tree/main/demos) and the [API documentation](https://jax-smfsb.readthedocs.io/en/latest/index.html). Within the demos directory, see [shbuild.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/shbuild.py) for an example of how to specify a (SEIR epidemic) model using SBML-shorthand and [stepCLE2Df.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/stepCLE2Df.py) for a 2-d reaction-diffusion simulation. For parameter inference (from time course data), see [abc-cal.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/abc-cal.py) for ABC inference, [abcSmc.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/abcSmc.py) for ABC-SMC inference and [pmmh.py](https://github.com/darrenjw/jax-smfsb/tree/main/demos/pmmh.py) for particle marginal Metropolis-Hastings MCMC-based inference. There are many other demos besides these.\n\nYou can view this package on [GitHub](https://github.com/darrenjw/jax-smfsb) or [PyPI](https://pypi.org/project/jsmfsb/).\n\n\n\n\n**Copyright (C) 2024 Darren J Wilkinson**\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Python+JAX code relating to the textbook, Stochastic modelling for systems biology, third edition",
"version": "1.0.0",
"project_urls": {
"Documentation": "https://jax-smfsb.readthedocs.io/",
"Homepage": "https://github.com/darrenjw/jax-smfsb",
"Issues": "https://github.com/darrenjw/jax-smfsb/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0fbd401119fceaa04db1246c5fdb454a5b308fa4daf3e1c0ec75c8cb7d166689",
"md5": "2768aa2949d788120117ad3a86e53166",
"sha256": "9c9937ce80b9bf49c4943106bad64d9455edc64e3176f78a333bb544a34ddc96"
},
"downloads": -1,
"filename": "jsmfsb-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2768aa2949d788120117ad3a86e53166",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 22391,
"upload_time": "2024-09-08T15:35:31",
"upload_time_iso_8601": "2024-09-08T15:35:31.575882Z",
"url": "https://files.pythonhosted.org/packages/0f/bd/401119fceaa04db1246c5fdb454a5b308fa4daf3e1c0ec75c8cb7d166689/jsmfsb-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e703806294edea64ddb013092986d92b20b142a7b7bfe8a5f8796d4c1262a56a",
"md5": "1590d1d688761103958c2c4b3bb10b26",
"sha256": "f210fdeaf48d70123fcf870a859fc72318c95566b0ea8f9d2ce9d3a6faa978ac"
},
"downloads": -1,
"filename": "jsmfsb-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "1590d1d688761103958c2c4b3bb10b26",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 2647839,
"upload_time": "2024-09-08T15:35:35",
"upload_time_iso_8601": "2024-09-08T15:35:35.178319Z",
"url": "https://files.pythonhosted.org/packages/e7/03/806294edea64ddb013092986d92b20b142a7b7bfe8a5f8796d4c1262a56a/jsmfsb-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-08 15:35:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "darrenjw",
"github_project": "jax-smfsb",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "jsmfsb"
}