setMapOptions

PURPOSE ^

setMapOptions set the values of the options fields

SYNOPSIS ^

function options = setMapOptions(options, map, varargin)

DESCRIPTION ^

setMapOptions set the values of the options fields

 options = setMapOptions(options, map, model,'property name',value,...)
 options = setMapOptions(options, map, 'property name',value,...)

INPUT
 options           The options whose properties are to be set.

 map               The map corresponding to the options.  
 


OPTIONAL INPUT

 model             The model which the values of the properties are
                   corresponding to.
 property          Name of any field of the options to be set.
 value             The corresponding value of the property.

 The function returns an options with it fields set to the values passed
 to it.
 The input arguments can be passed in two manner:
       If passed with no map and model it is assumed that the values are
       already processed and corresponds to the map structure so they are
       simply assigned to the fields of options.

       If there is map and model passed the values will be checked to see
       if they are ready to be assigned or they need more prosseccing by
       matching up the map struct with model's.

 options
   nodeColor           A nx3 matrix corresponds to the color of the metabolite
                       nodes on the map. This color scale represent the
                       concentration of the metabolites.
   edgeColor           A nx3 matrix corresponds to the color of the rxn edges
                       on the map. This color scale represent the
                       fluxes of the reactions.
   edgeArrowColor      A nx3 matrix corresponding to the color of the rxn
                       edges arrowheads on the map.
   nodeWeight          A nx1 matrix corresponds to the diameter of the nodes.
                       it is representative of the confidance of the
                       concentrations.
   edgeWeight          A nx1 matrix corresponds to the width of the edges.
                       it is representative of the confidance of the
                       fluxes.
   textColor           A nx3 matrix corresponds to the color of the
                       metabolites labels on the map.
   textSize            A nx1 matrix corresponds to the size of the
                       metabolites labels on the map.
   fileName            Name of output file
   lb                  Lower limit to round smaller values up to.
   ub                  Upper limit to round larger values down to.
   colorScale          Colormap (Default = cool(100))

                       drawFlux options
   zeroFluxWidth       Width of arrows of reactions which carry zero flux.
                       (Default = edgeWeight)
   zeroFluxColor       Color of arrows of reactions which carry zero flux.
                       (Default = edgeColor set by drawFlux)
   rxnDirFlag          Scale arrowheads based on flux directionality.
                       (Default = false)
   rxnDirMultiplier    Scaling value of arrows denoting flux direction.
                       (Default = 2.5) (only used if rxnDirFlag = true)

                       drawFluxVariability options
   bidircolor          Bi-directional flux color (Default = [0 255 0])
   unidirirrcolor      Irreversible reaction color 
                       (Default = [0 0 255])
   unidirfwdcolor      Only forward direction flux color
                       (Default = [255 0 255])
   unidirrevcolor      Only reverse direction flux color
                       (Default = [0 255 255])

OUTPUT
 options       Options structure

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function options = setMapOptions(options, map, varargin)
0002 %setMapOptions set the values of the options fields
0003 %
0004 % options = setMapOptions(options, map, model,'property name',value,...)
0005 % options = setMapOptions(options, map, 'property name',value,...)
0006 %
0007 %INPUT
0008 % options           The options whose properties are to be set.
0009 %
0010 % map               The map corresponding to the options.
0011 %
0012 %
0013 %
0014 %OPTIONAL INPUT
0015 %
0016 % model             The model which the values of the properties are
0017 %                   corresponding to.
0018 % property          Name of any field of the options to be set.
0019 % value             The corresponding value of the property.
0020 %
0021 % The function returns an options with it fields set to the values passed
0022 % to it.
0023 % The input arguments can be passed in two manner:
0024 %       If passed with no map and model it is assumed that the values are
0025 %       already processed and corresponds to the map structure so they are
0026 %       simply assigned to the fields of options.
0027 %
0028 %       If there is map and model passed the values will be checked to see
0029 %       if they are ready to be assigned or they need more prosseccing by
0030 %       matching up the map struct with model's.
0031 %
0032 % options
0033 %   nodeColor           A nx3 matrix corresponds to the color of the metabolite
0034 %                       nodes on the map. This color scale represent the
0035 %                       concentration of the metabolites.
0036 %   edgeColor           A nx3 matrix corresponds to the color of the rxn edges
0037 %                       on the map. This color scale represent the
0038 %                       fluxes of the reactions.
0039 %   edgeArrowColor      A nx3 matrix corresponding to the color of the rxn
0040 %                       edges arrowheads on the map.
0041 %   nodeWeight          A nx1 matrix corresponds to the diameter of the nodes.
0042 %                       it is representative of the confidance of the
0043 %                       concentrations.
0044 %   edgeWeight          A nx1 matrix corresponds to the width of the edges.
0045 %                       it is representative of the confidance of the
0046 %                       fluxes.
0047 %   textColor           A nx3 matrix corresponds to the color of the
0048 %                       metabolites labels on the map.
0049 %   textSize            A nx1 matrix corresponds to the size of the
0050 %                       metabolites labels on the map.
0051 %   fileName            Name of output file
0052 %   lb                  Lower limit to round smaller values up to.
0053 %   ub                  Upper limit to round larger values down to.
0054 %   colorScale          Colormap (Default = cool(100))
0055 %
0056 %                       drawFlux options
0057 %   zeroFluxWidth       Width of arrows of reactions which carry zero flux.
0058 %                       (Default = edgeWeight)
0059 %   zeroFluxColor       Color of arrows of reactions which carry zero flux.
0060 %                       (Default = edgeColor set by drawFlux)
0061 %   rxnDirFlag          Scale arrowheads based on flux directionality.
0062 %                       (Default = false)
0063 %   rxnDirMultiplier    Scaling value of arrows denoting flux direction.
0064 %                       (Default = 2.5) (only used if rxnDirFlag = true)
0065 %
0066 %                       drawFluxVariability options
0067 %   bidircolor          Bi-directional flux color (Default = [0 255 0])
0068 %   unidirirrcolor      Irreversible reaction color
0069 %                       (Default = [0 0 255])
0070 %   unidirfwdcolor      Only forward direction flux color
0071 %                       (Default = [255 0 255])
0072 %   unidirrevcolor      Only reverse direction flux color
0073 %                       (Default = [0 255 255])
0074 %
0075 %OUTPUT
0076 % options       Options structure
0077 
0078 nNodes = size(map.molName,1);
0079 nEdges = size(map.connectionName,1);
0080 % if map and model are passed the data will be processed before assignment
0081 if ~isstr(varargin{1}) && isstr(varargin{2})
0082     model = varargin{1};
0083     for i = 2:2:size(varargin,2)
0084         switch lower(varargin{i})
0085             case 'nodecolor'
0086                 conc = cell2mat(varargin(i+1));
0087                 if size(conc,1)==1
0088                     conc = repmat(conc,nNodes,1);
0089                 elseif all(size(conc) == [nNodes 3])
0090                     %directly assign to options struct
0091                     options.nodeColor = conc;
0092                     continue;
0093                 end
0094                 if(size(conc,2)==1)
0095                     color = getColorFromColorScale(conc);
0096                  elseif(size(conc,2)== 3)   %colors maped
0097                      color = conc;
0098                 else %wrong size
0099                     warning('Invalid size for nodeColor entry');
0100                     continue;
0101                 end
0102                 %   match map with model and find out the missing parts
0103                 if isfield(model,'metNames')
0104                     mapMol = 'molName';
0105                     modelMol = 'metNames';
0106                 else
0107                     mapMol = 'molAbbreviation';
0108                     modelMol = 'mets';
0109                 end
0110                 %generate default color vector
0111                 options.nodeColor = ones(nNodes,3)*191;
0112                 %map known concentrations
0113                 [known index] = ismember(map.(mapMol),model.(modelMol));
0114                 index = index(index~=0);
0115                 options.nodeColor(known,:) = color(index,:);
0116                 %Clear variables
0117                 clear('conc','mapMol','modelMol','color','known','index');
0118             case 'edgecolor'
0119                 flux = cell2mat(varargin(i+1));
0120                 if size(flux,1)==1
0121                     flux = repmat(flux,nEdges,1);
0122                 elseif all(size(flux) == [nEdges 3])
0123                     %directly assign to options struct
0124                     options.edgeColor = flux;
0125                     continue
0126                 elseif size(flux) ~= length(model.rxns)
0127                     warning('Invalid size for edgeColor entry');
0128                     continue;
0129                 end
0130                 % Map to color if flux vector
0131                 if(size(flux,2)==1)
0132                     color = getColorFromColorScale(flux);
0133                  elseif(size(flux,2)== 3)   %colors maped
0134                      color = flux;
0135                 else %wrong size
0136                     warning('Invalid size for edgeColor entry');
0137                     continue;
0138                 end
0139                 % Generate default color vector
0140                 options.edgeColor = ones(nEdges,3)*191;
0141                 %map known connections
0142                 [known index] = ismember(map.connectionAbb,model.rxns);
0143                 index = index(index~=0);
0144                 options.edgeColor(known,:) = color(index,:);
0145                 %Clear variables
0146                 clear('flux','color','known','index');
0147             case 'edgearrowcolor'
0148                 arrowColor = cell2mat(varargin(i+1));
0149                 if size(arrowColor,1)==1
0150                     arrowColor = repmat(arrowColor,nEdges,1);
0151                 end
0152                 if size(arrowColor,2)~=3
0153                     warning('Invalid size for arrowColor entry');
0154                     continue
0155                 end
0156                 options.edgeArrowColor = arrowColor;
0157                 %Clear variables
0158                 clear('arrowColor');
0159             case 'nodeweight'
0160                 nodeWeight = cell2mat(varargin(i+1));
0161                 if size(nodeWeight,1)==1
0162                     nodeWeight = repmat(nodeWeight,nNodes,1);
0163                     options.nodeWeight = nodeWeight;
0164                 elseif size(nodeWeight,1)==length(model.mets) %assumes concentration confidence
0165                     %Match map with model and find out the missing parts
0166                     if isfield(model,'metNames')
0167                         mapMol = 'molName';
0168                         modelMol = 'metNames';
0169                     else
0170                         mapMol = 'molAbbreviation';
0171                         modelMol = 'mets';
0172                     end
0173                     %scale
0174                     if max(nodeWeight)~=0, nodeWeight = round(24*nodeWeight/max(nodeWeight))+1; end
0175                     %default node weight
0176                     options.nodeWeight = ones(nNodes,1)*25;
0177                     %Map to nodes
0178                     [known index] = ismember(map.(mapMol),model.(modelMol));
0179                     index = index(index~=0);
0180                     options.nodeWeight(known) = nodeWeight(index);
0181                 elseif size(nodeWeight,1)==nNodes
0182                     %directly assign to options struct
0183                     options.nodeWeight=nodeWeight;
0184                 else %wrong size
0185                     warning('Invalid size for nodeWeight entry');
0186                 end
0187                 if ~isfield(options,'nodeWeightSecondary')
0188                     options.nodeWeightSecondary = options.nodeWeight*15/25;
0189                 end
0190                 %Clear variables
0191                 clear('nodeWeight','mapMol','modelMol','known','index');
0192             case 'nodeweightsecondary'
0193                  nodeWeight = cell2mat(varargin(i+1));
0194                 if size(nodeWeight,1)==1
0195                     nodeWeight = repmat(nodeWeight,nNodes,1);
0196                     options.nodeWeightSecondary = nodeWeight;
0197                 elseif size(nodeWeight,1)==length(model.mets) %assumes concentration confidence
0198                     %Match map with model and find out the missing parts
0199                     if isfield(model,'metNames')
0200                         mapMol = 'molName';
0201                         modelMol = 'metNames';
0202                     else
0203                         mapMol = 'molAbbreviation';
0204                         modelMol = 'mets';
0205                     end
0206                     %scale
0207                     if max(nodeWeight)~=0, nodeWeight = round(24*nodeWeight/max(nodeWeight))+1; end
0208                     %default node weight
0209                     options.nodeWeightSecondary = ones(nNodes,1)*25;
0210                     %Map to nodes
0211                     [known index] = ismember(map.(mapMol),model.(modelMol));
0212                     index = index(index~=0);
0213                     options.nodeWeightSecondary(known) = nodeWeight(index);
0214                 elseif size(nodeWeight,1)==nNodes
0215                     %directly assign to options struct
0216                     options.nodeWeightSecondary=nodeWeight;
0217                 else %wrong size
0218                     warning('Invalid size for nodeWeight entry');
0219                 end
0220                 %Clear variables
0221                 clear('nodeWeight','mapMol','modelMol','known','index');
0222             case 'edgeweight'
0223                 edgeWeight = cell2mat(varargin(i+1));
0224                 if size(edgeWeight,1) == 1
0225                     %set edgeWeight for all reactions
0226                     options.edgeWeight = repmat(edgeWeight,nEdges,1);
0227                 elseif size(edgeWeight,1) == length(model.rxns)
0228                     %Assume flux confidence
0229                     %scale
0230                     if max(edgeWeight)~=0, edgeWeight = round(4*edgeWeight/max(edgeWeight))+1; end
0231                     %default edge weight
0232                     options.edgeWeight = ones(nEdges,1)*4;
0233                     %map known connections
0234                     [known index] = ismember(map.connectionAbb,model.rxns);
0235                     index = index(index~=0);
0236                     options.edgeWeight(known) = edgeWeight(index);
0237                 elseif size(edgeWeight,1) == nEdges
0238                     %Directly assign to options struct
0239                     options.edgeWeight = edgeWeight;
0240                 else
0241                     warning('invalid size for nodeWeight entry');
0242                 end
0243                 %Clear variables
0244                 clear('edgeWeight','known','index');
0245             case 'textsize'
0246                 textSize = cell2mat(varargin(i+1));
0247                 nNodes = size(map.molName,1);
0248                 if length(textSize)==1
0249                     textSize = ones(nNodes,1)*textSize;
0250                 end
0251                 for j = 1:nNodes
0252                     str = map.molName(j);
0253                     index = find(strcmp(model.metNames(:),str));
0254                     if isempty(index)
0255                         options.textSize(j,1) = 8;
0256                     elseif length(index) == 1
0257                         options.textSize(j,1) = textSize(index);
0258                     else
0259                         options.textSize(j,1) = textSize(index(1));
0260                     end
0261                 end
0262             case 'textcolor'
0263                 tColor = cell2mat(varargin(i+1));
0264                 nNodes = size(map.molName,1);
0265                 if size(tColor,1)==1
0266                     tColor = repmat(tColor,nNodes,1);
0267                 end
0268                 for j = 1:nNodes
0269                     str = map.molName(j);
0270                     index = find(strcmp(model.metNames(:),str));
0271                     if isempty(index)
0272                         options.textColor(j,:) = [0 0 0];
0273                     elseif length(index) == 1
0274                         options.textColor(j,:)= tColor(index,:);
0275                     else
0276                         options.textColor(j,:)= tColor(index(1),:);
0277                     end
0278                 end
0279             case 'othertextcolor'
0280                 otColor = cell2mat(varargin(i+1));
0281                 nNodes = size(map.molName,1);
0282                 if size(ltColor,1)==1
0283                     otColor = repmat(otColor,nNodes,1);
0284                 end
0285                 options.otherTextColor = otColor;
0286             case 'lb', options.lb = varargin{i+1};
0287             case 'ub', options.ub = varargin{i+1};
0288             case 'scaletype', options.scaleType = varargin{i+1};
0289             case 'colorscale', options.colorScale = varargin{i+1};
0290             case 'zerofluxwidth', options.zeroFluxWidth = varargin{i+1};
0291             case 'zerofluxcolor', options.zeroFluxColor = varargin{i+1};
0292             case 'zeroconccolor', options.zeroConcColor = varargin{i+1};
0293             case 'filename', options.fileName = varargin{i+1};
0294             case 'rxndirflag', options.rxnDir = varargin{i+1};
0295             case 'rxndirmultiplier', options.rxnDirMultiplier = varargin{i+1};
0296             case 'bidircolor', options.fluxVarColor.biDirColor = varargin{i+1};
0297             case 'unidirirrcolor', options.fluxVarColor.uniDirIrrColor = varargin{i+1};
0298             case 'unidirfwdcolor', options.fluxVarColor.uniDirFwdColor = varargin{i+1};
0299             case 'unidirrevcolor', options.fluxVarColor.uniDirRevColor = varargin{i+1};
0300             otherwise
0301                 if isstr(varargin{i})       % The property doesn't match any of the feilds
0302                     warning('Unknown Property: "%s"',varargin{i});
0303                 end
0304         end
0305     end
0306     
0307     % if model is not passed.
0308 else
0309     for i = 1:2:size(varargin,2)
0310         switch lower(varargin{i})
0311             case 'nodeweight', options.nodeWeight = cell2mat(varargin(i+1));
0312             case 'nodecolor', options.nodeColor = cell2mat(varargin(i+1));
0313             case 'edgeweight', options.edgeWeight = cell2mat(varargin(i+1));
0314             case 'edgecolor', options.edgeColor = cell2mat(varargin(i+1));
0315             case 'edgearrowcolor', options.edgeArrowColor = cell2mat(varargin(i+1));
0316             case 'textsize', options.textSize = cell2mat(varargin(i+1));
0317             case 'textcolor', options.textColor = cell2mat(varargin(i+1));
0318             case 'othertextsize', options.otherTextSize = cell2mat(varargin(i+1));
0319             case 'othertextcolor', options.otherTextColor = cell2mat(varargin(i+1));
0320             case 'lb', options.lb = varargin{i+1};
0321             case 'ub', options.ub = varargin{i+1};
0322             case 'scaletype', options.scaleType = varargin{i+1};
0323             case 'colorscale', options.colorScale = varargin{i+1};
0324             case 'zerofluxwidth', options.zeroFluxWidth = varargin{i+1};
0325             case 'zerofluxcolor', options.zeroFluxColor = varargin{i+1};
0326             case 'zeroconccolor', options.zeroConcColor = varargin{i+1};
0327             case 'filename', options.fileName = varargin{i+1};
0328             case 'rxndirflag', options.rxnDirFlag = varargin{i+1};
0329             case 'rxndirmultiplier', options.rxnDirMultipler = varargin{i+1};
0330             case 'bidircolor', options.fluxVarColor.biDirColor = varargin{i+1};
0331             case 'unidirirrcolor', options.fluxVarColor.uniDirIrrColor = varargin{i+1};
0332             case 'unidirfwdcolor', options.fluxVarColor.uniDirFwdColor = varargin{i+1};
0333             case 'unidirrevcolor', options.fluxVarColor.uniDirRevColor = varargin{i+1};
0334             otherwise
0335                 if isstr(varargin{i})        % The property doesn't match any of the feilds
0336                     warning('Unknown Property: "%s"',varargin{i});
0337                 end
0338         end
0339     end
0340 end

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