.. _typical_workflows:

Typical Workflows
##################

Developing a |pkpd| model for a real life Data Set
=================================================== 

A typical task for a |pkpd| modeller is deducing a model given a data set collected from patients. It is usually best to take pre-existing knowledge about the |pk| and |pd| of the drug and use this as a starting point to create an initial model. You can then explore more complex models by adding new parameters and comparing the fitted |fx| and objective value obtained with the new model, to prior models. In |popy| you can achieve this by developing a series of :ref:`fit scripts<fit_script>`, running each script and examining the outputs.

To help with this process the potential child scripts of an individual :ref:`fit_script` are summarised in :numref:`fig_fit_script_hierarchy`.

.. _fig_fit_script_hierarchy:

.. figure:: /popy_guide/hierarchy_diagrams/fit_script_hierarchy.*
    :width: 50%
    :align: center
    
    Hierarchy of child scripts for a parent :ref:`fit_script`.
    
The child scripts are automatically generated by |popy| in order to facilitate other tasks you may wish to perform. Each child script is optionally generated by an entry in the |output_scripts| section of the :ref:`fit_script`.
    
For example a :ref:`sim_script` will plot a dense |pk| or |pd| curve for each individual and you can see where your current model may not be matching the data set and where the model is extrapolating.

An :ref:`msim_script` allows you to easily generate a |vpc| plot, which allow you to see how your current model compares to the data set for the whole population. As a |vpc| tests the distributional assumptions of the model as well as the fit to each individual, it is a rigorous test for a population model.

Investigate a |pkpd| model using synthetic data
=================================================== 

If you do |not| have a real life data set or just wish to carry out a more theoretical investigation you can use |popy|'s tools to generate artificial data. This approach has the benefit of allowing you to create data sets with known properties and test hypotheses about the identifiability of parameters. The primary tool to do this in |popy| is the :ref:`tut_script`, see :ref:`simple_tut_example` for a run through of using a tut script. The potential child scripts of a :ref:`tut_script` are shown in :numref:`fig_tut_script_hierarchy`.

.. _fig_tut_script_hierarchy:

.. figure:: /popy_guide/hierarchy_diagrams/tut_script_hierarchy.*
    :width: 50%
    :align: center
    
    Hierarchy of child scripts for a parent :ref:`tut_script`.

Another tool for investigating models using artificial data in |popy| is the :ref:`mtut_script`. See :ref:`simple_mtut_example` for a run through of using a MTut script. The potential child scripts of a :ref:`mtut_script` are shown in :numref:`fig_mtut_script_hierarchy`.

.. _fig_mtut_script_hierarchy:

.. figure:: /popy_guide/hierarchy_diagrams/mtut_script_hierarchy.*
    :width: 50%
    :align: center
    
    Hierarchy of child scripts for a parent :ref:`mtut_script`.

.. only:: browser

    .. _next_steps_workflow:

    Next Steps
    ============

    You can familiarise yourself with more |popy| examples our overview of PK/PD concepts:-

    * :ref:`indiv_pkpd_index`
    * :ref:`pop_pkpd_index`

    Or examine our :ref:`examples_index`.
