Analysis#
MATLAB functions in RAVEN/src/analysis of the RAVEN toolbox.
Functions#
Function |
Summary |
|---|---|
Compare flux change significance with expression change. |
|
Find the reactions whose flux differs between two flux vectors. |
|
Delete genes and track the resulting fluxes. |
|
Flux Scanning based on Enforced Objective Flux. |
|
Return the minimal and maximal fluxes through reactions. |
|
Get all metabolic subgraphs in a model. |
|
Calculate the essential reactions for a solvable model. |
|
Calculate Z scores between two sets of random flux distributions. |
|
Find the minimal set of uptake reactions for growth. |
|
Check which reactions can carry a flux. |
|
Sample the flux solution space (entry point for all samplers). |
|
Identify metabolites around which transcriptional changes occur. |
|
Perform dynamic FBA using the static optimisation approach. |
|
Run phenotype phase plane analysis and plot the results. |
|
Calculate the byproduct secretion envelope. |
|
Perform robustness analysis for a reaction and objective. |
|
Find deletions that couple metabolite production to growth. |
|
Artificially Centered Hit-and-Run flux sampling. |
|
Centre of the largest ball inscribed in a polytope. |
|
Coordinate Hit-and-Run with Rounding flux sampling. |
|
Maximum-volume inscribed ellipsoid of a polytope. |
|
FVA warmup vertices for ACHR sampling. |
|
Find the highest-flux-fraction path between two reactions. |
|
Interactively navigate a flux distribution reaction by reaction. |
Reference#
analyzeSampling#
function scores=analyzeSampling(Tex, df, solutionsA, solutionsB, varargin)
Compare flux change significance with expression change.
Compares the significance of change in flux between two conditions with the significance of change in gene expression.
Parameters
Tex: doublea vector of t-scores for the change in gene expression for each reaction. The score is the Student t between the two conditions, or is calculated from a p-value by the inverse of the error function. Transcripts that increased in expression level have positive values and transcripts that decreased have negative values. A p-value does not give the direction of the change, so a score calculated from a p-value takes its sign from the direction of the expression change.
df: doublethe degrees of freedom in the t-test.
solutionsA: doublerandom solutions for the reference condition (as generated by randomSampling).
solutionsB: doublerandom solutions for the test condition (as generated by randomSampling).
Name-Value Arguments
printResults: logicaltrue to print the 10 reactions with the highest probability in each category (default false).
Returns
scores: doublea Nx3 column matrix with the probabilities of a reaction:
changing both in flux and expression in the same direction
changing in expression but not in flux
changing in flux but not in expression or changing in opposed directions in flux and expression
Examples
scores = analyzeSampling(Tex, df, solutionsA, solutionsB, ...
printResults);
compareFluxes#
function result = compareFluxes(model, fluxes1, fluxes2, varargin)
Find the reactions whose flux differs between two flux vectors.
Compares two flux vectors from the same model and returns all reactions that changed, sorted by absolute flux difference. Classifies reactions as turned on, turned off, reversed direction, or changed magnitude.
Parameters
model: structa model structure.
fluxes1: doublereference flux vector (condition A, such as wild-type).
fluxes2: doublecomparison flux vector (condition B, such as a mutant or knock-in).
Name-Value Arguments
cutoff: doubleminimum |flux| for a reaction to be active, and minimum |flux2 - flux1| for a reaction to be changed (default 1e-8).
metaboliteList: cellcell array of metabolite names. Only reactions involving at least one of these metabolites are compared; all other reactions are excluded from every field of the result. Matching is against model.metNames and is case insensitive. A name that matches no metabolite is reported as a warning (default all reactions).
nMax: doublemaximum rows printed in the summary table (default 20).
verbose: logicalprint the summary table (default true).
Returns
result: structstructure with fields:
turnedOn : cell array with the IDs of reactions that are active in fluxes2 and not in fluxes1.
turnedOff : cell array with the IDs of reactions that are active in fluxes1 and not in fluxes2.
flipped : cell array with the IDs of reactions that are active in both conditions and change sign.
changed : struct with fields for all reactions with |flux2 - flux1| above cutoff, sorted by |flux2 - flux1| descending:
rxn : cell array with the reaction IDs.
flux1 : double array with the flux in condition A.
flux2 : double array with the flux in condition B.
absDelta : double array with |flux2 - flux1|.
relChange : double array with (flux2 - flux1)/|flux1|. NaN when |flux1| is below cutoff.
type : cell array with 'on', 'off', 'flip' or '' (changed magnitude) for each reaction.
Examples
solA = solveLP(model);
modelAna = setParam(model, 'ub', 'O2exchange', 0);
solB = solveLP(modelAna);
result = compareFluxes(model, solA.x, solB.x)
result = compareFluxes(model, solA.x, solB.x, 'nMax', 50)
result = compareFluxes(model, solA.x, solB.x, 'metaboliteList', {'ATP','NADH'})
See also
walkFluxes, traceFluxPath, modelSummary
findGeneDeletions#
function [genes, fluxes, originalGenes, details, grRatioMuts]=findGeneDeletions(model,varargin)
Delete genes and track the resulting fluxes.
Deletes single genes or gene pairs, solves the model by FBA after each deletion, and returns the resulting fluxes. The output identifies gene deletion targets.
Parameters
model: structa model structure.
Name-Value Arguments
testType: chartype of gene deletion (default "sgd"):
"sgd" : single gene deletion
"dgd" : double gene deletion
Returns
genes: doublea matrix with the genes that were deleted in each simulation (the gene indexes in originalGenes). Each row corresponds to a column in fluxes.
fluxes: doublea matrix with the resulting fluxes. Double deletions that result in an unsolvable problem have all zero flux. Single deletions that result in an unsolvable problem are indicated in details instead.
originalGenes: cellthe genes in the input model.
details: doublea vector with one element per gene in originalGenes that states whether the gene was deleted and why. Genes that only belong to dead-end reactions, for example, are not deleted:
1 : deleted, and the problem was solved (a lethal deletion with zero growth also gets 1)
2 : the single-deletion problem had no optimal solution (infeasible or failed); fluxes and grRatioMuts are 0
3 : redundant (not assigned)
4 : involved in dead-end reaction
grRatioMuts: doublegrowth rate ratio between mutated strain and wild type, matching the originalGenes(genes) mutants. The elements do not map directly to model.genes, unlike the output of COBRA getEssentialGenes. The mapping to model.genes is obtained with:
grRatio=zeros(1,numel(model.genes)); grRatio(genes)=grRatioMuts;
Examples
[genes, fluxes, originalGenes, details, grRatioMuts]=...
findGeneDeletions(model,testType);
FSEOF#
function targets=FSEOF(model,biomassRxn,targetRxn,varargin)
Flux Scanning based on Enforced Objective Flux.
Implements the Flux Scanning based on Enforced Objective Flux algorithm. This function writes a tab-delimited file or prints to the command window. If an output is specified (targets), it also returns a structure indicating for each model reaction whether FSEOF identifies it as a target and the slope of the reaction when switching from biomass formation to product formation.
Parameters
model: structa model structure.
biomassRxn: charreaction ID of the biomass formation or growth reaction.
targetRxn: charreaction ID of the target reaction.
Name-Value Arguments
iterations: doublenumber of enforced target flux levels, equally spaced up to coefficient times the maximum target flux (default 10).
coefficient: doubleratio of the maximum target reaction flux that is enforced at the last iteration, less than 1 (default 0.9).
outputFile: charoutput filename (default prints to command window).
corrThreshold: doubleminimum absolute Pearson correlation coefficient between the absolute flux of a reaction and the enforced product flux for the reaction to be selected as a target. Values are in [0, 1]. The filter keeps reactions whose flux is close to linear in the enforced product flux, and a higher value keeps fewer reactions (default 0.9).
Returns
targets: structstructure with information for identified targets, with fields:
logical : logical array, true for amplification targets (identical to amplify).
amplify : logical array, reactions whose absolute flux increases with enforced product flux.
knockdown : logical array, reactions whose absolute flux decreases but stays above zero at the highest enforced product flux.
knockout : logical array, reactions whose absolute flux decreases to zero at the highest enforced product flux.
slope : numeric array with per-reaction regression slopes of absolute flux versus enforced product flux (for all reactions).
Examples
targets = FSEOF(model, biomassRxn, targetRxn, iterations, ...
coefficient, outputFile);
getAllowedBounds#
function [minFluxes, maxFluxes, exitFlags]=getAllowedBounds(model,varargin)
Return the minimal and maximal fluxes through reactions.
Parameters
model: structa model structure.
Name-Value Arguments
rxns: cell or logical or doubleeither a cell array of reaction IDs, a logical vector with the same number of elements as reactions in the model, or a vector of reaction indexes (default model.rxns).
runParallel: logicalrun the calculations in parallel (default true). Parallel processing requires the MATLAB Parallel Computing Toolbox; without it, the calculations run serially regardless of this setting. For a few reactions, the overhead of parallel processing exceeds the time it saves.
Returns
minFluxes: doubleminimal allowed fluxes.
maxFluxes: doublemaximal allowed fluxes.
exitFlags: doublea matrix with one row per reaction. Column 1 holds the solver status of the minimisation and column 2 the status of the maximisation (1 if a flux could be calculated).
Notes
In cases where no solution can be calculated, NaN is returned.
Examples
[minFluxes, maxFluxes, exitFlags] = getAllowedBounds(model, rxns, runParallel);
getAllSubGraphs#
function subGraphs=getAllSubGraphs(model)
Get all metabolic subgraphs in a model.
Two metabolites are connected if they share a reaction.
Parameters
model: structa model structure.
Returns
subGraphs: logicala logical matrix with one row per metabolite and one column per subgraph. An element is true if the metabolite belongs to the subgraph. The columns are ordered by decreasing subgraph size.
Examples
subGraphs = getAllSubGraphs(model);
getEssentialRxns#
function [essentialRxns, essentialRxnsIndexes]=getEssentialRxns(model,varargin)
Calculate the essential reactions for a solvable model.
Parameters
model: structa model structure.
Name-Value Arguments
ignoreRxns: cellcell array of reaction IDs which should not be checked (default {}).
Returns
essentialRxns: cellcell array with the IDs of the essential reactions.
essentialRxnsIndexes: doublevector with the indexes of the essential reactions.
Notes
Essential reactions are those which, when constrained to 0, result in an infeasible problem.
Examples
[essentialRxns, essentialRxnsIndexes] = getEssentialRxns(model, ignoreRxns);
getFluxZ#
function Z=getFluxZ(solutionsA, solutionsB)
Calculate Z scores between two sets of random flux distributions.
Parameters
solutionsA: doublerandom solutions for the reference condition (as generated by randomSampling).
solutionsB: doublerandom solutions for the test condition (as generated by randomSampling).
Returns
Z: doublea vector with one Z-score per reaction: the difference between the mean fluxes of solutionsB and solutionsA, divided by the square root of the sum of their variances. A positive sign indicates an increase of the flux in the second condition with respect to the first, a negative sign a decrease. Values are limited to the range -100 to 100.
Examples
Z = getFluxZ(solutionsA, solutionsB);
See also
randomSampling
getMinimalMedium#
function [medium, mediumIdx] = getMinimalMedium(model, varargin)
Find the minimal set of uptake reactions for growth.
Uses MILP to find the smallest set of exchange reactions that can carry uptake flux (lb < 0) while the model achieves a target growth rate. The MILP formulation gives a medium with the globally minimal number of uptake reactions.
Parameters
model: structa model structure.
Name-Value Arguments
minGrowth: doubleminimum objective value (growth rate) the medium must support. If empty, 10 % of the optimum objective value under the current bounds, which requires one extra FBA call. A value given explicitly avoids that call (for example 'minGrowth', 0.1) (default empty).
verbose: logicalprint the resulting minimal medium (default true).
Returns
medium: cellcell array of reaction IDs that form the minimal medium. Empty if no feasible medium can support the requested growth.
mediumIdx: doublecolumn vector of reaction indices corresponding to medium.
Examples
[med, idx] = getMinimalMedium(model)
[med, idx] = getMinimalMedium(model, 'minGrowth', 0.05)
[med, idx] = getMinimalMedium(model, 'verbose', false)
Notes
Only exchange reactions with lb < 0 are candidate uptake reactions. Exchange reactions with lb >= 0 are not included.
The MILP formulation: minimise sum(y_i) s.t. S v = 0 c' v >= minGrowth v_i >= lb_i * y_i for each candidate uptake reaction i lb_j <= v_j <= ub_j for all reactions j y_i in {0, 1}
A y_i = 0 forces reaction i to carry non-negative flux (no net uptake); y_i = 1 allows it to carry flux as low as lb_i.
The number of uptake reactions is minimal, but the medium is not necessarily unique: when several media of the same size support the growth rate, the solver returns one of them, and another solver or solver version can return a different one.
The MILP is solved with the solver set by setRavenSolver. RAVEN's bundled GLPK solves it for small models. The RAVEN:glpkMILP warning issued with GLPK states that GLPK works for small problems and that Gurobi is much faster and more reliable for larger ones (setRavenSolver('gurobi')).
haveFlux#
function I=haveFlux(model,varargin)
Check which reactions can carry a flux.
Checks which reactions can carry a (positive or negative) flux under the model's current bounds; other media or bounds are not explored. Unlike getAllowedBounds, which minimises and maximises every reaction, it skips a reaction once an earlier solution has given it a flux, and minimises only reversible reactions that still have none.
Parameters
model: structa model structure.
Name-Value Arguments
cutOff: doublethe absolute flux value that a reaction has to exceed to be identified as carrying flux (default 10^-6).
rxns: cell or logical or doubleeither a cell array of IDs, a logical vector with the same number of elements as reactions in the model, or a vector of indexes (default model.rxns).
seed: doubleseed for the random number generator that shuffles the order in which reactions are tested. The order is then reproducible across runs (default: the current rng state is left untouched).
Returns
I: logicallogical array with true if the corresponding reaction can carry a flux under the tested bounds.
Examples
I = haveFlux(model, cutOff, rxns);
Notes
Bounds of +/- Inf are replaced with +/- 10000 before solving.
Dead-end reactions are removed (simplifyModel) before solving. A dead-end reaction with a forced flux (lb > 0 or ub < 0) makes the model infeasible, but it is removed like any other dead end, so the remaining reactions are tested as if it were absent. A forced flux elsewhere in an infeasible model gives false for all reactions.
randomSampling#
function [solutions, goodRxns, info]=randomSampling(model,varargin)
Sample the flux solution space (entry point for all samplers).
Dispatches to one of three sampling methods via the 'method' argument: 'achr' (default) Artificially Centered Hit-and-Run; near-uniform MCMC sampling of the polytope interior (see sampleACHR). 'chrr' Coordinate Hit-and-Run with Rounding; near-uniform MCMC with maximum-volume-ellipsoid rounding, which improves mixing on thin or ill-conditioned polytopes such as enzyme-constrained models (see sampleCHRR). 'randomObjective' the random-objective vertex method of Bordel et al. (2010) PLoS Comput Biol (doi:10.1371/journal.pcbi.1000859): each sample optimises a random objective of nObjectives reactions with random weights, returning a polytope vertex.
The 'achr' and 'chrr' methods draw from the (near-)uniform distribution over the interior; the 'randomObjective' method draws vertices. Arguments below marked [randomObjective] apply only to that method; 'thinning' and 'nBurnin' apply only to the MCMC methods.
Parameters
model: structa model structure.
Name-Value Arguments
nSamples: doublethe number of solutions to return (default 1000).
method: charsampling method: 'achr' (default), 'chrr', or 'randomObjective'.
thinning: doubleMCMC steps between recorded samples for 'achr' and 'chrr' (default 100).
nBurnin: doubleburn-in steps discarded before the first sample for 'chrr' (default 1000).
replaceBoundsWithInf: logical[randomObjective] replace the largest upper bounds with Inf and the smallest lower bounds with -Inf (the latter only if the smallest lower bound is negative). This is required to get solutions without loops if the model has arbitrarily large bounds, for example 1000 and -1000. A model with only biologically relevant bounds can use false (default true).
supressErrors: logicalif false, randomSampling raises an error after 99 consecutive failed attempts to find a non-zero solution that is not involved in loops. Failures can result from constraints that are too relaxed (such as unlimited glucose uptake) or too strict (such as many narrow constraints). If true, the attempts continue without an error (default false).
runParallel: logicalrun the calculations in parallel (default true). Requires the MATLAB Parallel Computing Toolbox; without it, the calculations run serially regardless of this setting.
goodRxns: doublevector of indexes of those reactions that are not involved in loops and can be used as random objective functions, as generated by a previous run of randomSampling on the same model (default empty).
minFlux: logicaldetermines if a second optimisation is performed for each random sample, which minimises the sum of absolute fluxes to prevent loops (default false).
nObjectives: doublenumber of reactions included in the random objective function per sample iteration (default 2).
seed: doublerandom seed for reproducibility. If empty, the current MATLAB random state is used (default empty).
Returns
solutions: doublematrix with the solutions.
goodRxns: double[randomObjective] vector of indexes of those reactions that are not involved in loops or always carry zero flux and can be used as random objective functions. Empty ([]) for the 'achr' and 'chrr' methods.
info: struct[chrr] the diagnostics from sampleCHRR, including mveConverged (whether the maximum-volume ellipsoid rounding reached tolerance). Empty ([]) for the 'achr' and 'randomObjective' methods.
Notes
With 'randomObjective', the solutions are generated by optimising (with random weights) a random set of nObjectives reactions (default 2). The sign of each weight is chosen at random, which selects maximisation or minimisation of the reaction; reactions with an upper bound below 0 always receive a positive weight. The default 'achr' and the 'chrr' methods use no random objectives; they take hit-and-run steps through the interior of the solution space.
If the model is a GECKO v3+ ecModel, then usage_prot reactions are not selected as random objectives; the objectives are drawn from the metabolic reactions.
Examples
% Near-uniform interior sampling (default, ACHR):
solutions = randomSampling(model, 1000);
% Coordinate hit-and-run with rounding:
solutions = randomSampling(model, 1000, 'method', 'chrr', 'seed', 1);
% Random-objective vertex method:
solutions = randomSampling(model, 1000, 'method', 'randomObjective');
See also
sampleACHR, sampleCHRR, sampleMaxVolEllipse
reporterMetabolites#
function repMets=reporterMetabolites(model,genes,genePValues,varargin)
Identify metabolites around which transcriptional changes occur.
Applies the Reporter Metabolites algorithm, which scores each metabolite by the differential expression of the genes around it.
Parameters
model: structa model structure.
genes: cella cell array of gene names (matching model.genes).
genePValues: doubleP-values for differential expression of the genes. Values must lie in [0, 1]; NaN values are ignored, any other value raises an error.
Name-Value Arguments
printResults: logicaltrue to print the top 20 Reporter Metabolites to the screen (default false).
outputFile: charthe results are printed to this file (default none).
geneFoldChanges: doublelog-fold changes for the genes. If supplied, Reporter Metabolites are also calculated for the upregulated genes (fold change >= 0) alone and for the downregulated genes (fold change < 0) alone, in addition to the full test (default none).
Returns
repMets: structan array of structures with the following fields:
test : a string that describes the genes used to calculate the Reporter Metabolites ("all", "only up", or "only down"). The tests "only up" and "only down" are only calculated if geneFoldChanges is supplied.
mets : a cell array of metabolite IDs for the metabolites for which a score could be calculated.
metNames : a cell array with the names of the metabolites in "mets".
metZScores : background-corrected Z-scores for differential expression around each metabolite in "mets". The entries of all fields are sorted by this score, highest first.
metPValues : one-sided (upper-tail) P-values of "metZScores".
metNGenes : number of neighbouring genes for each metabolite in "mets".
meanZ : average Z-scores for the genes around each metabolite in "mets".
stdZ : standard deviations of the Z-scores around each metabolite in "mets".
Examples
repMets = reporterMetabolites(model, genes, genePValues, ...
printResults, outputFile, geneFoldChanges);
Notes
For details about the algorithm, see Patil KR, Nielsen J, Uncovering transcriptional regulation of metabolism by using metabolic network topology. Proc. Natl Acad. Sci. USA 2005;102:2685-2689.
The background correction uses the closed-form mean and standard deviation of the aggregate Z-score of n genes drawn at random from all scored genes, so the results are deterministic.
runDynamicFBA#
function [concentrationMatrix, excRxnNames, timeVec, biomassVec] = runDynamicFBA(model, substrateRxns, initConcentrations, initBiomass, timeStep, nSteps, plotRxns, exclUptakeRxns)
Perform dynamic FBA using the static optimisation approach.
Parameters
model: structa model structure.
substrateRxns: cellcell array with exchange reaction identifiers for substrates that are initially in the media, whose concentration may change (for example not h2o or co2).
initConcentrations: doubleinitial concentrations of substrates (matching substrateRxns).
initBiomass: doubleinitial biomass (must be non-zero).
timeStep: doubletime step size.
nSteps: doublemaximum number of time steps.
plotRxns: cellcell array with exchange reaction identifiers for substrates whose concentration should be plotted.
exclUptakeRxns: cellcell array with exchange reaction identifiers for substrates whose concentration does not change (for example co2, o2, h2o, h).
Returns
concentrationMatrix: doublematrix with extracellular metabolite concentrations.
excRxnNames: cellcell array with exchange reaction identifiers that match the metabolites included in the concentrationMatrix.
timeVec: doublevector of time points.
biomassVec: doublevector with biomass concentrations.
Examples
[concentrationMatrix, excRxnNames, timeVec, biomassVec] = ...
runDynamicFBA(model, substrateRxns, initConcentrations, ...
initBiomass, timeStep, nSteps, plotRxns, exclUptakeRxns);
Notes
If no initial concentration is given for a substrate that has an open uptake in the model (that is, model.lb < 0), the initial concentration is set to 1000. If the uptake bound calculated from the concentration exceeds the maximum uptake rate specified in the model for that nutrient, and the maximum uptake rate specified is > 0, the maximum uptake rate specified in the model is used as the uptake bound.
Modified from COBRA Toolbox dynamicFBA.m.
runPhenotypePhasePlane#
function [growthRates, shadowPrices1, shadowPrices2] = runPhenotypePhasePlane(model, controlRxn1, controlRxn2, varargin)
Run phenotype phase plane analysis and plot the results.
Runs phenotype phase plane analysis and plots the results. The first plot is a 3D surface plot showing the phenotype phase plane, the other two plots show the shadow prices of the metabolites from the two control reactions, which define the phases.
Parameters
model: structa model structure.
controlRxn1: charreaction identifier of the first reaction to be plotted.
controlRxn2: charreaction identifier of the second reaction to be plotted.
Name-Value Arguments
nPts: doublethe number of points to plot in each dimension (default 50).
range1: doublethe range [from 0 to range1] of reaction 1 to plot (default 20).
range2: doublethe range [from 0 to range2] of reaction 2 to plot (default 20).
Returns
growthRates: doublea matrix of maximum growth rates.
shadowPrices1: doublea matrix with shadow prices for reaction 1.
shadowPrices2: doublea matrix with shadow prices for reaction 2.
Examples
[growthRates, shadowPrices1, shadowPrices2] = ...
runPhenotypePhasePlane(model, controlRxn1, controlRxn2, nPts, ...
range1, range2);
Notes
Modified from COBRA Toolbox phenotypePhasePlane.m.
runProductionEnvelope#
function [biomassValues, targetValues] = runProductionEnvelope(model, targetRxn, biomassRxn, varargin)
Calculate the byproduct secretion envelope.
Parameters
model: structa model structure.
targetRxn: charidentifier of target metabolite production reaction.
biomassRxn: charidentifier of biomass reaction.
Name-Value Arguments
nPts: doublenumber of biomass values at which the target bounds are calculated (default 20).
Returns
biomassValues: doublenPts biomass values, evenly spaced from the minimum to the maximum biomass flux.
targetValues: doublea matrix with two rows: the lower bounds (row 1) and the upper bounds (row 2) of the target reaction flux at each biomass value. NaN where the problem has no solution.
Examples
[biomassValues, targetValues] = runProductionEnvelope(model, ...
targetRxn, biomassRxn, nPts);
Notes
Modified from COBRA Toolbox productionEnvelope.m.
runRobustnessAnalysis#
function [controlFlux, objFlux] = runRobustnessAnalysis(model, controlRxn, varargin)
Perform robustness analysis for a reaction and objective.
Varies the flux of a reaction of interest from its minimum to its maximum and calculates the optimal value of an objective of interest at each flux.
Parameters
model: structa model structure.
controlRxn: charreaction of interest whose value is to be controlled.
Name-Value Arguments
nPoints: doublenumber of control flux values (default 20).
objRxn: charreaction identifier of the objective to be maximised (default: the objective defined in the model).
plotRedCost: logicalwhether the reduced cost of the control reaction is also plotted on the right axis (default false).
Returns
controlFlux: doubleflux values of the reaction of interest, ranging from its minimum to its maximum value.
objFlux: doubleoptimal values of objective reaction at each control reaction flux value.
Examples
[controlFlux, objFlux] = runRobustnessAnalysis(model, controlRxn, ...
nPoints, objRxn);
Notes
Modified from COBRA Toolbox robustnessAnalysis.m.
runSimpleOptKnock#
function out = runSimpleOptKnock(model, targetRxn, biomassRxn, varargin)
Find deletions that couple metabolite production to growth.
Checks all gene or reaction deletions for growth-coupled metabolite production, by testing combinations of up to maxNumKO deletions. It tries a deeper deletion only after a deletion whose growth rate is above minGrowth. A combination is reported if the growth rate exceeds minGrowth and the product of growth rate and production rate exceeds the value without the last added deletion (the wild type for the first deletion) by more than 1 %. The method is not defined as a MILP and is therefore slow.
Parameters
model: structa model structure.
targetRxn: charidentifier of target reaction.
biomassRxn: charidentifier of biomass reaction.
Name-Value Arguments
deletions: cellcell array with gene or reaction identifiers that should be considered for knockout (default model.rxns).
genesOrRxns: charstring indicating whether deletions parameter is given with 'genes' or 'rxns' identifiers (default 'rxns').
maxNumKO: doublemaximum number of simultaneous knockouts (default 1).
minGrowth: doubleminimum growth rate (default 0.05).
Returns
out: structstructure with deletion strategies that result in growth-coupled production, with fields:
KO : cell array with gene(s) or reaction(s) to be deleted.
growthRate : vector with growth rates after deletion.
prodRate : vector with production rates after deletion.
score : vector with the product of growth rate and production rate.
Examples
out = runSimpleOptKnock(model, targetRxn, biomassRxn, deletions, ...
genesOrRxns, maxNumKO, minGrowth);
sampleACHR#
function solutions = sampleACHR(model, nSamples, thinning, warmup, seed)
Artificially Centered Hit-and-Run flux sampling.
Draws nSamples flux vectors approximately uniformly from the flux polytope {v : Sv = 0, lb <= v <= ub}, using the ACHR algorithm (Kaufman & Smith 1998). No rounding is performed, so on strongly elongated polytopes (for example enzyme-constrained models) mixing is slower than with sampleCHRR, which rounds the polytope. Reactions whose bounds or warmup values coincide never move. The remaining reactions are corrected towards Sv = 0 every few steps and before each recorded sample, with a sparse Cholesky factor of the row-normalised SS' (no dense null-space basis), so the rounding error in Sv does not grow with the number of steps and samples stay inside the bounds. The guarantee S*v = 0 holds for a well-conditioned S and warmup points that are feasible for the model. When the largest residual of a recorded sample exceeds 1e-9 times max(1, max(abs(v))) (nearly dependent rows of S, a noisy or infeasible warmup), sampleACHR issues the warning sampleACHR:steadyStateNotRestored.
Parameters
model: structa model structure.
nSamples: doublenumber of flux vectors to return (default 1000).
thinning: doubleMarkov-chain steps between recorded samples (default 100).
warmup: doublenPoints-by-nRxns warmup vertices (default: generated by sampleWarmupPoints).
seed: doublerandom seed for reproducibility (default: current RNG state).
Returns
solutions: doublenRxns-by-nSamples matrix of sampled flux distributions.
See also
randomSampling, sampleCHRR, sampleWarmupPoints
sampleChebyshevCenter#
function x0 = sampleChebyshevCenter(A, b)
Centre of the largest ball inscribed in a polytope.
Solves the LP max r s.t. a_i'*x + ||a_i||r <= b_i, r >= 0, giving a strictly interior point of {x : Ax <= b}. Used to initialise the interior-point MVE solver (sampleMaxVolEllipse) inside sampleCHRR.
Parameters
A: doublem-by-n constraint matrix.
b: doublem-by-1 right-hand side.
Returns
x0: doublen-by-1 Chebyshev centre (strictly interior point).
See also
sampleMaxVolEllipse, sampleCHRR
sampleCHRR#
function [solutions, info] = sampleCHRR(model, nSamples, thinning, nBurnin, seed, fixedWidthTol)
Coordinate Hit-and-Run with Rounding flux sampling.
Draws nSamples flux vectors approximately uniformly from the flux polytope {v : S*v = 0, lb <= v <= ub}, using the CHRR algorithm (Haraldsdottir et al. 2017, Bioinformatics 33:1741). The polytope is rounded before sampling, which improves mixing on strongly elongated polytopes (for example enzyme-constrained models) in comparison with sampleACHR, which does not round.
Constraints to condition on (for example a biomass lower bound or measured exchange fluxes) are set on the model before the call.
Parameters
model: structa model structure.
nSamples: doublenumber of flux vectors to return (default 1000).
thinning: doubleMarkov-chain steps between recorded samples (default 100).
nBurnin: doubleburn-in steps discarded before the first recorded sample (default 1000).
seed: doublerandom seed for reproducibility (default: current RNG state).
fixedWidthTol: doublea reaction whose allowed flux range is narrower than this is treated as stoichiometrically fixed and added to the equality system at the middle of its range, which keeps the reduced polytope full-dimensional (default 1e-7).
Returns
solutions: doublenRxns-by-nSamples matrix of sampled flux distributions.
info: struct.nDimensions : dimension of the sampled flux polytope .mveConverged : whether MVE rounding reached tolerance .fixedRxns : IDs of reactions added to the equality system as fixed
See also
randomSampling, sampleACHR, sampleMaxVolEllipse
sampleMaxVolEllipse#
function [x, E, converged] = sampleMaxVolEllipse(A, b, x0, maxiter, tol, reg)
Maximum-volume inscribed ellipsoid of a polytope.
Solves max log det E over centre x and SPD matrix E such that the ellipsoid {x + Es : ||s||_2 <= 1} is contained in the polytope {z : Az <= b}, using the Zhang & Gao (2003) primal-dual interior-point method (the regularised variant used in COBRA's CHRR sampler). This is the rounding step of sampleCHRR: the returned transform E maps the polytope to a well-conditioned body in which coordinate hit-and-run samples.
This function is pure linear algebra (no LP solver) except when x0 is empty, in which case a Chebyshev centre is obtained via sampleChebyshevCenter.
Parameters
A: doublem-by-n constraint matrix of the polytope {z : A*z <= b}. Requires m >= n+1 and a non-empty interior.
b: doublem-by-1 right-hand side.
x0: double (optional)a strictly interior point (A*x0 < b). If empty, computed by sampleChebyshevCenter(A, b).
maxiter: double (optional)maximum interior-point iterations (default 150).
tol: double (optional)convergence tolerance (default 1e-6).
reg: double (optional)diagonal (Levenberg) regularisation of the Newton solves (default 1e-8).
Returns
x: doublen-by-1 ellipsoid centre.
E: doublen-by-n lower-triangular rounding transform with EE' = E2 (the SPD ellipsoid matrix). The rounding substitution is z = x + Ey.
converged: logicalwhether tol was reached within maxiter. If false, the last iterate is returned as the centre and transform, which is a valid but looser rounding.
Notes
Analytic cases, tested in tSampling: a box maps to the unit ball (E = I); a sheared box {z : -1 <= Mz <= 1} gives EE' = inv(M)*inv(M)'; a triangle gives its Steiner inellipse.
Based on Y. Zhang & L. Gao (2003), SIAM J. Optim. 14:53-76; as used in Haraldsdottir et al. (2017) Bioinformatics 33:1741 (CHRR).
See also
sampleCHRR, sampleChebyshevCenter, randomSampling
sampleWarmupPoints#
function warmup = sampleWarmupPoints(model,varargin)
FVA warmup vertices for ACHR sampling.
Generates warmup points for sampleACHR by maximising and minimising each reaction in turn and storing the full flux distribution at each optimum. These vertices span the flux polytope and define the hit-and-run directions.
Parameters
model: structa model structure.
Name-Value Arguments
runParallel: logicalrun the calculations in parallel, as in getAllowedBounds, which solves the same per-reaction minimisation and maximisation LPs (default true).
Returns
warmup: doublenPoints-by-nRxns matrix; each row is a vertex flux distribution. Duplicate rows are removed.
See also
sampleACHR, randomSampling, getAllowedBounds
traceFluxPath#
function [pathRxns, pathMets, cumFrac] = traceFluxPath(model, fluxes, fromRxn, toRxn, varargin)
Find the highest-flux-fraction path between two reactions.
Traces how flux flows from one reaction to another through the metabolic network, quantifying what fraction of the source reaction's flux reaches the target. At each metabolite junction the flux is split proportionally among all consuming reactions; the path with the highest cumulative fraction is returned, and printed if verbose is true.
By default the search excludes currency metabolites (for example ATP, NAD, H2O), which makes the returned path follow material flow. The setting traceMaterial=false disables this.
Parameters
model: structa model structure.
fluxes: doubleflux vector (length = numel(model.rxns)).
fromRxn: charsource reaction ID.
toRxn: chartarget reaction ID.
Name-Value Arguments
cutoff: doubleminimum net flux through a metabolite (|S_ij * v_j|) for a consuming reaction to be considered (default 1e-8).
maxHops: doublepaths of more than maxHops reactions are not extended further, so a returned path has at most maxHops + 1 reactions (default 30).
verbose: logicalprint the path to the command window (default true).
traceMaterial: logicalexclude common currency and cofactor metabolites (ATP, ADP, NAD, NADH, H2O, CoA, Pi, CO2 and others); the path then follows material flux (default true).
carbonOnly: logicaladditionally require each intermediate metabolite to contain at least one carbon atom, inferred from model.metFormulas. Drops H+, H2O, Pi, O2, NH3, CO2 that are not already caught by the currency list. Ignored with a warning when model.metFormulas is absent or empty (default false).
excludeMets: cell of charextra metabolite names or IDs (after stripping compartment suffix) to exclude, in addition to the built-in currency list (which applies when traceMaterial is true) (default {}).
Returns
pathRxns: cellcell array of reaction IDs on the best path, including fromRxn and toRxn. Empty if no path is found.
pathMets: cellmetabolite IDs at each junction (numel = numel(pathRxns)-1).
cumFrac: doublefraction of fromRxn's flux that passes through this exact path (0 = no path found, 1 = all flux reaches toRxn directly).
Examples
[p, m, f] = traceFluxPath(model, sol.x, 'PFK', 'ATPS4rpp')
% disable material filter to see all connections including ATP and ADP:
[p, m, f] = traceFluxPath(model, sol.x, 'PFK', 'ATPS4rpp', 'traceMaterial', false)
% add model-specific cofactors to the exclusion list:
[p, m, f] = traceFluxPath(model, sol.x, 'PFK', 'CS', 'excludeMets', {'acetyl-CoA'})
Notes
The algorithm follows metabolites in the forward direction only: it traces the metabolites that fromRxn produces and finds which consuming reactions eventually reach toRxn. If fromRxn and toRxn are not connected in the forward flux direction (for example they are in parallel branches), an empty path is returned. A best-first search, which expands the entry with the highest cumulative fraction first, finds the highest-fraction path; a path does not revisit a reaction.
walkFluxes#
function walkFluxes(model, fluxes, startRxn, varargin)
Interactively navigate a flux distribution reaction by reaction.
Starting from a chosen reaction, displays the flux-carrying reactions connected through shared metabolites, grouped by metabolite and labelled with each neighbour's role (produces or consumes). Entering the number of a neighbour steps to it. The visited reactions are kept in a history, and 'b' steps back through it.
Parameters
model: structa model structure.
fluxes: doubleflux vector (length = numel(model.rxns)).
startRxn: char or doublestarting reaction ID (string) or reaction index.
Name-Value Arguments
cutoff: doubleminimum net flux through a metabolite (|S_ij * v_j|) for the metabolite to be listed for the current reaction and for a reaction to be displayed as a neighbour (default 1e-8).
maxPerMet: doublemaximum neighbour reactions displayed per metabolite, selected by decreasing absolute flux (default 8).
Examples
sol = solveLP(model);
walkFluxes(model, sol.x, 'BIOMASS_Ec_iJO1366_core_53p95M')
walkFluxes(model, sol.x, 'PFK', 'cutoff', 1e-6)
Notes
Navigation commands:
This function is interactive and reads from the terminal at every step. It raises an error under -batch and in deployed code.