Description of NetPoster

Home > BiKEGG > NetPoster.m

# NetPoster

## PURPOSE

NetPoster

## SYNOPSIS

function NetPoster(LineStrength,OverlapC,ColormapC,BackCol,CpdCol,inactiveCol)

## DESCRIPTION

     NetPoster
     is a subfunction of MapAdjuster for post-processing the
     customized metabolic maps created by NetDraw, and possesses a structure
     very similar to that of the NetDraw.

     Inputs:
     LineStrength: User defined of reactions' line width.
     OverlapC: Check if user wants to remove (0) or retain (1) overlapping
     reactions on the created map.
     ColormapC: Check if user wants to remove (1) or apply (0) color mapping.
     BackCol: Background color.
     CpdCol: Compounds' color.
     inactiveCol: Inactive reactions' color.

## CROSS-REFERENCE INFORMATION

This function calls:

- ArrowheadProcess ArrowheadProcess
- MapTrimmer MapTrimmer
- MapTrimmerF MapTrimmerF
- OverlapChecker OverlapChecker
- arrowhead arrowhead
- pixFill pixFill
- pixHover pixHover

This function is called by:

- MapAdjuster MapAdjuster(GUI)

## SOURCE CODE

    0001 function NetPoster(LineStrength,OverlapC,ColormapC,BackCol,CpdCol,inactiveCol)
    0002 % NetPoster
    0003 % is a subfunction of MapAdjuster for post-processing the
    0004 % customized metabolic maps created by NetDraw, and possesses a structure
    0005 % very similar to that of the NetDraw.
    0006 %
    0007 % Inputs:
    0008 % LineStrength: User defined of reactions' line width.
    0009 % OverlapC: Check if user wants to remove (0) or retain (1) overlapping
    0010 % reactions on the created map.
    0011 % ColormapC: Check if user wants to remove (1) or apply (0) color mapping.
    0012 % BackCol: Background color.
    0013 % CpdCol: Compounds' color.
    0014 % inactiveCol: Inactive reactions' color.
    0015
    0016 % O. Jamialahmadi
    0017 % TMU, Chem. Eng. Dept., Biotech. Group
    0018 % July 2016
    0019
    0020
    0021 PostData = getappdata(0,'PostData');
    0022 h1 = getappdata(0,'ParentAx');
    0023 H1 = getappdata(0,'ParentFig');
    0024 delete(h1); delete(H1);
    0025 % Create new canvas -------------------------------------------------------
    0026 H1 = figure;
    0027 h1 = axes;
    0028 set(H1,'position',get(0,'screensize'));
    0029 set(h1,'position',[0,0,1,1],'xtick',[],'ytick',[]);
    0030 set(H1,'toolbar','figure');
    0031 set(H1,'menubar','figure');
    0032 setappdata(0,'ParentAx',h1); setappdata(0,'ParentFig',H1);
    0033 % Set Background color ----------------------------------------------------
    0034 if isempty(BackCol) || numel(BackCol) == 1
    0035     BackColr = [0.8,0.992,0.8];
    0036 else
    0037     BackColr = BackCol;
    0038 end
    0039 I = ones(PostData.max_y-PostData.min_y+50,...
    0040     PostData.max_x-PostData.min_x+50,3);
    0041 I(:,:,1) = I(:,:,1).*BackColr(1);
    0042 I(:,:,2) = I(:,:,2).*BackColr(2);
    0043 I(:,:,3) = I(:,:,3).*BackColr(3);
    0044 % Set inactive rxns -------------------------------------------------------
    0045 Allx4Arrow = PostData.Allx4Arrow; Ally4Arrow = PostData.Ally4Arrow;
    0046 if isempty(inactiveCol) || numel(inactiveCol) == 1
    0047     Flaginactive = [0 0 0];
    0048 else
    0049     Flaginactive = inactiveCol;
    0050 end
    0051 for i1 = 1:numel(Allx4Arrow)
    0052     I = pixFill(I,Allx4Arrow{i1},Ally4Arrow{i1},LineStrength,Flaginactive);
    0053 end
    0054 % Flux overlay ------------------------------------------------------------
    0055 field_intsect_overlay = PostData.field_intsect_overlay;
    0056 field_intsect = PostData.field_intsect;
    0057 Cm=jet(numel(field_intsect_overlay)); flx = PostData.flx;
    0058 flx_abs = abs(flx);
    0059 for k=PostData.k
    0060     McmCollect = zeros(size(flx,1),3);
    0061     if ~ColormapC
    0062         for m=1:size(flx,1)
    0063             % Normalize colors and insertion into enzyme boxes
    0064             flxMax=max(abs(flx(:)));
    0065             flxMin=min(abs(flx(:)));
    0066             if flxMax==flxMin % One row (i.e. for 1 rxn)
    0067                 flxMax=max(abs(flx(:)));
    0068                 flxMin=min(abs(flx(:)));
    0069             end
    0070             flxSl=(size(Cm,1)-1)./(flxMax-flxMin);
    0071             if isinf(flxSl) % in case of flxMax == flxMin
    0072                 flxSl = 1e15.*(size(Cm,1)-1);
    0073             end
    0074             Mcm=ceil((flx_abs(m,k)-flxMax).*flxSl+size(Cm,1));
    0075
    0076             I = pixFill(I,PostData.ArX{m},PostData.ArY{m},LineStrength,...
    0077                 [Cm(Mcm,1) Cm(Mcm,2) Cm(Mcm,3)]);
    0078             McmCollect(m,:) = [Cm(Mcm,1) Cm(Mcm,2) Cm(Mcm,3)];
    0079             clear pixx pixy
    0080         end
    0081     else % No color for flux carrying rxns
    0082         for m=1:size(flx,1)
    0083             I = pixFill(I,PostData.ArX{m},PostData.ArY{m},LineStrength,...
    0084                 Flaginactive);
    0085             McmCollect(m,:) = Flaginactive;
    0086         end
    0087     end
    0088     ArX = PostData.ArX; ArY = PostData.ArY; OverlapData = PostData.OverlapData;
    0089     min_x = PostData.min_x; min_y = PostData.min_y; basemap = PostData.basemap;
    0090     RefOverlapData = PostData.RefOverlapData;
    0091     if OverlapC
    0092         [I,ArXo,ArYo,ArrowChek,RxnId] = OverlapChecker(I,ArX,ArY,OverlapData,...
    0093         flx(:,k),McmCollect,field_intsect_overlay,LineStrength);
    0094         [ArrowX,ArrowY,Cntrs] = ArrowheadProcess(Allx4Arrow,Ally4Arrow,...
    0095             min_x,min_y,field_intsect,basemap,RxnId,RefOverlapData,'bigg',field_intsect_overlay);
    0096         I = MapTrimmer(I,ArrowX,ArrowY,Cntrs,Allx4Arrow,Ally4Arrow,LineStrength,BackColr);
    0097         [ArrowX1,ArrowY1,Cntrs1,Director] = ArrowheadProcess(ArXo,ArYo,min_x,min_y,...
    0098             field_intsect_overlay,basemap,[],[],'bigg',[]);
    0099         I = MapTrimmerF(I,ArrowX1,ArrowY1,Cntrs1,ArXo,ArYo,RxnId,field_intsect_overlay,LineStrength,BackColr);
    0100     else
    0101         [ArrowX,ArrowY,Cntrs] = ArrowheadProcess(Allx4Arrow,Ally4Arrow,...
    0102             min_x,min_y,field_intsect,basemap,[],[],'bigg',[]);
    0103         I = MapTrimmer(I,ArrowX,ArrowY,Cntrs,Allx4Arrow,Ally4Arrow,LineStrength,BackColr);
    0104         [ArrowX1,ArrowY1,~,Director] = ArrowheadProcess(ArX,ArY,min_x,min_y,...
    0105             field_intsect_overlay,basemap,[],[],'bigg',[]);
    0106     end
    0107     % Compounds overlay ---------------------------------------------------
    0108     if isempty(CpdCol) || numel(CpdCol) == 1
    0109         CpdColr = [0,1,0.498];
    0110     else
    0111         CpdColr = CpdCol;
    0112     end
    0113     for i1 = 1:size(PostData.cpdxy,1)
    0114         cc1 = PostData.x_cpd(i1)-PostData.cpdxy(i1,4)*0.7:PostData.x_cpd(i1)+PostData.cpdxy(i1,4)*0.7;
    0115         cc2 = PostData.y_cpd(i1)-PostData.cpdxy(i1,4)*0.7:PostData.y_cpd(i1)+PostData.cpdxy(i1,4)*0.7;
    0116         [x,y] = meshgrid(cc1,cc2);
    0117         f1= ((x-PostData.x_cpd(i1)).^2+(y-PostData.y_cpd(i1)).^2) <=(PostData.cpdxy(i1,4)*0.7)^2 ;
    0118         f2= ((x-PostData.x_cpd(i1)).^2+(y-PostData.y_cpd(i1)).^2) <=(PostData.cpdxy(i1,4)*0.55)^2 ;
    0119         x1 = x(f1); y1= y(f1);x1=round(x1); y1=round(y1);
    0120         x2 = x(f2); y2= y(f2); x2=round(x2); y2=round(y2);
    0121         x1(~y1) = []; y1(~y1) = [];
    0122         x2(~y2) = []; y2(~y2) = [];
    0123         for i2 = 1:numel(x1)
    0124             I(y1(i2),x1(i2),1) = 0.502;
    0125             I(y1(i2),x1(i2),2) = 0.502;
    0126             I(y1(i2),x1(i2),3) = 0;
    0127         end
    0128         for i2 = 1:numel(x2)
    0129             I(y2(i2),x2(i2),1) = CpdColr(1);
    0130             I(y2(i2),x2(i2),2) = CpdColr(2);
    0131             I(y2(i2),x2(i2),3) = CpdColr(3);
    0132         end
    0133         clear f1 x1 x2 cc1 cc2
    0134     end
    0135     % Show map ------------------------------------------------------------
    0136     imshow(I,'InitialMagnification', 'fit','Parent',h1);
    0137     % Show time-series values on the corresponding image
    0138 %     TimePropUDF ('One',PostData.TextFont,PostData.TimeUnit,PostData.mTime,k,h1)
    0139     arrowhead(ArrowX,ArrowY,[],Flaginactive,LineStrength/2,[]);
    0140     flxDirect.D = Director; flxDirect.F = flx(:,k);
    0141     if OverlapC
    0142         arrowhead(ArrowX1,ArrowY1,ArrowChek,McmCollect,LineStrength/2,flxDirect);
    0143     else
    0144         arrowhead(ArrowX1,ArrowY1,[],McmCollect,LineStrength/2,flxDirect);
    0145     end
    0146
    0147     Mdl = getappdata(0,'Mdl');
    0148     Uni = load(which('UniModelKEGG.mat'));
    0149     K = Uni.B2Kegg.K; K1 = Mdl.B2Kegg.K;
    0150     B = Uni.B2Kegg.B; B1 = Mdl.B2Kegg.B;
    0151     clear Uni
    0152     HoverUs.K = K1; HoverUs.B = B1;
    0153     HoverUs.R = PostData.OverlayRxnsIDs; HoverUs.P = field_intsect_overlay';
    0154     HoverUs.CR = PostData.ConOverlayRxnID;
    0155     HoverAll.R = PostData.rxnCds; HoverAll.P = field_intsect;
    0156     HoverAll.K = K; HoverAll.B = B;
    0157     pixHover(PostData.x_cpd,PostData.y_cpd,0.7*PostData.cpdxy(1,4),PostData.cpdnames...
    0158         ,PostData.Allx,PostData.Ally,...
    0159         HoverAll,HoverUs,abs(flx(:,k)),h1,H1)
    0160     % Show colorbar--------------------------------------------------------
    0161     if ~ColormapC
    0162         flxstr=linspace(flxMin,flxMax,7);
    0163         flxstr1=cell(numel(flxstr),1);
    0164         for ir=1:numel(flxstr)
    0165             flxstr1{ir,1}=num2str(flxstr(ir),2);
    0166         end
    0167         ch = colorbar('peer',h1);
    0168         set(ch,'yticklabel',flxstr1)
    0169     end
    0170 end