Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions analysis/FSEOF.m
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
function targets=FSEOF(model,biomassRxn,targetRxn,iterations,coefficient,outputFile)
% FSEOF
% Implements the Flux Scanning based on Enforced Objective Flux algorithm.
% FSEOF Flux Scanning based on Enforced Objective Flux.
%
% Input:
% model a model structure
% biomassRxn string with reaction ID of the biomass formation or
% growth reaction
% targetRxn string with reaction ID of target reaction
% iterations numeric indicating number of iterations (optional,
% default 10)
% coefficient numeric indicating ratio of optimal target reaction
% flux, must be less than 1 (optional, default 0.9)
% outputFile string with output filename (optional, default prints
% to command window)
% 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 has been specified (targets), it will also generate
% a structure indicating for each model reaction whether it is identified
% by FSEOF as a target and the slope of the reaction when switching from
% biomass formation to product formation.
%
% Output:
% targets structure with information for identified targets
% logical logical array indicating whether a model reaction was
% identified as target by FSEOF
% slope numeric array with FSEOF slopes for target reactions
% Parameters
% ----------
% model : struct
% a model structure.
% biomassRxn : char
% reaction ID of the biomass formation or growth reaction.
% targetRxn : char
% reaction ID of the target reaction.
% iterations : double, optional
% number of iterations (default 10).
% coefficient : double, optional
% ratio of optimal target reaction flux, must be less than 1
% (default 0.9).
% outputFile : char, optional
% output filename (default prints to command window).
%
% This function writes an tab-delimited file or prints to command window.
% If an output has been specified (targets), it will also generate a
% structure indicating for each model reaction whether it is identified by
% FSEOF as a target and the slope of the reaction when switching from
% biomass formation to product formation.
% Returns
% -------
% targets : struct
% structure with information for identified targets, with fields:
%
% - logical : logical array indicating whether a model reaction was
% identified as target by FSEOF
% - slope : numeric array with FSEOF slopes for target reactions
%
% Usage: targets = FSEOF(model, biomassRxn, targetRxn, iterations,...
% coefficient, outputFile)
% Examples
% --------
% targets = FSEOF(model, biomassRxn, targetRxn, iterations, ...
% coefficient, outputFile);

biomassRxn=char(biomassRxn);
targetRxn=char(targetRxn);
Expand Down
66 changes: 40 additions & 26 deletions analysis/analyzeSampling.m
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
function scores=analyzeSampling(Tex, df, solutionsA, solutionsB, printResults)
% analyzeSampling
% Compares the significance of change in flux between two conditions with
% the significance of change in gene expression
% analyzeSampling Compare flux change significance with expression change.
%
% Tex a vector of t-scores for the change in gene expression
% for each reaction. This score could be the Student t
% between the two conditions, or you can calculate it from
% a p-value (by computing the inverse of the so called error
% function). If you choose the second alternative you should
% be aware that the transcripts that increased in expression
% level should have positive values and those who decreased
% in expression level should have negative values (the
% p-values only tell you if the fluxes changed or not but
% not in which direction)
% df the degrees of freedom in the t-test
% solutionsA random solutions for the reference condition (as
% generated by randomSampling)
% solutionsB random solutions for the test condition (as generated
% by randomSampling)
% printResults prints the most significant reactions in each category
% (optional, default false)
% Compares the significance of change in flux between two conditions with
% the significance of change in gene expression.
%
% scores a Nx3 column matrix with the probabilities of a reaction:
% 1) changing both in flux and expression in the same direction
% 2) changing in expression but not in flux
% 3) changing in flux but not in expression or changing
% in opposed directions in flux and expression.
% Parameters
% ----------
% Tex : double
% a vector of t-scores for the change in gene expression for each
% reaction. This score could be the Student t between the two
% conditions, or you can calculate it from a p-value (by computing the
% inverse of the so called error function). If you choose the second
% alternative you should be aware that the transcripts that increased
% in expression level should have positive values and those who
% decreased in expression level should have negative values (the
% p-values only tell you if the fluxes changed or not but not in which
% direction).
% df : double
% the degrees of freedom in the t-test.
% solutionsA : double
% random solutions for the reference condition (as generated by
% randomSampling).
% solutionsB : double
% random solutions for the test condition (as generated by
% randomSampling).
% printResults : logical, optional
% prints the most significant reactions in each category
% (default false).
%
% Usage: scores=analyzeSampling(Tex, df, solutionsA, solutionsB, printResults)
% Returns
% -------
% scores : double
% a Nx3 column matrix with the probabilities of a reaction:
%
% 1. changing both in flux and expression in the same direction
% 2. changing in expression but not in flux
% 3. changing in flux but not in expression or changing in opposed
% directions in flux and expression
%
% Examples
% --------
% scores = analyzeSampling(Tex, df, solutionsA, solutionsB, ...
% printResults);

if nargin<5
printResults=false;
Expand Down
109 changes: 62 additions & 47 deletions analysis/findGeneDeletions.m
Original file line number Diff line number Diff line change
@@ -1,54 +1,69 @@
function [genes, fluxes, originalGenes, details, grRatioMuts]=findGeneDeletions(model,testType,analysisType,refModel,oeFactor)
% findGeneDeletions
% Deletes genes, optimizes the model, and keeps track of the resulting
% fluxes. This is used for identifying gene deletion targets.
% findGeneDeletions Delete genes and track the resulting fluxes.
%
% model a model structure
% testType single/double gene deletions/over expressions. Over
% expression only available if using MOMA
% 'sgd' single gene deletion
% 'dgd' double gene deletion
% 'sgo' single gene over expression
% 'dgo' double gene over expression
% (optional, default 'sgd')
% analysisType determines whether to use FBA ('fba') or MOMA ('moma')
% in the optimization. (optional, default 'fba')
% refModel MOMA works by fitting the flux distributions of two
% models to be as similar as possible. The most common
% application is where you have a reference model where
% some of the fluxes are constrained from experimental
% data. This model is required when using MOMA
% oeFactor a factor by which the fluxes should be increased if a
% gene is overexpressed (optional, default 10)
% Deletes genes, optimizes the model, and keeps track of the resulting
% fluxes. This is used for identifying gene deletion targets.
%
% genes a matrix with the genes that were deleted in each
% optimization (the gene indexes in originalGenes). Each
% row corresponds to a column in fluxes
% fluxes a 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 simply the genes in the input model. Included for
% simple presentation of the output
% details not all genes will be deleted in all analyses. It is
% for example not necessary to delete genes for dead end
% reactions. This is a vector with details about
% each gene in originalGenes and why or why not it was
% deleted
% 1: Was deleted/overexpressed
% 2: Proved lethal in sgd (single gene deletion)
% 3: - redundant, no longer used -
% 4: Involved in dead-end reaction
% grRatioMuts growth rate ratio between mutated strain and wild type,
% matches the originalGenes(genes) mutants. Note that
% this does not directly map to model.genes, as is the case
% for COBRA getEssentialGenes. However, this can be
% obtained by afterwards running:
% grRatio=zeros(1,numel(model.genes));
% grRatio(genes)=grRatioMuts;
% Parameters
% ----------
% model : struct
% a model structure.
% testType : char, optional
% single/double gene deletions/over expressions. Over expression is
% only available if using MOMA (default 'sgd'):
%
% Usage: [genes, fluxes, originalGenes, details, grRatioMuts]=findGeneDeletions(model,testType,analysisType,...
% refModel,oeFactor)
% - 'sgd' : single gene deletion
% - 'dgd' : double gene deletion
% - 'sgo' : single gene over expression
% - 'dgo' : double gene over expression
% analysisType : char, optional
% determines whether to use FBA ('fba') or MOMA ('moma') in the
% optimization (default 'fba').
% refModel : struct, optional
% MOMA works by fitting the flux distributions of two models to be as
% similar as possible. The most common application is where there is a
% reference model with some fluxes constrained from experimental data.
% This model is required when using MOMA.
% oeFactor : double, optional
% a factor by which the fluxes should be increased if a gene is
% overexpressed (default 10).
%
% Returns
% -------
% genes : double
% a matrix with the genes that were deleted in each optimization (the
% gene indexes in originalGenes). Each row corresponds to a column in
% fluxes.
% fluxes : double
% a 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 : cell
% simply the genes in the input model. Included for simple
% presentation of the output.
% details : double
% not all genes will be deleted in all analyses. It is for example not
% necessary to delete genes for dead end reactions. This is a vector
% with details about each gene in originalGenes and why or why not it
% was deleted:
%
% - 1 : was deleted/overexpressed
% - 2 : proved lethal in sgd (single gene deletion)
% - 3 : redundant, no longer used
% - 4 : involved in dead-end reaction
% grRatioMuts : double
% growth rate ratio between mutated strain and wild type, matching the
% originalGenes(genes) mutants. Note that this does not directly map
% to model.genes, as is the case for COBRA getEssentialGenes. However,
% this can be obtained by afterwards running:
%
% grRatio=zeros(1,numel(model.genes));
% grRatio(genes)=grRatioMuts;
%
% Examples
% --------
% [genes, fluxes, originalGenes, details, grRatioMuts]=...
% findGeneDeletions(model,testType,analysisType,refModel,oeFactor);

originalModel=model;
if nargin<5
Expand Down
46 changes: 28 additions & 18 deletions analysis/followChanged.m
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
function followChanged(model,fluxesA,fluxesB, cutOffChange, cutOffFlux, cutOffDiff, metaboliteList)
% followChanged
% Prints fluxes and reactions for each of the reactions that results in
% different fluxes compared to the reference case.
% followChanged Print reactions whose fluxes differ from a reference case.
%
% model a model structure
% fluxesA flux vector for the test case
% fluxesB flux vector for the reference test
% cutOffChange reactions where the fluxes differ by less than
% this many percent won't be printed (optional, default 10^-8)
% cutOffFlux reactions where the absolute value of both fluxes
% are below this value won't be printed (optional,
% default 10^-8)
% cutOffDiff reactions where the fluxes differ by less than
% cutOffDiff won't be printed (optional, default 10^-8)
% metaboliteList cell array of metabolite names. Only reactions
% involving any of these metabolites will be
% printed (optional)
% Prints fluxes and reactions for each of the reactions that result in
% different fluxes compared to the reference case.
%
% Usage: followChanged(model,fluxesA,fluxesB, cutOffChange, cutOffFlux,
% cutOffDiff, metaboliteList)
% Parameters
% ----------
% model : struct
% a model structure.
% fluxesA : double
% flux vector for the test case.
% fluxesB : double
% flux vector for the reference test.
% cutOffChange : double, optional
% reactions where the fluxes differ by less than this many percent
% won't be printed (default 10^-8).
% cutOffFlux : double, optional
% reactions where the absolute value of both fluxes are below this
% value won't be printed (default 10^-8).
% cutOffDiff : double, optional
% reactions where the fluxes differ by less than cutOffDiff won't be
% printed (default 10^-8).
% metaboliteList : cell, optional
% cell array of metabolite names. Only reactions involving any of
% these metabolites will be printed.
%
% Examples
% --------
% followChanged(model,fluxesA,fluxesB,cutOffChange,cutOffFlux,...
% cutOffDiff,metaboliteList);

%Checks if a cut off flux has been set
if nargin<4
Expand Down
37 changes: 25 additions & 12 deletions analysis/followFluxes.m
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
function errorFlag=followFluxes(model, fluxesA, lowerFlux, upperFlux, fluxesB)
% followFluxes
% Prints fluxes and reactions for each of the reactions that results in
% fluxes in the specified interval.
% followFluxes Print reactions with fluxes in a specified interval.
%
% model a model structure
% fluxesA flux vector for the test case
% lowerFlux only reactions with fluxes above this cutoff
% value are displayed
% upperFlux only reactions with fluxes below this cutoff
% value are displayed (optional, default Inf)
% fluxesB flux vector for the reference case(optional)
% Prints fluxes and reactions for each of the reactions that result in
% fluxes within the specified interval.
%
% Usage: errorFlag=followFluxes(model, fluxesA, lowerFlux, upperFlux,
% fluxesB)
% Parameters
% ----------
% model : struct
% a model structure.
% fluxesA : double
% flux vector for the test case.
% lowerFlux : double
% only reactions with fluxes above this cutoff value are displayed.
% upperFlux : double, optional
% only reactions with fluxes below this cutoff value are displayed
% (default Inf).
% fluxesB : double, optional
% flux vector for the reference case.
%
% Returns
% -------
% errorFlag : double
% set to 1 if upperFlux is not larger than lowerFlux, otherwise empty.
%
% Examples
% --------
% errorFlag=followFluxes(model,fluxesA,lowerFlux,upperFlux,fluxesB);

%Checks that the upper flux is larger than the lower flux
if nargin>3
Expand Down
26 changes: 16 additions & 10 deletions analysis/getAllSubGraphs.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
function subGraphs=getAllSubGraphs(model)
% getAllSubGraphs
% Get all metabolic subgraphs in a model. Two metabolites
% are connected if they share a reaction.
% getAllSubGraphs Get all metabolic subgraphs in a model.
%
% Input:
% model a model structure
% Two metabolites are connected if they share a reaction.
%
% Output:
% subGraphs a boolean matrix where the rows correspond to the metabolites
% and the columns to which subgraph they are assigned to. The
% columns are ordered so that larger subgraphs come first
% Parameters
% ----------
% model : struct
% a model structure.
%
% Usage: subGraphs=getAllSubGraphs(model)
% Returns
% -------
% subGraphs : logical
% a boolean matrix where the rows correspond to the metabolites and
% the columns to which subgraph they are assigned to. The columns are
% ordered so that larger subgraphs come first.
%
% Examples
% --------
% subGraphs = getAllSubGraphs(model);

%Generate the connectivity graph. Metabolites are connected through
%reactions. This is not a bipartite graph with the reactions.
Expand Down
Loading
Loading