Import simulation data

This module implements functions to import and process simulation data.

aggregate_time_series(data_df: DataFrame, quant_type: str, name_list: list) DataFrame

Takes in a dataframe with either fluxes or concentrations and calculates the median and respective first and third quartiles for each flux or metabolite at a given time point over the whole model ensemble.

Parameters
  • data_df – dataframe with concentrations or fluxes for each time point and model.

  • quant_type – whether the data frame contains relative concentrations (‘conc_rel’), absolute concentrations (‘conc_abs’), relative fluxes (‘flux_rel’), or absolute_fluxes (‘flux_abs’).

  • name_list – reaction or metabolite names, depending on what that the dataframe contains.

Returns

A pandas dataframe with the concentrations/fluxes median and 1st and 3rd quartiles for each metabolite/reaction.

gather_conc_data(mat: dict, met_names: list, n_models: int, quant_type: str, ref_conc_dic: Optional[dict] = None) DataFrame

Imports the concentration data over time from the matlab simulation results.

The concentrations are relative to the reference state.

If a dictionary with reference concentrations is supplied the resulting dataframe will both relative and absolute metabolite concentrations. The columns are named conc_rel and conc_abs, respectively.

Pre-allocated numpy arrays are used for memory performance (vs. previous list extend).

Parameters
  • mat – matlab structures with simulation results.

  • met_names – names of the simulated metabolites in the model.

  • n_models – number of models to be simulated.

  • quant_type – whether to get relative or absolute concentrations. Possible values: conc_abs, conc_rel.

  • ref_conc_dic – a dictionary with the metabolites reference concentrations in each model.

Returns

A pandas dataframe with all concentration values at each time point.

gather_flux_data(mat: dict, rxn_names: list, n_models: int, quant_type: str, ref_flux_dic: Optional[dict] = None) DataFrame

Imports the flux data over time from the matlab simulation results.

The fluxes coming from matlab are absolute.

If a dictionary with reference fluxes is supplied the resulting dataframe will both relative and absolute reaction fluxes. The columns are named flux_rel and flux_abs, respectively.

Pre-allocated numpy arrays are used for memory performance (vs. previous list extend).

Parameters
  • mat – matlab structures with simulation results.

  • rxn_names – names of the simulated reactions in the model.

  • n_models – number of models to be simulated.

  • quant_type – whether to get relative or absolute fluxes. Possible values: flux_abs, flux_rel.

  • ref_flux_dic – a dictionary with the reactions reference fluxes.

Returns

A pandas dataframe with all concentration and flux values at each time point.

get_met_rxn_names(raw_data_dir: str, model_name: str) tuple

Gets the names of metabolites and reactions in the model.

Parameters
  • raw_data_dir – path to folder with the raw data.

  • model_name – named of the model.

Returns

A list with the metabolite names and another with the reaction names.

get_time_series_quartiles(mat, names_list: list, n_models: int, ref_dic: dict, quant_type: str) DataFrame
Given a .mat file from matlab with the simulation results, and the type of quantity the user wants to extract:
  • “flux_rel” - relative fluxes

  • “flux_abs” - absolute fluxes

  • “conc_rel” - relative concentrations

  • “conc_abs” - absolute concentrations

it extracts the data and calculates the median, the first and third quartile for each model, metabolite/reaction, and time point.

Parameters
  • mat – .mat file with simulations from matlab.

  • names_list – list of reaction or metabolite names.

  • n_models – number of models for which to extract the simulations.

  • ref_dic – dictionary with either reference concentrations or fluxes.

  • quant_type – which quantity to extract: “flux_rel”, “flux_abs”, “conc_rel”, “conc_abs”.

Returns

A dataframe with flux/concentrations median+first+third quartiles for each each model, metabolite/reaction, and time point.

import_ref_conc(mat: dict, n_models: int) dict

Converts a .mat file from matlab into a dictionary with reference concentrations for each model. Metabolites are the keys, lists of concentrations are the values, where each entry is the concentration for a model.

Parameters
  • mat – ensemble .mat file from matlab in form of dictionary.

  • n_models – number of models to consider.

Returns

A dictionary with the reference metabolite concentrations for each model.

import_ref_flux(mat: dict) dict

Get the reference fluxes into a dictionary from a .mat file from matlab. Reaction names are the keys and fluxes are the values.

Parameters

mat – ensemble .mat file from matlab in form of dictionary.

Returns

A dictionary with the reference reaction fluxes.

load_simulation(raw_data_dir: str, model_name: str, simulation_name: str, n_models: int) tuple

Takes in the path to the folder with the model ensemble and simulation data, loads it and returns the simulation Matlab file, the reference concentration and flux dictionaries, as well as the metabolite and reaction names.

Parameters
  • raw_data_dir – path to folder with simulation and model data.

  • model_name – name of the model

  • simulation_name – name of the simulation

  • n_models – number of models in the simulation to plot

Returns

The matlab simulation file, reference concentration and fluxes dictionary, and lists of metabolite and reaction names.