hgrecco / simbio

Simulation of Biological Systems
6 stars 0 forks source link

pyABC integration proposal #12

Open sadeus opened 4 years ago

sadeus commented 4 years ago

pyABC is a framework for doing distributed, likelihood-free inference. In a nutshell, if you want a model with parameters, experimental data, you use this library/framework to get a distribution (as a random variable) of the model parameters (which is called posteriori distribution). As you may already know, we are using bayesian statistics, where it makes sense to consider the parameters as random variables instead of the experimental data, and thus the experimental data is the ground knowledge.

The usage of pyABC is two-fold, for a part to found proper parameters values and also to validate the model election (for now by hand).

The proposed solution for now, is to create a function into the umbrella of algo package which will receive the model (the universal compartment, as today) and the experimental data. The model may contain the first guess, as it is needed to construct it. pyABC also saves the history using sqlite, so we will add a function of restore a old calculation just providing the db file (we will not do mangling on that for now).

maurosilber commented 4 years ago

I think that all integrations, functions of the algo module, should receive an instance of Simulator, not of the Compartment (model).

Simulator has a Simulator._run method, which build and runs a solver. Or it has the Simulator.create_solver method, which creates and returns a solver, if the integration requires a customized running of the solver. Both ways allow for variation of parameters and/or initial concentrations of species.

sadeus commented 4 years ago

@maurosilber do you have a example of varying the parameters of an Simulator instance?

maurosilber commented 4 years ago

It may need better docstrings, but Simulator __init__, create_solver and run methods have a values parameter that takes a dict[str | Species | Parameter, float], which overrides the default concentrations and parameters values from the model.

I added an example here.

sadeus commented 4 years ago

One concern that I have with pyABC, is that it have this dependency tree

pyabc==0.10.7
  - bokeh [required: >=2.1.1, installed: 2.2.3]
    - Jinja2 [required: >=2.7, installed: 2.11.2]
      - MarkupSafe [required: >=0.23, installed: 1.1.1]
    - numpy [required: >=1.11.3, installed: 1.19.2]
    - packaging [required: >=16.8, installed: 20.4]
      - pyparsing [required: >=2.0.2, installed: 2.4.7]
      - six [required: Any, installed: 1.15.0]
    - pillow [required: >=7.1.0, installed: 7.2.0]
    - python-dateutil [required: >=2.1, installed: 2.8.1]
      - six [required: >=1.5, installed: 1.15.0]
    - PyYAML [required: >=3.10, installed: 5.3.1]
    - tornado [required: >=5.1, installed: 6.0.4]
    - typing-extensions [required: >=3.7.4, installed: 3.7.4.3]
  - click [required: >=7.1.2, installed: 7.1.2]
  - cloudpickle [required: >=1.5.0, installed: 1.6.0]
  - dill [required: >=0.3.2, installed: 0.3.2]
  - distributed [required: >=2.21.0, installed: 2.30.0]
    - click [required: >=6.6, installed: 7.1.2]
    - cloudpickle [required: >=1.5.0, installed: 1.6.0]
    - dask [required: >=2.9.0, installed: 2.30.0]
      - pyyaml [required: Any, installed: 5.3.1]
    - msgpack [required: >=0.6.0, installed: 1.0.0]
    - psutil [required: >=5.0, installed: 5.7.3]
    - pyyaml [required: Any, installed: 5.3.1]
    - setuptools [required: Any, installed: 41.2.0]
    - sortedcontainers [required: !=2.0.1,!=2.0.0, installed: 2.2.2]
    - tblib [required: >=1.6.0, installed: 1.7.0]
    - toolz [required: >=0.8.2, installed: 0.11.1]
    - tornado [required: >=6.0.3, installed: 6.0.4]
    - zict [required: >=0.1.3, installed: 2.0.0]
      - heapdict [required: Any, installed: 1.0.1]
  - feather-format [required: >=0.4.1, installed: 0.4.1]
    - pyarrow [required: >=0.4.0, installed: 2.0.0]
      - numpy [required: >=1.14, installed: 1.19.2]
  - flask [required: >=1.1.2, installed: 1.1.2]
    - click [required: >=5.1, installed: 7.1.2]
    - itsdangerous [required: >=0.24, installed: 1.1.0]
    - Jinja2 [required: >=2.10.1, installed: 2.11.2]
      - MarkupSafe [required: >=0.23, installed: 1.1.1]
    - Werkzeug [required: >=0.15, installed: 1.0.1]
  - flask-bootstrap [required: >=3.3.7.1, installed: 3.3.7.1]
    - dominate [required: Any, installed: 2.6.0]
    - Flask [required: >=0.8, installed: 1.1.2]
      - click [required: >=5.1, installed: 7.1.2]
      - itsdangerous [required: >=0.24, installed: 1.1.0]
      - Jinja2 [required: >=2.10.1, installed: 2.11.2]
        - MarkupSafe [required: >=0.23, installed: 1.1.1]
      - Werkzeug [required: >=0.15, installed: 1.0.1]
    - visitor [required: Any, installed: 0.1.3]
  - gitpython [required: >=3.1.7, installed: 3.1.11]
    - gitdb [required: >=4.0.1,<5, installed: 4.0.5]
      - smmap [required: >=3.0.1,<4, installed: 3.0.4]
  - ipython [required: >=7.16.1, installed: 7.18.1]
    - backcall [required: Any, installed: 0.2.0]
    - colorama [required: Any, installed: 0.3.9]
    - decorator [required: Any, installed: 4.4.2]
    - jedi [required: >=0.10, installed: 0.17.2]
      - parso [required: >=0.7.0,<0.8.0, installed: 0.7.1]
    - pickleshare [required: Any, installed: 0.7.5]
    - prompt-toolkit [required: >=2.0.0,<3.1.0,!=3.0.1,!=3.0.0, installed: 3.0.8]
      - wcwidth [required: Any, installed: 0.2.5]
    - pygments [required: Any, installed: 2.7.1]
    - setuptools [required: >=18.5, installed: 41.2.0]
    - traitlets [required: >=4.2, installed: 5.0.5]
      - ipython-genutils [required: Any, installed: 0.2.0]
  - jabbar [required: >=0.0.10, installed: 0.0.13]
  - matplotlib [required: >=3.3.0, installed: 3.3.2]
    - certifi [required: >=2020.06.20, installed: 2020.6.20]
    - cycler [required: >=0.10, installed: 0.10.0]
      - six [required: Any, installed: 1.15.0]
    - kiwisolver [required: >=1.0.1, installed: 1.2.0]
    - numpy [required: >=1.15, installed: 1.19.2]
    - pillow [required: >=6.2.0, installed: 7.2.0]
    - pyparsing [required: >=2.0.3,!=2.1.6,!=2.1.2,!=2.0.4, installed: 2.4.7]
    - python-dateutil [required: >=2.1, installed: 2.8.1]
      - six [required: >=1.5, installed: 1.15.0]
  - numpy [required: >=1.19.1, installed: 1.19.2]
  - pandas [required: >=1.0.5, installed: 1.1.3]
    - numpy [required: >=1.15.4, installed: 1.19.2]
    - python-dateutil [required: >=2.7.3, installed: 2.8.1]
      - six [required: >=1.5, installed: 1.15.0]
    - pytz [required: >=2017.2, installed: 2020.1]
  - pyarrow [required: >=1.0.0, installed: 2.0.0]
    - numpy [required: >=1.14, installed: 1.19.2]
  - pygments [required: >=2.6.1, installed: 2.7.1]
  - redis [required: >=2.10.6, installed: 3.5.3]
  - scikit-learn [required: >=0.23.1, installed: 0.23.2]
    - joblib [required: >=0.11, installed: 0.17.0]
    - numpy [required: >=1.13.3, installed: 1.19.2]
    - scipy [required: >=0.19.1, installed: 1.5.2]
      - numpy [required: >=1.14.5, installed: 1.19.2]
    - threadpoolctl [required: >=2.0.0, installed: 2.1.0]
  - scipy [required: >=1.5.2, installed: 1.5.2]
    - numpy [required: >=1.14.5, installed: 1.19.2]
  - sqlalchemy [required: >=1.3.18, installed: 1.3.20]

So incorporating this library will defy the idea of a library. Looking for alternatives in the pyABC documentation.

One possible solution is to use simbio in a new application around pyABC instead

sadeus commented 3 years ago

I created this repo to create a CLI application for ABC, for now pyABC, but there are alternatives:

Other solutions (excluding pyABC) seems to be almost abandoned or without any relevant activity.

As a actionable item around the libraries, I will create for a branch (in the abc_simbio repo) for test each.