Description of flx2col

Home > BiKEGG > flx2col.m

# flx2col

## PURPOSE

flx2col

## SYNOPSIS

function I = flx2col(BoxCol,flx,Cm,I,k,flxMax,flxMin,m,idx,idw,Tempx,Thresh)

## DESCRIPTION

     flx2col
     Performs color mapping for caculated flux values and normalizes them based on
     maximum and minimum flux values in the input data.
     This function uses following inputs:
     1- BoxCol: RGB code entered by user for background color of each box
     2- flx : Contains flux values in form of:
           2-1 A 2D matrix, in which each column represents flux values for
               each state of one certain species/model (i.e. dynamic state
               of a certain model extracted from COBRA Toolbox). In this
               situation flx may contain various columns, indicating different
               circumstances of a certain species.
           2-2 A 2D matrix, in which each column represents flux valuse for
               each state of two different species/models (similarly, from
               COBRA Toolbox). In this situation, if a dynamic comparison
               between two species/models is performed, the number of flx
               columns must be even.
           2-3 A column vector. This situation is similar to case 1-1, but in
               static state.
     3- Cm : A colormap based on MATLAB built-in colormaps.
     4- I : The output of imread, containing RGB values of KEGG map pixels.
     5- k, m : Column and row indices, respectively.
     6- idx : Coordinates of each enzyme box on a KEGG map image, extracted
              from corresponding KGML file
     7- idw : Width of each box corresponding to idx, extracted from KGML
              file
     8- Tempx : Indicates the height of each box which should be colored
     9- Thresh: Threshold for each flux value, which lower than this threshold
                the box will be left blank, suggesting that the flx value is
                near zero.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- KeggDraw KeggDraw

## SOURCE CODE

    0001 function I = flx2col(BoxCol,flx,Cm,I,k,flxMax,flxMin,m,idx,idw,Tempx,Thresh)
    0002 % flx2col
    0003 % Performs color mapping for caculated flux values and normalizes them based on
    0004 % maximum and minimum flux values in the input data.
    0005 % This function uses following inputs:
    0006 % 1- BoxCol: RGB code entered by user for background color of each box
    0007 % 2- flx : Contains flux values in form of:
    0008 %       2-1 A 2D matrix, in which each column represents flux values for
    0009 %           each state of one certain species/model (i.e. dynamic state
    0010 %           of a certain model extracted from COBRA Toolbox). In this
    0011 %           situation flx may contain various columns, indicating different
    0012 %           circumstances of a certain species.
    0013 %       2-2 A 2D matrix, in which each column represents flux valuse for
    0014 %           each state of two different species/models (similarly, from
    0015 %           COBRA Toolbox). In this situation, if a dynamic comparison
    0016 %           between two species/models is performed, the number of flx
    0017 %           columns must be even.
    0018 %       2-3 A column vector. This situation is similar to case 1-1, but in
    0019 %           static state.
    0020 % 3- Cm : A colormap based on MATLAB built-in colormaps.
    0021 % 4- I : The output of imread, containing RGB values of KEGG map pixels.
    0022 % 5- k, m : Column and row indices, respectively.
    0023 % 6- idx : Coordinates of each enzyme box on a KEGG map image, extracted
    0024 %          from corresponding KGML file
    0025 % 7- idw : Width of each box corresponding to idx, extracted from KGML
    0026 %          file
    0027 % 8- Tempx : Indicates the height of each box which should be colored
    0028 % 9- Thresh: Threshold for each flux value, which lower than this threshold
    0029 %            the box will be left blank, suggesting that the flx value is
    0030 %            near zero.
    0031
    0032 % O. Jamialahmadi
    0033 % TMU, Chem. Eng. Dept., Biotech. Group
    0034 % Feb. 2015
    0035 % Modified: Lines 70-78 for zero carrying fluxes
    0036 % =========================================================================
    0037
    0038 % Normalization of color indices in Cm, Red for highest flux and
    0039 % Blue for lowest flux.
    0040 flx = abs(flx);
    0041 % flxMax=max(abs(flx(:,k)));
    0042 % flxMin=min(abs(flx(:,k)));
    0043 % if flxMax==flxMin % One row (i.e. for 1 rxn)
    0044 %     flxMax=max(abs(flx(m,:)));
    0045 %     flxMin=min(abs(flx(m,:)));
    0046 % end
    0047     flxSl=(size(Cm,1)-1)./(flxMax-flxMin);
    0048     if isinf(flxSl) % in case of flxMax == flxMin
    0049         flxSl = 1e15.*(size(Cm,1)-1);
    0050     end
    0051     Mcm=ceil((flx(m,k)-flxMax).*flxSl+size(Cm,1));
    0052     Tempy=(round(idx(m)+1):round(idx(m)+idw(m)-1));
    0053 if flxMax > 0
    0054     [x1,y1]=find(I(Tempx,Tempy,1)==0 & I(Tempx,Tempy,2)==0 & I(Tempx,Tempy,3)==0);
    0055     Tempy1=round(idx(m)+1):round(idx(m)+(flx(m,k)*idw(m))./flxMax-1);
    0056     Tempy2=round(idx(m)+(flx(m,k)*idw(m))./flxMax)-1:(idx(m)+idw(m)-1);
    0057     [x2,y2]=find(I(Tempx,Tempy1,1)==0 & I(Tempx,Tempy1,2)==0 & I(Tempx,Tempy1,3)==0);
    0058     I(Tempx,Tempy1,1)=Cm(Mcm,1);
    0059     I(Tempx,Tempy1,2)=Cm(Mcm,2);
    0060     I(Tempx,Tempy1,3)=Cm(Mcm,3);
    0061     if isempty(BoxCol) % Default color
    0062         I(Tempx,Tempy2,1)=169;%Dark gray for background of each box
    0063         I(Tempx,Tempy2,2)=169;
    0064         I(Tempx,Tempy2,3)=169;
    0065     else % User defined color
    0066         I(Tempx,Tempy2,1)=BoxCol(1);
    0067         I(Tempx,Tempy2,2)=BoxCol(2);
    0068         I(Tempx,Tempy2,3)=BoxCol(3);
    0069     end
    0070 end
    0071 if abs(flx(m,k))< Thresh % Threshold for considering a flux = 0
    0072     if isempty(BoxCol) % Default color
    0073         for g1=1:length(x1)
    0074             I(Tempx(x1(g1)),Tempy(y1(g1)),:)=169;
    0075         end
    0076     else
    0077         I(Tempx,Tempy,1)=BoxCol(1);
    0078         I(Tempx,Tempy,2)=BoxCol(2);
    0079         I(Tempx,Tempy,3)=BoxCol(3);
    0080     end
    0081 else
    0082     for g1=1:length(x2)
    0083         I(Tempx(x2(g1)),Tempy1(y2(g1)),1)=Cm(Mcm,1);
    0084         I(Tempx(x2(g1)),Tempy1(y2(g1)),2)=Cm(Mcm,2);
    0085         I(Tempx(x2(g1)),Tempy1(y2(g1)),3)=Cm(Mcm,3);
    0086     end
    0087 end
    0088 end