Home > src > geckomat > utilities > mapRxnsToConv.m

mapRxnsToConv

PURPOSE ^

mapRxnsToConv

SYNOPSIS ^

function [mappedFlux, enzUsageFlux, usageEnz] = mapRxnsToConv(ecModel, model, fluxVect)

DESCRIPTION ^

 mapRxnsToConv
   A vector (or matrix) of fluxes is mapped to the reactions in the
   conventional starting model that was used to construct the ecModel. It
   is essential that the provided conventional model is indeed the model
   that was used to initate ecModel reconstruction.

 Input:
   ecModel         an ecModel in GECKO 3 format (with ecModel.ec structure),
                   that was used to obtain fluxVect
   model           the starting model for ecModel, to which the reactions
                   should be mapped
   fluxVect        vector or matrix of flux values, matching ecModel.rxns

 Output:
   mappedFlux      vector or matrix of flux values, matching model.rxns
   enzUsageFlux    vector or matrix of flux values from enzyme usage
                   reactions, as these are absent from mappedFlux
   usageEnz        cell array with protein IDs, matching enzUsageFlux

 Usage:
   [mappedFlux, enzUsageFlux, usageEnz] = mapRxnsToConv(ecModel, model, fluxVect)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [mappedFlux, enzUsageFlux, usageEnz] = mapRxnsToConv(ecModel, model, fluxVect)
0002 % mapRxnsToConv
0003 %   A vector (or matrix) of fluxes is mapped to the reactions in the
0004 %   conventional starting model that was used to construct the ecModel. It
0005 %   is essential that the provided conventional model is indeed the model
0006 %   that was used to initate ecModel reconstruction.
0007 %
0008 % Input:
0009 %   ecModel         an ecModel in GECKO 3 format (with ecModel.ec structure),
0010 %                   that was used to obtain fluxVect
0011 %   model           the starting model for ecModel, to which the reactions
0012 %                   should be mapped
0013 %   fluxVect        vector or matrix of flux values, matching ecModel.rxns
0014 %
0015 % Output:
0016 %   mappedFlux      vector or matrix of flux values, matching model.rxns
0017 %   enzUsageFlux    vector or matrix of flux values from enzyme usage
0018 %                   reactions, as these are absent from mappedFlux
0019 %   usageEnz        cell array with protein IDs, matching enzUsageFlux
0020 %
0021 % Usage:
0022 %   [mappedFlux, enzUsageFlux, usageEnz] = mapRxnsToConv(ecModel, model, fluxVect)
0023 
0024 if isempty(fluxVect)
0025     error('No or empty flux vector provided')
0026 end
0027 
0028 fluxes = fluxVect;
0029 rxnIDs = ecModel.rxns;
0030 
0031 % Invert flux of _REV reactions
0032 revRxns = endsWith(rxnIDs,'_REV') | contains(rxnIDs,'_REV_EXP_');
0033 fluxes(revRxns,:) = -fluxes(revRxns,:);
0034 rxnIDs(revRxns) = replace(rxnIDs(revRxns),'_REV','');
0035 % Remove _EXP_. suffixes
0036 rxnIDs = regexprep(rxnIDs,'_EXP_\d+','');
0037 
0038 % Map and sum fluxes to converted reaction IDs
0039 [rxnIDmap, convRxnID] = findgroups(rxnIDs);
0040 newVect = splitapply(@(x){sum(x,1)}, fluxes, rxnIDmap);
0041 newVect = cell2mat(newVect);
0042 
0043 % Place in same order as in original model
0044 [mapCheck,origIdx] = ismember(model.rxns,convRxnID);
0045 if ~all(mapCheck)
0046     error('Not all reactions from model.rxns can be found in the ecModel. Are you sure that ecModel is derived from model?')
0047 end
0048 mappedFlux=newVect(origIdx,:);
0049 
0050 % Separately report enzyme usages
0051 usageEnz = startsWith(ecModel.rxns,{'usage_prot_','prot_pool_exchange'});
0052 enzUsageFlux = fluxVect(usageEnz,:);
0053 usageEnz = regexprep(ecModel.rxns(usageEnz),'usage_prot_','');
0054 usageEnz = regexprep(usageEnz,'prot_pool_exchange','pool');
0055 end

Generated by m2html © 2005