calcGroupStats(data, groups, statName, groupList, randStat, nRand)

calcGroupStats Calculate statistics such as mean or standard deviation for subgroups of a population


[groupStat, groupList, groupCnt, zScore] = calcGroupStats(data, groups, statName, groupList, randStat, nRand)


data: Matrix of data (individuals x variables) groups: Group identifier for each individual statName: Name of the statistic to be computed for each group:

‘mean’: mean value for group (default) ‘std’: standard deviation for group ‘median’: median for group ‘count’: sum total of variable values for group

groupList: List of group identifiers to be considered (optional, default

all values occurring in groups)

randStat: Perform randomization analysis nRand: # of randomizations

Group identifier can be either strings or numerical values


groupStat: Matrix of group statistic values for each group and variable groupList: List of group identifiers considered groupCount: Number of individuals in a group

createDeltaMatchMatrix(set1, set2)

Create a flux difference constraint matrix for MOMA type calculations


A = createDeltaMatchMatrix(set1, set2)


set1, set2: input sets


A: flux difference matrix


Generates a configuration report of the sytem and saves it as COBRAconfigReport.log



Converts a url to a clickable link in order to improve usability when using the MATLAB desktop environment


outLink = hyperlink(url, urlText, altText1, altText2)


url: url address urlText: url for java altText1: alternative text before link altText2: alternative text after link


outLink: clickable link

parseBoolean(str, tokens, allowedElementChars)

Parses a Boolean logic statement


[elements, newRule] = parseBoolean(str, tokens, allowedElementChars)


str: Input string or cell array of boolean statements tokens: Allowed operators in boolean statements (optional,

default ‘()&|~’)

allowedElementChars: Allowed characters in elements of the statement


elements: Non-operator elements newRule: New rule translated to element numbers rxnGeneMat: If str is a cell array, rxnGeneMat is the normal

COBRA rxnGeneMat (a matrix with rows corresponding to reactions, and columns corresponding to genes).

parseCobraVarargin(varArgIn, optArgin, defaultValues, validator, problemTypes, keyForSolverParams, emptyForDefault)

Parse varargin for a COBRA function to obtain function inputs and cobra-problem-specific parameters. Used to handle inputs for functions supporting all of (i) direct argument inputs, (ii) name-value inputs, and (iii) parameter structure inputss


[funParams, cobraParams, solverVaragin] = parseCobraVarargin(optArgin, defaultValues, validator, problemTypes, keyForSolverParams, emptyForDefault)


varArgIn: cell array of additional inputs for the function (= varargin in that function) optArgin: cell array of strings for the optional arguments of a function defaultValues: cell array of default values corresponding to optArgin validator: cell array of function handles for validating the inputs corresponding to optArgin

Will return error if the inputs do not return true from the validator

problemTypes: cell array of cobra supported optimization problems needed to solve in the function

(default {‘LP’, ‘MILP’, ‘QP’, ‘MIQP’})

keyForSolverParams: the keyword for solver-specific parameter structure in optArgin if solver-specific parameter structure

is an explicit optional input argument in optArgin (which is NOT encouraged when writing cobra functions because the solver-specific parameter structure as a convention among cobra functions can be inputted without keyword and is handled this way in this parsing process). If this is the case, provide the keyword and it will be handled (default ‘’). Note that in this case the solver parameter structure will not be included in funParams but instead integrated in solverVaragin

emptyForDefault: True to interpret empty inputs for positional arguments as using the default values (default false)

funParams: cell array of optional argument inputs corresponding to optArgin.

Can be assigned in the function easily by [argIn1, argIn2, …] = deal(funParams{:})

cobraParams: structure containing parsed cobra parameters for each problem type in problemTypes,

to be used within the cobra function being written.

solverVaragin: structure containing parsed cobra-problem-specific addition inputs as a cell array for each problem type in problemTypes,

with the first cell being the solver-specific parameter structure e.g., solverVarargin.LP contains the additional inputs for solveCobraLP, with solverVarargin.LP{1} being the solver-specific parameter structure, called as solveCobraLP(LPproblem, solverVarargin.LP{:})

parseGPR(grRuleString, currentGenes, preparsed, positions)

Convert a GPR rule in string format to a rule in logic format. We assume the following properties of GPR Rules: 1. There are no genes called “and” or “or” (in any capitalization). 2. A gene name does not contain any of the following characters: (),{},[],|,& and no whitespace. 3. The general format of a GPR is: Gene1 or Gene2 and (Gene3 or Gene4) 4. ‘and’ and ‘or’ operators as well as gene names have to be followed and preceded by either a whitespace character or a opening or closing bracket, respectively. Gene Names can also be at the beginning or the end of the string.


[ruleString, totalGeneList, newGeneList] = parseGPR(grRuleString, currentGenes, preparsed)


grRuleString: The rule string in textual format. currentGenes: Names of all currently known genes. Encountered

genes (column cell Array of Strings)

preparsed: Whether the sring inserted into the function was

preparsed or not. If provided, it is assumed, that currentGenes ONLY contains the genes in this rule AND that positions is the actual position of each gene to be used for the rule.

positions: Only used when preparsed is true.

positions(ismember(currentGenes,gene)) will become the number used for that gene in the rule.

ruleString: The logical formula representing the grRuleString.

Any position refers to the totalGeneList returned.

totalGeneList: The concatenation of currentGenes and newGeneList newGeneList: A list of gene Names that were not present in



Figures out the base metabolite names and compartments for each metabolite


[baseMetNames, compSymbols, uniqueMetNames, uniqueCompSymbols] = parseMetNames(metNames)


metNames: List of metabolite names


baseMetNames: List of met names without compartment symbol compSymbols: Compartment symbols for each metabolite uniqueMetNames: Unique metabolite names (w/o comp symbol) uniqueCompSymbols: Unique compartment symbols

Metabolite names should describe the compartment assignment in the form “metName[compName]”


Parses reaction formula into a list of metabolites and a list of S coefficients


[metaboliteList, stoichCoeffList, revFlag] = parseRxnFormula(formula)

formula: Reaction formula, may contain symbols ‘+’, ‘->’, ‘<=>’ in

addition to stoichiometric coefficients and metabolite names examples: ‘0.01 cdpdag-SC[m] + 0.01 pg-SC[m] -> 0.01 clpn-SC[m] + cmp[m] + h[m]’ (irreversible reaction) ‘cit[c] + icit[x] <=> cit[x] + icit[c] ‘ (reversible reaction) If no stoichiometric coefficient is provided, it is assumed to be = 1. Reaction formula should be a string, not a cell array


metaboliteList: Cell array with metabolite names stoichCoeffList: List of S coefficients revFlag: Indicates whether the reaction is reversible (true) or not (false)


formula = ‘0.01 cdpdag-SC[m] + 0.01 pg-SC[m] -> 0.01 clpn-SC[m] + cmp[m] + h[m]’

[metaboliteList, stoichCoeffList, revFlag] = parseRxnFormula(formula)

%metaboliteList = ‘cdpdag-SC[m]’ ‘pg-SC[m]’ ‘clpn-SC[m]’ ‘cmp[m]’ ‘h[m]’ %stoichCoeffList = -0.01 -0.01 0.01 1 1 %revFlag = false


preparse model.grRules before parsing the remaining part and transforming model.grRules into model.rules


preParsedGrRules = preparseGPR(grRules)


grRules: grRules cell or single grRule


preParsedGrRules: preparsed grRules cell or single grRule

reporterMets(model, data, nRand, pValFlag, nLayers, metric, dataRxns, inclExchFlag)

Implements the reporter metabolites algorithm by Patil & Nielsen


[normScore, nRxnsMet, nRxnsMetUni, rawScore] = reporterMets(model, data, nRand, pValFlag, nLayers, metric, dataRxns)


model: Metabolic network reconstruction structure data: Data matrix/vector nRand: Number of randomizations pValFlag: The data are p-values and should be converted to z-scores nLayers: Number of reaction layers around each metabolite considered (default = 1) metric: Metric used to evaluate score

(‘default’,’mean’, ‘median’, ‘std’, ‘count’)

dataRxns: Reaction list for the data file (if different from the

model reactions)

inclExchFlag: Flag for exchange reactions


normScore: Normalized scores for each metabolite nRxnsMet: Number of reactions connected to each metabolite nRxnsMetUni: rawScore: Raw unnormalized scores


Create selection matrix from a selection vector


selMat = selMatrix(selVec)


selVec: selection vector


selMat: selection matrix


selVec = [1 0 0 1 0 0] % returns selMat = [1 0 0 0 0 0

0 0 0 1 0 0]

% For reversible selections selVec = [1 0 0 1 -1 0] % returns selMat = [1 0 0 0 0 0

0 0 0 1 -1 0]


configures the number of (parallel) workers




nworkers: Number of workers in the pool


Requires the Parallel computing toolbox

splitString(string, delimiter)

Splits a string Perl style


fields = splitString(string, delimiter)


string: Either a single string or a cell array of strings delimiter: Splitting delimiter

fields: Either a single cell array of fields or a cell array of cell

arrays of fields

Default delimiter is ‘s’ (whitespace) Delimiters are perl regular expression style, e.g. ‘|’ has to be expressed as ‘|’ Results are returned in the cell array fields

translateList(list, trList1, trList2)

Translate a list of identifiers (either numerical or cell array) using a dictionary


list = translateList(list, trList1, trList2)


list: original list trList1: list of elemets to be changed trList2: list of elements to be changed into


list: list after changes


% Define original list list = {‘a’, ‘b’, ‘c’}

% Define dictionary trList1 = {‘b’, ‘c’} trList2 = {‘B’, ‘C’}

newList = translateList(list, trList1, trList2);

% returns newList = {‘a’, ‘B’, ‘C’};