mass.thermo.conc_sampling.conc_sampling

Module implementing concentration sampling for mass models.

Based on sampling implementations in cobra.sampling.sampling

Module Contents

Functions

sample_concentrations(concentration_solver, n[, ...])

Sample valid concentration distributions from a mass model.

mass.thermo.conc_sampling.conc_sampling.sample_concentrations(concentration_solver, n, method='optgp', thinning=100, processes=1, seed=None)[source]

Sample valid concentration distributions from a mass model.

This function samples valid concentration distributions from a mass model using a ConcSolver.

Currently supports two methods.

  1. 'optgp' which uses the ConcOptGPSampler that supports parallel sampling [MHM14]. Requires large numbers of samples to be performant (n > 1000). For smaller samples, 'achr' might be better suited.

  2. 'achr' which uses artificial centering hit-and-run via the ConcACHRSampler. This is a single process method with good convergence [KS98].

Parameters
  • concentration_solver (ConcSolver) – The ConcSolver to use in generating samples.

  • n (int) – The number of samples to obtain. When using 'method=optgp', this must be a multiple of processes, otherwise a larger number of samples will be returned.

  • method (str) – The sampling algorithm to use. Default is 'optgp'.

  • thinning (int) –

    The thinning factor for the generated sampling chain as a positive int > 0. A thinning factor of 10 means samples are returned every 10 steps. If set to one, all iterates are returned.

    Default is 100.

  • processes (int or None) –

    The number of processes used to generate samples. If None the number of processes specified in the MassConfiguration is utilized. Only valid for method='optgp'.

    Default is 1.

  • seed (int or None) –

    A positive int > 0 indiciating random number seed that should be used. If None provided, the current time stamp is used.

    Default is None.

Returns

The generated concentration samples. Each row corresponds to a sample of the concentrations and the columns are the metabolites.

Return type

pandas.DataFrame

See also

ConcSolver.setup_sampling_problem()

For setup of the sampling problem in the given ConcSolver.