% This function computes the state transition matrix for the SBN of the T cell network % INPUT: % M: the stochastic sequence length, e.g. M = 1000; % p: the perturbation probability, e.g. p = 0.01; % when there is no perturbation, p = 0. % OUTPUT: % A: the computed state transition matrix. % Copyright @ The authors, 2012. function A = T_cell_SBN(M,p) tic %% initialization n = 12; % gene numbers gn = zeros(2, n,M); % initialization of the input vector L = ones(1,n); % the number of boolean functions for each gene C = ones(n,4); % the probability of the network %% description L(1) = 1; L(2) = 2; %assign value L(1) ...L(n) L(3) = 1; L(4) = 1; L(5) = 1; L(6) = 2; L(7) = 1; L(8) = 1; L(9) = 2; L(10) = 1; L(11) = 3; L(12) = 1; % the following are the probabilities for the multiplexers C(2,1) = 0.5; C(2,2) = 0.5; C(6,1) = 0.9375; C(6,2) = 0.0625; C(9,1) = 0.5; C(9,2) = 0.5; C(11,1) = 0.297; C(11,2) = 0.185; C(11,3) = 0.370; C(11,4) = 0.148; % assign value(0.2,0.5,0.3;) A = zeros(2^n, 2^n); % transition matrix input = zeros (1,2^n); input(1730)=1; for i = 1:2^n % all the input combination i for j = 1:n x = bitand(i-1,2^n-1); gn(1,j,:) = bitand(bitshift(x,-j+1),1); end %% generate sequences for the mux e2=randomsequence(1,M,500); e6=randomsequence(1,M, 200); e9=randomsequence(1,M,500); e110=zeros(1,1,M); e111=zeros(1,1,M); while sum(e110)~=148; jj=int32(1+(length(e110)-1)*rand); e110(jj)=1; e111(jj)=1; end while sum(e110)~=(148+370); ii = int32(1+(length(e110)-1)*rand); if e110(ii)~=1 e110(ii)=1; else end end while sum(e111)~=(148+185); ii = int32(1+(length(e111)-1)*rand); if or(e110(ii),e111(ii))~=1 e111(ii)=1; else end end %% SBN gup = zeros(1,n,M); gdown = zeros(1, n,M); gup(1,1,:) = not(gn(1,6,:)); f21 = or ( gn(1,3,:), gn(1,6,:) ); f22 = or ( gn(1,2,:), gn(1,6,:) ); gup(1,2,:) = mux2(f21,f22,e2); gup(1,3,:) = gn(1,2,:); gup(1,4,:) = not(gn(1,2,:)); gup(1,5,:) = not(gn(1,3,:)); f61 = and(not(gn(1,10,:)),or(or(gn(1,1,:),gn(1,9,:)),or(gn(1,11,:),gn(1,12,:)))); f62 = not(gn(1,10,:)); gup(1,6,:) = mux2(f61,f62,e6); gup(1,7,:) = gn(1,3,:); gup(1,8,:) = not(gn(1,5,:)); f91 = or(gn(1,4,:),gn(1,12,:)); f92 = or ( gn(1,5,:), gn(1,12,:) ); gup(1,9,:) = mux2(f91,f92,e9); gup(1,10,:) = gn(1,11,:); f111 = not(gn(1,6,:)); %%% 0.297 f112 = and(not(gn(1,6,:)), or ( gn(1,7,:), not(or(gn(1,4,:),gn(1,5,:))) )); %%% 0.185 f113 = and ( not(or(gn(1,4,:),gn(1,5,:))), not(gn(1,6,:)) ); %%% 0.37 f114 = and (not(gn(1,6,:)), gn(1,7,:));%0.148 gup(1,11,:) = mux4(f111,f112,f113,f114, e110, e111); gup(1,12,:) = not(gn(1,8,:)); %% perturbation ee1=randomsequence(1,M,M*p); ee2=randomsequence(1,M,M*p); ee3=randomsequence(1,M,M*p); ee4=randomsequence(1,M,M*p); ee5=randomsequence(1,M,M*p); ee6=randomsequence(1,M,M*p); ee7=randomsequence(1,M,M*p); ee8=randomsequence(1,M,M*p); ee9=randomsequence(1,M,M*p); ee10=randomsequence(1,M,M*p); ee11=randomsequence(1,M,M*p); ee12=randomsequence(1,M,M*p); gdown(1,1,:) = xor(gn(1,1,:),ee1); gdown(1,2,:) = xor(gn(1,2,:),ee2); gdown(1,3,:) = xor(gn(1,3,:),ee3); gdown(1,4,:) = xor(gn(1,4,:),ee4); gdown(1,5,:) = xor(gn(1,5,:),ee5); gdown(1,6,:) = xor(gn(1,6,:),ee6); gdown(1,7,:) = xor(gn(1,7,:),ee7); gdown(1,8,:) = xor(gn(1,8,:),ee8); gdown(1,9,:) = xor(gn(1,9,:),ee9); gdown(1,10,:) = xor(gn(1,10,:),ee10); gdown(1,11,:) = xor(gn(1,11,:),ee11); gdown(1,12,:) = xor(gn(1,12,:),ee12); sel = or(or(or(or(or(or(or(or(or(or(or(ee1,ee2),ee3),ee4),ee5),ee6),ee7),ee8),ee9),ee10),ee11),ee12); gn(2,1,:) = mux2(gup(1,1,:),gdown(1,1,:),sel); gn(2,2,:) = mux2(gup(1,2,:),gdown(1,2,:),sel); gn(2,3,:) = mux2(gup(1,3,:),gdown(1,3,:),sel); gn(2,4,:) = mux2(gup(1,4,:),gdown(1,4,:),sel); gn(2,5,:) = mux2(gup(1,5,:),gdown(1,5,:),sel); gn(2,6,:) = mux2(gup(1,6,:),gdown(1,6,:),sel); gn(2,7,:) = mux2(gup(1,7,:),gdown(1,7,:),sel); gn(2,8,:) = mux2(gup(1,8,:),gdown(1,8,:),sel); gn(2,9,:) = mux2(gup(1,9,:),gdown(1,9,:),sel); gn(2,10,:) = mux2(gup(1,10,:),gdown(1,10,:),sel); gn(2,11,:) = mux2(gup(1,11,:),gdown(1,11,:),sel); gn(2,12,:) = mux2(gup(1,12,:),gdown(1,12,:),sel); %%computation of the transition matrix for k = 1:M j = 1; for kkk = 1:n j = j + gn(2,kkk,k)*2^(kkk-1); end A(i,j) = A(i,j) + 1/M; end end A; % if p=0, A is the transition matrix when no perturbation; if p>0, A is the transition matrix with random perturbation rate of p. toc end function c=randomsequence(c1,c2,c3) % randomsequence sequence generator c=zeros(1,c1,c2); irandom=0; while irandom ~= c3 x=int32(1+(length(c)-1)*rand); if c(x)~=1 c(x)=1; irandom=irandom+1; end end end