deleteModelGenes

PURPOSE ^

deleteModelGenes Delete one or more genes and constrain the reactions

SYNOPSIS ^

function [model,hasEffect,constrRxnNames,deletedGenes] = deleteModelGenes(model,geneList,downRegFraction)

DESCRIPTION ^

deleteModelGenes Delete one or more genes and constrain the reactions
affected to zero and appends '_deleted' to the gene(s)

 [model,hasEffect,constrRxnNames,deletedGenes] =
 deleteModelGenes(model,geneList,downRegFraction)

INPUT
 model             COBRA model with the appropriate constrains for a 
                   particular condition

OPTIONA INPUTS
 geneList          List of genes to be deleted (Default =  all genes in
                   model)
 downRegFraction   Fraction of the original bounds that the reactions
                   corresponding to downregulated genes will be assigned
                   (Default = 0 corresponding to a full deletion)

OUTPUTS
 model             COBRA model with the selected genes deleted
 hasEffect         True if the gene deletion has an effect on the model
 constrRxnNames    Reactions that are associated to the genes in geneList
 deletedGenes      The list of genes removed from the model.  

%%%% FIXED
 Note that deleting a set of genes one after another has a different effect than deleting them all at once.
 This is because of the case where a reaction has boolean string (geneA or geneB).  
 Deleting geneA will not turn off the reaction and subsequently deleting geneB will also not delete the reaction.
 It is therefore better to delete a list of genes at once.  -Jan Schellenberger (4/07/08)
%%%%

 Markus Herrgard 8/28/06
 Josh Lerman and Richard Que 04/21/10 - Added an error if non-existent gene.
 Richard Que (04/22/2010) - '_deleted' is appended to deleted gene names

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [model,hasEffect,constrRxnNames,deletedGenes] = deleteModelGenes(model,geneList,downRegFraction)
0002 %deleteModelGenes Delete one or more genes and constrain the reactions
0003 %affected to zero and appends '_deleted' to the gene(s)
0004 %
0005 % [model,hasEffect,constrRxnNames,deletedGenes] =
0006 % deleteModelGenes(model,geneList,downRegFraction)
0007 %
0008 %INPUT
0009 % model             COBRA model with the appropriate constrains for a
0010 %                   particular condition
0011 %
0012 %OPTIONA INPUTS
0013 % geneList          List of genes to be deleted (Default =  all genes in
0014 %                   model)
0015 % downRegFraction   Fraction of the original bounds that the reactions
0016 %                   corresponding to downregulated genes will be assigned
0017 %                   (Default = 0 corresponding to a full deletion)
0018 %
0019 %OUTPUTS
0020 % model             COBRA model with the selected genes deleted
0021 % hasEffect         True if the gene deletion has an effect on the model
0022 % constrRxnNames    Reactions that are associated to the genes in geneList
0023 % deletedGenes      The list of genes removed from the model.
0024 %
0025 %%%%% FIXED
0026 % Note that deleting a set of genes one after another has a different effect than deleting them all at once.
0027 % This is because of the case where a reaction has boolean string (geneA or geneB).
0028 % Deleting geneA will not turn off the reaction and subsequently deleting geneB will also not delete the reaction.
0029 % It is therefore better to delete a list of genes at once.  -Jan Schellenberger (4/07/08)
0030 %%%%%
0031 %
0032 % Markus Herrgard 8/28/06
0033 % Josh Lerman and Richard Que 04/21/10 - Added an error if non-existent gene.
0034 % Richard Que (04/22/2010) - '_deleted' is appended to deleted gene names
0035 
0036 if (nargin < 2)
0037     geneList = model.genes;
0038 end
0039 
0040 if (nargin < 3)
0041     downRegFraction = 0;
0042 end
0043 
0044 if (~iscell(geneList))
0045     geneName = geneList;
0046     clear geneList;
0047     geneList{1} = geneName;
0048 end
0049 
0050 if (~isfield(model,'genes'))
0051     error('Gene-reaction associations not included with the model');
0052 end
0053 
0054 hasEffect = false;
0055 constrRxnNames = {};
0056 %deletedGenes is a cell array for returning the genes that are
0057 %eliminated from the model.
0058 deletedGenes = {};
0059 
0060 
0061 
0062 % Find gene indices in model
0063 [isInModel,geneInd] = ismember(geneList,regexprep(model.genes,'_deleted',''));
0064 
0065 if (all(isInModel))
0066 
0067   %If there are any zero elements in geneInd remove them from the
0068   %geneList and the geneInd because they correspond to genes that
0069   %are not in the model.
0070   deletedGenes = geneList( find( geneInd ) );
0071   geneInd = geneInd( find( geneInd ) );
0072   
0073   %mark genes for deletion
0074   model.genes(geneInd) = strcat(model.genes(geneInd),'_deleted');
0075   
0076     % Find rxns associated with this gene
0077     rxnInd = find(any(model.rxnGeneMat(:,geneInd),2));
0078     if (~isempty(rxnInd))
0079         x = true(size(model.genes));
0080         % set genes marked "_deleted" to false
0081         x(~cellfun('isempty',(regexp(model.genes,'_deleted')))) = false;
0082         constrainRxn = false(length(rxnInd),1);
0083         % Figure out if any of the reaction states is changed
0084         for j = 1:length(rxnInd)
0085             if (~eval(model.rules{rxnInd(j)}))
0086                 constrainRxn(j) = true;
0087             end
0088         end
0089         % Constrain flux through the reactions associated with these genes
0090         if (any(constrainRxn))
0091             constrRxnNames = model.rxns(rxnInd(constrainRxn));
0092             if (nargin > 2)
0093                 model = changeRxnBounds(model,constrRxnNames,downRegFraction*model.lb(findRxnIDs(model,constrRxnNames)),'l');
0094                 model = changeRxnBounds(model,constrRxnNames,downRegFraction*model.ub(findRxnIDs(model,constrRxnNames)),'u');
0095             else
0096                 % Full deletion
0097                 model = changeRxnBounds(model,constrRxnNames,0,'b');
0098             end
0099             hasEffect = true;
0100         end
0101     end
0102 else
0103     error(['Gene',' ',geneList{~isInModel}, ' not in model!']);
0104 end
0105

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003