From 01c6a47395c51c22d1547bd9c88b5fd3f0b2f710 Mon Sep 17 00:00:00 2001 From: llegregam Date: Tue, 24 Oct 2023 15:34:25 +0200 Subject: [PATCH] Added model test and fixed broken links --- docs/index.rst | 4 ++-- docs/installation.rst | 6 ------ docs/models.rst | 44 +++++++++++++++++++++++++++++++++++++++---- docs/quickstart.rst | 2 +- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index aeaf184..8047163 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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 `_ -and `MetaToul platform `_ to calculate fluxes. +`MetaSys team `_ +and `MetaToul platform `_ to calculate fluxes. The code is open-source, and available on `GitHub `_ under a :ref:`GPLv3 license `. diff --git a/docs/installation.rst b/docs/installation.rst index 11b24a8..3389e40 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -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 `_ package or `Anaconda `_. If this method does not work, you should ask your local system administrator or diff --git a/docs/models.rst b/docs/models.rst index ee48031..85e9723 100644 --- a/docs/models.rst +++ b/docs/models.rst @@ -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] } @@ -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 ` (equations -5 and 6). +5 and 6). See :ref:`here ` 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 @@ -476,12 +476,48 @@ behind this implementation can be found :ref:`here `. .. 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() diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 536a8bd..9fe2b4b 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -57,4 +57,4 @@ scripts: import physiofit -.. seealso:: Have a look at our :ref:`library showcase ` if you are interested in this feature. \ No newline at end of file +.. seealso:: Have a look at our :ref:`API ` if you are interested in this feature. \ No newline at end of file