Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added model test and fixed broken links #47

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ additional tailor-made models can be implemented by users.
* **biologist-friendly**.

It is one of the routine tools that we use at the
`MetaSys team <http://www.toulouse-biotechnology-institute.fr/en/research/molecular-physiology-and-metabolism/metasys.html>`_
and `MetaToul platform <http://www.metatoul.fr>`_ to calculate fluxes.
`MetaSys team <https://www.toulouse-biotechnology-institute.fr/en/poles/equipe-metasys/>`_
and `MetaToul platform <https://mth-metatoul.com/>`_ to calculate fluxes.

The code is open-source, and available on `GitHub <https://github.com/MetaSys-LISBP/PhysioFit/>`_ under a
:ref:`GPLv3 license <license>`.
Expand Down
6 changes: 0 additions & 6 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ To install PhysioFit using Python's built-in installer, you can just run the fol

pip install physiofit

Use :samp:`conda` to install from conda:

.. code-block:: bash

conda install physiofit -c bioconda

.. tip:: We recommend the creation of isolated environments for each python tool you install in your system using the python built-in `venv <https://docs.python.org/3/library/venv.html>`_ package or `Anaconda <https://www.anaconda.com/products/individual>`_.

If this method does not work, you should ask your local system administrator or
Expand Down
44 changes: 40 additions & 4 deletions docs/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ testing purposes. Here is an example of how you can test the model: ::
test_data = pd.DataFrame(
{
"time": [0, 1, 2, 3],
"experiment": ["A", "A", "A", "A"],
"experiments": ["A", "A", "A", "A"],
"X": [0.5, 0.8, 1.2, 1.8],
"Glucose": [12, 11.6, 11, 10.2]
}
Expand Down Expand Up @@ -411,7 +411,7 @@ use the :samp:`empty_like` function from the numpy library: ::
return simulated_matrix

The math corresponding to the simulation function provided above as example can be found :ref:`here <default_steady-state_models>` (equations
5 and 6).
5 and 6). See :ref:`here <testing_the_model>` for information on how to test the completed model.

This example showcases the use of analytical functions to simulate the flux dynamics. It is also possible to use
numerical derivation to solve a system of ordinary differential equations (ODEs), which can be usefull when algebric derivation is not straightforward. This require the implementation of additional functions into the simulate
Expand Down Expand Up @@ -476,12 +476,48 @@ behind this implementation can be found :ref:`here <default_dynamic_models>`.

.. note:: The simulation function will be called a high number of times by the optimizer for parameter estimation, so optimize this function as much as possible. When possible, implement the model using analytical solution as calculations will be faster than solving numerically the corresponding ODEs.

.. _testing_the_model:

Test the model
--------------

One a model has been implemented, it is time to test it! To integrate your model into the GUI, just copy the :file:`.py` file
in the folder :file:`models` of PhysioFit directory. You can get the path towards this folder by opening a python kernel in your dedicated environment and initializing an IoHandler ::
Once you have completely populated your model file, you can now launch a round of simulations and optimizations in a
programmatic way: ::

if __name__ == "__main__":
from physiofit.base.io import IoHandler
from physiofit.models.base_model import StandardDevs

test_data = pd.DataFrame(
{
"time": [0, 1, 2, 3],
"experiments": ["A", "A", "A", "A"],
"X": [0.5, 0.8, 1.2, 1.8],
"Glucose": [12, 11.6, 11, 10.2]
}
)

io = IoHandler()
model = ChildModel(data=test_data)
model.get_params()
fitter = io.initialize_fitter(
model.data,
model=model,
mc=True,
iterations=100,
sd=StandardDevs({"X": 1, "Glucose": 1}),
debug_mode=True
)
fitter.optimize()
fitter.monte_carlo_analysis()
fitter.khi2_test()
print(fitter.parameter_stats)

This will return the calculated flux values and associated statistics.

To test the integration of the model into the GUI, copy the :file:`.py` file
in the folder :file:`models` of PhysioFit directory. You can get the path towards this folder by opening a python
kernel in your dedicated environment and initializing an IoHandler ::

from physiofit.base.io import IoHandler
io_handler = IoHandler()
Expand Down
2 changes: 1 addition & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ scripts:

import physiofit

.. seealso:: Have a look at our :ref:`library showcase <Library documentation>` if you are interested in this feature.
.. seealso:: Have a look at our :ref:`API <Library documentation>` if you are interested in this feature.