# CHRR¶

chrrExpSampler(model, numSkip, numSamples, lambda, toRound, roundedPolytope, useFastFVA)[source]

Generate random flux samples from an exponential distribution with CHRR Coordinate Hit-and-Run with Rounding. chrrExpSampler will generate numSamples samples from model, taking numSkip steps of a random walk between each sample. Rounding the polytope is a potentially expensive step. If you generate multiple rounds of samples from a single model, you can save roundedPolytope from the first round and input it for subsequent rounds. It is allowed to change lambda without recomputing roundedPolytope.

Usage

[samples, roundedPolytope, minFlux, maxFlux] = chrrExpSampler(model, numSkip, numSamples, lambda, toRound, roundedPolytope, useFastFVA)

Inputs

• model – COBRA model structure with fields:
• .S - The m x n stoichiometric matrix
• .lb - n x 1 lower bounds on fluxes
• .ub - n x 1 upper bounds on fluxes
• .c - n x 1 linear objective
• numSkip – Number of steps of coordinate hit-and-run between samples
• numSamples – Number of samples

Optional inputs

• lambda – the bias vector, i.e. generate samples from exp(-<lambda, x>) restricted to the feasible region. OPTIONAL ONLY IF model.c is nonzero, in which case we set lambda=model.c.
• toRound{0, 1} Option to round the polytope before sampling.
• roundedPolytope – The rounded polytope from a previous round of sampling the same model.
• useFastFVA – Boolean to use fastFVA (default: false)

Outputs

• samplesn x numSamples matrix of random flux samples
• roundedPolytope – The rounded polytope. Save for use in subsequent rounds of sampling.
• minFlux, maxFlux – flux minima and maxima
chrrParseModel(model)[source]

Parse a COBRA model into the right format for the CHRR sampler

Usage

[P,model] = chrrParseModel(model);

We are trying to sample uniformly at random from the points v that satisfy:

$\begin{split}Sv = b\\ ~~ l_b \leq v \leq u_b\end{split}$

Input

• model – COBRA model structure with fields:
• .S - The m x n stoichiometric matrix
• .lb - n x 1 lower bounds on fluxes
• .ub - n x 1 upper bounds on fluxes

Optional inputs

• * .C - ‘k x n’ matrix of additional inequality constraints
• * .d - ‘k x 1’ rhs of the above constraints
• * .dsense - ‘k x 1’ the sense of the above constraints (‘L’ or ‘G’)

Output

• P – A structure with fields:
• .A_eq - Equality constraint matrix (model.S)
• .b_eq - Right hand side of equality constraints (model.b)
• .A - Inequality constraint matrix ([I_n 0; 0 -I_n])
• .b - Right hand side of inequality constraints ([lb; -ub])
chrrSampler(model, numSkip, numSamples, toRound, roundedPolytope, useFastFVA, optPercentage)[source]

Generate uniform random flux samples with CHRR Coordinate Hit-and-Run with Rounding. chrrSampler will generate numSamples samples from model, taking numSkip steps of a random walk between each sample. Rounding the polytope is a potentially expensive step. If you generate multiple rounds of samples from a single model, you can save roundedPolytope from the first round and input it for subsequent rounds.

Usage

[samples, roundedPolytope] = chrrSampler(model, numSkip, numSamples, toRound, roundedPolytope, useFastFVA)

Inputs

• model – COBRA model structure with fields:
• .S - The m x n stoichiometric matrix
• .lb - n x 1 lower bounds on fluxes
• .ub - n x 1 upper bounds on fluxes
• .c - n x 1 linear objective
• numSkip – Number of steps of coordinate hit-and-run between samples
• numSamples – Number of samples

Optional inputs

• toRound{0,(1)} Option to round the polytope before sampling.
• roundedPolytope – The rounded polytope from a previous round of sampling the same model.
• useFastFVA – Boolean to use fastFVA (default: false)
• optPercentage – Only consider solutions that give you at least a certain percentage of the optimal solution (Default = 100) Can decrease optPercentage slightly if getting errors.

Outputs

• samplesn x numSamples matrix of random flux samples
• roundedPolytope – The rounded polytope. Save for use in subsequent rounds of sampling.
• minFlux, maxFlux – flux minima and maxima