API reference

This module serves as reference for the different classes and associated methods of the PhysioFit package.

fitter.py

PhysioFit software main module

class physiofit.base.fitter.PhysioFitter(data, model, mc=True, iterations=100, sd=None, debug_mode=False)

Bases: object

This class is responsible for most of Physiofit’s heavy lifting. Features included are:

  • loading of data from csv or tsv file

  • equation system initialization using the following analytical functions (in absence of lag and degradation:

    X(t) = X0 * exp(mu * t) Mi(t) = qMi * (X0 / mu) * (exp(mu * t) - 1) + Mi0

  • simulation of data points from given initial parameters

  • cost calculation using the equation:

    residuum = sum((sim - meas) / sd)²

  • optimization of the initial parameters using scipy.optimize.minimize (‘Differential evolution’, with polish with ‘L-BFGS-B’ method)

  • sensitivity analysis, khi2 tests and plotting

Parameters:
  • data (class: pandas.DataFrame) – DataFrame containing data and passed by IOstream object

  • model (physiofit.models.base_model.Model) – Model to initialize parameters and optimize

  • mc (Boolean) – Should Monte-Carlo sensitivity analysis be performed (default=True)

  • iterations (int) – number of iterations for Monte-Carlo simulation (default=50)

  • sd (int, float, list, dict or ndarray) –

    sd matrix used for residuum calculations. Can be:

    • a matrix with the same dimensions as the measurements matrix (but without the time column)

    • a named vector containing sds for all the metabolites provided in the input file

    • 0 in which case the matrix is automatically constructed from default values

    • a dictionary with the data column headers as keys and the associated value as a scalar or list

initialize_sd_matrix()

Initialize the sd matrix from different types of inputs: single value, vector or matrix.

Returns:

None

khi2_test()
monte_carlo_analysis()

Run a monte carlo analysis to calculate optimization standard deviations on parameters and simulated data points

optimize()

Run optimization and build the simulated matrix from the optimized parameters

verify_attrs()

Check that attributes are valid

io.py

Module to handle inputs and outputs for PhysioFit

class physiofit.base.io.ConfigParser(selected_model, sds, mc, iterations, path_to_data=None)

Bases: object

allowed_keys = ['model', 'sds', 'mc', 'iterations']
export_config(export_path)
classmethod from_file(yaml_file)
classmethod from_galaxy(galaxy_yaml)
get_kwargs()
update_model(model)
class physiofit.base.io.IoHandler

Bases: object

Input/Output class that handles the former and initializes the PhysioFitter component object. It is the preferred interface for interacting with the PhysioFit package.

static add_model(model_file)
allowed_keys = {'debug_mode', 'iterations', 'mc', 'model', 'sd'}
get_local_model_folder() str

Return the path towards the actual environment’s used models folder

static get_model_list()
get_models(data=None)

Read modules containing the different models and add them to models attribute

Returns:

list containing the different model objects

initialize_fitter(data: pd.DataFrame, **kwargs) PhysioFitter

Initialize a PhysioFitter object

Parameters:
  • data – input data

  • kwargs – Keyword arguments for fitter initialization

Returns:

None

output_pdf(fitter: PhysioFitter, export_path: str | Path = None)

Handle the creation and output of a pdf file containing fit results as a plot

Parameters:

export_path – Path to exported pdf. In local mode, it is sent to the _res directory

Returns:

None

output_plots(fitter, export_path)

Handle the creation and export of the different plots in svg format :return: None

output_recap(export_path: str, galaxy=False)
output_report(fitter, export_path: str | list = None)

Handle creation and export of the report containing stats from monte carlo analysis of optimization parameters

Parameters:

export_paths – list of paths to export the stats and fluxes. [0] is for stats and [1] for fluxes.

plot_data(fitter, display: bool = False)

Plot the data

Parameters:

display – should plots be displayed

static read_data(data: str) DataFrame

Read initial data file (csv or tsv)

Parameters:

data – str containing the relative or absolute path to the data

Returns:

pandas DataFrame containing the data

read_model(model_file)

Import and return the model class from .py file containing the model.

Parameters:

model_file – path to the model.py file to import

static read_yaml(yaml_file: str | bytes) ConfigParser

Import raml configuration file and parse keyword arguments

Parameters:

yaml_file – path to the yaml file or json file

Return config_parser:

Dictionary containing arguments parsed from yaml file

select_model(model_name, data=None)

Select a model from the list of models in the model folder of the package src directory

gui.py

class physiofit.ui.gui.App

Bases: object

Physiofit Graphical User Interface

check_uptodate()

Compare installed and most recent Physiofit versions.

silent_sim()
start_app()

Launch the application

base_model.py

class physiofit.models.base_model.Bounds(mapping=None, **kwargs)

Bases: dict

class physiofit.models.base_model.Model(data: DataFrame)

Bases: ABC

abstract get_params()
Return params_to_estimate:

List of parameters to estimate

Return fixed_parameters:

dict of constant parameters

Return bounds:

dict of upper and lower bounds

Return default_init_values:

dict containing default initial values for params

abstract static simulate(params_opti: list, data_matrix: ndarray, time_vector: ndarray, params_non_opti: dict | list)
exception physiofit.models.base_model.ModelError

Bases: Exception

class physiofit.models.base_model.StandardDevs(mapping=None, **kwargs)

Bases: dict

property vector