Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: light_ecModel tutorial getSubsetEcModel #322

Merged
merged 10 commits into from
Jun 30, 2023
33 changes: 17 additions & 16 deletions doc/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/src/geckomat/gather_kcats/fuzzyKcatMatching.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0085 <span class="keyword">else</span>
0086 rxnNames = extractAfter(model.ec.rxns, 4);
0087 <span class="keyword">end</span>
0088 originalRxns = getIndexes(model,rxnNames(ecRxns),<span class="string">'rxns'</span>);
0088 [~,originalRxns] = ismember(rxnNames(ecRxns),model.rxns);
0089 <span class="keyword">for</span> i = 1:length(ecRxns)
0090 sel = find(model.S(:,originalRxns(i)) &lt; 0);
0091 substrates{i} = model.metNames(sel);
Expand Down
265 changes: 132 additions & 133 deletions doc/src/geckomat/gather_kcats/getStandardKcat.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/src/geckomat/get_enzyme_data/getECfromGEM.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0033 rxnNames = extractAfter(model.ec.rxns, 4);
0034 <span class="keyword">end</span>
0035
0036 rxnIdxs = getIndexes(model,rxnNames,<span class="string">'rxns'</span>);
0036 [~,rxnIdxs] = ismember(rxnNames,model.rxns);
0037
0038 <span class="comment">% Check if eccodes are valid</span>
0039 eccodes = model.eccodes;
Expand Down
116 changes: 116 additions & 0 deletions doc/src/geckomat/utilities/getSubsetEcModel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>Description of getSubsetEcModel</title>
<meta name="keywords" content="getSubsetEcModel">
<meta name="description" content="getSubset_ecModel">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
<meta name="robots" content="index, follow">
<link type="text/css" rel="stylesheet" href="../../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../../index.html">Home</a> &gt; <a href="#">src</a> &gt; <a href="#">geckomat</a> &gt; <a href="index.html">utilities</a> &gt; getSubsetEcModel.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../../index.html"><img alt="<" border="0" src="../../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for src\geckomat\utilities&nbsp;<img alt=">" border="0" src="../../../right.png"></a></td></tr></table>-->

<h1>getSubsetEcModel
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="box"><strong>getSubset_ecModel</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="box"><strong>function smallEcModel = getSubsetEcModel(bigEcModel,smallGEM) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> getSubset_ecModel
Generate a context-specific ecModel (strain/cell-line/tissue) by
mapping reactions and genes from a conventional context-specific GEM to
a general ecModel (bigEcModel), to yield a context-specific ecModel.

Input:
bigEcModel enzyme-constrained version of conventional model of
metabolism for a given species
smallGEM Reduced model (subset of the general model) for a
specific strain (microbes) or cell-line/tissues (mammals)

Output:
smallEcModel Enzyme-constrained version of the context-specific model

Usage: smallEcModel = getSubsetEcModel(smallGEM,bigEcModel)</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function smallEcModel = getSubsetEcModel(bigEcModel,smallGEM)</a>
0002 <span class="comment">% getSubset_ecModel</span>
0003 <span class="comment">% Generate a context-specific ecModel (strain/cell-line/tissue) by</span>
0004 <span class="comment">% mapping reactions and genes from a conventional context-specific GEM to</span>
0005 <span class="comment">% a general ecModel (bigEcModel), to yield a context-specific ecModel.</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% Input:</span>
0008 <span class="comment">% bigEcModel enzyme-constrained version of conventional model of</span>
0009 <span class="comment">% metabolism for a given species</span>
0010 <span class="comment">% smallGEM Reduced model (subset of the general model) for a</span>
0011 <span class="comment">% specific strain (microbes) or cell-line/tissues (mammals)</span>
0012 <span class="comment">%</span>
0013 <span class="comment">% Output:</span>
0014 <span class="comment">% smallEcModel Enzyme-constrained version of the context-specific model</span>
0015 <span class="comment">%</span>
0016 <span class="comment">% Usage: smallEcModel = getSubsetEcModel(smallGEM,bigEcModel)</span>
0017
0018 <span class="comment">% Check if original bigEcModel contains context-dependent protein constraints</span>
0019 <span class="keyword">if</span> any(bigEcModel.lb(startsWith(bigEcModel.rxns,<span class="string">'usage_prot_'</span>)) ~= -1000)
0020 disp([<span class="string">'The bigEcModel is constraint by protein concentrations that are '</span> <span class="keyword">...</span>
0021 <span class="string">'likely not relevant in the constructed smallEcModel.'</span>])
0022 <span class="keyword">end</span>
0023
0024 <span class="comment">% Remove genes (and associated reactions) that are absent in smallGEM</span>
0025 genesToRemove = setdiff(bigEcModel.genes,smallGEM.genes);
0026 smallEcModel = removeGenes(bigEcModel,genesToRemove,true,true,false);
0027
0028 <span class="comment">% Remove genes from ec-structure</span>
0029 enzToRemove = ismember(smallEcModel.ec.genes,genesToRemove);
0030 smallEcModel.ec.genes(enzToRemove) = [];
0031 smallEcModel.ec.enzymes(enzToRemove) = [];
0032 smallEcModel.ec.concs(enzToRemove) = [];
0033 smallEcModel.ec.mw(enzToRemove) = [];
0034 smallEcModel.ec.sequence(enzToRemove) = [];
0035 smallEcModel.ec.rxnEnzMat(:,enzToRemove) = [];
0036
0037 <span class="comment">% Remove any reaction (except prot_ associated) that is absent from smallGEM</span>
0038 trimRxns = regexprep(smallEcModel.rxns,<span class="string">'_REV|_EXP_\d+'</span>,<span class="string">''</span>);
0039 protRxns = startsWith(smallEcModel.rxns,{<span class="string">'usage_prot_'</span>,<span class="string">'prot_pool_exchange'</span>});
0040 keepRxns = ismember(trimRxns,smallGEM.rxns) | protRxns;
0041 smallEcModel = removeReactions(smallEcModel,~keepRxns, true, true, true);
0042
0043 <span class="comment">% Remove reactions from ec-structure</span>
0044 ecRxnsToRemove = ~ismember(smallEcModel.ec.rxns,smallEcModel.rxns);
0045
0046 smallEcModel.ec.rxns(ecRxnsToRemove) = [];
0047 smallEcModel.ec.kcat(ecRxnsToRemove) = [];
0048 smallEcModel.ec.source(ecRxnsToRemove) = [];
0049 smallEcModel.ec.notes(ecRxnsToRemove) = [];
0050 smallEcModel.ec.eccodes(ecRxnsToRemove) = [];
0051 smallEcModel.ec.rxnEnzMat(ecRxnsToRemove,:) = [];
0052
0053 smallEcModel = removeReactions(smallEcModel,~keepRxns, true, true, true);
0054 <span class="keyword">end</span>
0055</pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/src/geckomat/utilities/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1>Index for src\geckomat\utilities</h1>

<h2>Matlab files in this directory:</h2>
<table>
<tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="ecFVA.html">ecFVA</a></td><td>ecFVA </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="enzymeUsage.html">enzymeUsage</a></td><td>enzymeUsage </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="findGECKOroot.html">findGECKOroot</a></td><td>findGECKOroot </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="getFluxTarget.html">getFluxTarget</a></td><td>getFluxTarget </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="loadConventionalGEM.html">loadConventionalGEM</a></td><td>loadConventionalGEM </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="loadEcModel.html">loadEcModel</a></td><td>loadEcModel </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="loadFluxData.html">loadFluxData</a></td><td>loadFluxData </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="loadProtData.html">loadProtData</a></td><td>loadProtData </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="mapRxnsToConv.html">mapRxnsToConv</a></td><td>mapRxnsToConv </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="plotEcFVA.html">plotEcFVA</a></td><td>plotEcFVA </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="reportEnzymeUsage.html">reportEnzymeUsage</a></td><td>reportEnzymeUsage </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="saveEcModel.html">saveEcModel</a></td><td>saveECmodel </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="startGECKOproject.html">startGECKOproject</a></td><td>startGECKOproject </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="updateGECKOdoc.html">updateGECKOdoc</a></td><td>updateGeckoDoc </td></tr></table>
<tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="ecFVA.html">ecFVA</a></td><td>ecFVA </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="enzymeUsage.html">enzymeUsage</a></td><td>enzymeUsage </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="findGECKOroot.html">findGECKOroot</a></td><td>findGECKOroot </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="getFluxTarget.html">getFluxTarget</a></td><td>getFluxTarget </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="getSubsetEcModel.html">getSubsetEcModel</a></td><td>getSubset_ecModel </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="loadConventionalGEM.html">loadConventionalGEM</a></td><td>loadConventionalGEM </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="loadEcModel.html">loadEcModel</a></td><td>loadEcModel </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="loadFluxData.html">loadFluxData</a></td><td>loadFluxData </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="loadProtData.html">loadProtData</a></td><td>loadProtData </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="mapRxnsToConv.html">mapRxnsToConv</a></td><td>mapRxnsToConv </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="plotEcFVA.html">plotEcFVA</a></td><td>plotEcFVA </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="reportEnzymeUsage.html">reportEnzymeUsage</a></td><td>reportEnzymeUsage </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="saveEcModel.html">saveEcModel</a></td><td>saveECmodel </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="startGECKOproject.html">startGECKOproject</a></td><td>startGECKOproject </td></tr><tr><td><img src="../../../matlabicon.gif" alt="" border="">&nbsp;<a href="updateGECKOdoc.html">updateGECKOdoc</a></td><td>updateGeckoDoc </td></tr></table>


<h2>Subsequent directories:</h2>
Expand Down
13 changes: 6 additions & 7 deletions src/geckomat/gather_kcats/getStandardKcat.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,13 @@

% Only add if not geckoLight & getStandardKcat was not run earlier
if ~any(strcmp(model.mets,'prot_standard'))
% Add a new gene to be consistent with ec field named standard
proteinStdGenes.genes = 'standard';
if isfield(model,'geneShortNames')
proteinStdGenes.geneShortNames = 'std';
end
model = addGenesRaven(model, proteinStdGenes);

if ~model.ec.geckoLight
% Add a new gene to be consistent with ec field named standard
edkerk marked this conversation as resolved.
Show resolved Hide resolved
proteinStdGenes.genes = 'standard';
if isfield(model,'geneShortNames')
proteinStdGenes.geneShortNames = 'std';
end
model = addGenesRaven(model, proteinStdGenes);
% Add a new metabolite named prot_standard
proteinStdMets.mets = 'prot_standard';
proteinStdMets.metNames = proteinStdMets.mets;
Expand Down
55 changes: 55 additions & 0 deletions src/geckomat/utilities/getSubsetEcModel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function smallEcModel = getSubsetEcModel(bigEcModel,smallGEM)
% getSubset_ecModel
% Generate a context-specific ecModel (strain/cell-line/tissue) by
% mapping reactions and genes from a conventional context-specific GEM to
% a general ecModel (bigEcModel), to yield a context-specific ecModel.
%
% Input:
% bigEcModel enzyme-constrained version of conventional model of
% metabolism for a given species
% smallGEM Reduced model (subset of the general model) for a
% specific strain (microbes) or cell-line/tissues (mammals)
%
% Output:
% smallEcModel Enzyme-constrained version of the context-specific model
%
% Usage: smallEcModel = getSubsetEcModel(smallGEM,bigEcModel)

% Check if original bigEcModel contains context-dependent protein constraints
if any(bigEcModel.lb(startsWith(bigEcModel.rxns,'usage_prot_')) ~= -1000)
disp(['The bigEcModel is constraint by protein concentrations that are ' ...
'likely not relevant in the constructed smallEcModel.'])
end

% Remove genes (and associated reactions) that are absent in smallGEM
genesToRemove = setdiff(bigEcModel.genes,smallGEM.genes);
smallEcModel = removeGenes(bigEcModel,genesToRemove,true,true,false);

% Remove genes from ec-structure
enzToRemove = ismember(smallEcModel.ec.genes,genesToRemove);
smallEcModel.ec.genes(enzToRemove) = [];
smallEcModel.ec.enzymes(enzToRemove) = [];
smallEcModel.ec.concs(enzToRemove) = [];
smallEcModel.ec.mw(enzToRemove) = [];
smallEcModel.ec.sequence(enzToRemove) = [];
smallEcModel.ec.rxnEnzMat(:,enzToRemove) = [];

% Remove any reaction (except prot_ associated) that is absent from smallGEM
trimRxns = regexprep(smallEcModel.rxns,'_REV|_EXP_\d+','');
protRxns = startsWith(smallEcModel.rxns,{'usage_prot_','prot_pool_exchange'});
keepRxns = ismember(trimRxns,smallGEM.rxns) | protRxns;
smallEcModel = removeReactions(smallEcModel,~keepRxns, true, true, true);

% Remove reactions from ec-structure
ecRxnsToRemove = ~ismember(smallEcModel.ec.rxns,smallEcModel.rxns);

smallEcModel.ec.rxns(ecRxnsToRemove) = [];
smallEcModel.ec.kcat(ecRxnsToRemove) = [];
smallEcModel.ec.source(ecRxnsToRemove) = [];
smallEcModel.ec.notes(ecRxnsToRemove) = [];
smallEcModel.ec.eccodes(ecRxnsToRemove) = [];
smallEcModel.ec.rxnEnzMat(ecRxnsToRemove,:) = [];

smallEcModel = removeReactions(smallEcModel,~keepRxns, true, true, true);
end

46 changes: 46 additions & 0 deletions tutorials/light_ecModel/code/HT29_ftINIT.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
% For reference, code is provided here that was used to make a cell-line
% specific (HT-29) model of human-GEM with the ftINIT function of RAVEN.
% This model, stored at tutorials/light_ecModel/models/HT-29-GEM.yml, is
% for demontration purposes only. The intention of the code in this file is
% not to routinely regenerate this model file, but merely as reference how
% the HT-29-GEM was constructed.

% Have the Human-GEM repo at release 1.15.0, and added to the MATLAB path.
humanGEMroot = HumanGEMInstaller.getHumanGEMMainPath;
load(fullfile(humanGEMroot,'model','Human-GEM.mat');
m = ihuman;
m.grRules = simplifyGrRules(m.grRules, true);

prepDataHumanGEM = prepHumanModelForftINIT(m, true, ...
fullfile(humanGEMroot,'data','metabolicTasks','metabolicTasks_Essential.txt'), ...
fullfile(humanGEMroot,'model','reactions.tsv'));
save('prepDataHumanGEMGeneSymbols.mat','prepDataHumanGEM');

% Use RNA-seq data of cell line HT-29 (ACH-000552) from DepMap, downloaded
% from here: https://depmap.org/portal/download/all/.

tbl = readtable('OmicsExpressionProteinCodingGenesTPMLogp1.csv');
% Cell lines are per row, genes are columns.
sel = strcmp(tbl.Var1, 'ACH-000552');
genes = tbl.Properties.VariableNames(2:end);
for x = 1:length(genes)
a = split(genes{x}, '_');
genes{x} = a{1};
end

% Invert Logp1
dataTmp = table2array(tbl(sel,2:end));
data = 2.^dataTmp - 1;

arrayData = struct();
arrayData.genes = genes.';
arrayData.levels = data.';
arrayData.tissues = {'1'};
arrayData.threshold = 1;
HT29 = ftINIT(prepDataHumanGEM,arrayData.tissues{1},[],[],arrayData,{},getHumanGEMINITSteps('1+1'),false,true,[]);

% Restore ENSEMBL gene identifiers and remove unnecessary fields
[HT29.grRules,HT29.genes,HT29.rxnGeneMat] = translateGrRules(HT29.grRules,'ENSG','Symbol');
HT29 = rmfield(HT29,{'geneShortNames','rxnReferences','rxnFrom','metFrom','rxnConfidenceScores','rxnNotes','metCharges','inchis','metFormulas','subSystems','eccodes'});
HT29.name = 'GEM of HT-29 cell-line, for use in GECKO3 tutorial';
writeYAMLmodel(HT29,fullfile('..','models','HT29-GEM.yml'));
1 change: 1 addition & 0 deletions tutorials/light_ecModel/data/smilesDB.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -3498,3 +3498,4 @@ ximenic acid CCCCCCCCC=CCCCCCCCCCCCCCCCC(=O)O
xylitol C(C(C(C(CO)O)O)O)O
zinc [Zn]
zymosterol CC(CCC=C(C)C)C1CCC2C1(CCC3=C2CCC4C3(CCC(C4)O)C)C

Loading