-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulation_script.m
More file actions
283 lines (201 loc) · 5.26 KB
/
Copy pathSimulation_script.m
File metadata and controls
283 lines (201 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
%function lineage_deterministic(q)
rng('shuffle');
Tg0=120;
mu0=log(2)/Tg0;
totaltime=5*Tg0;
%% number of proteins
ntot=2e3;
np=ntot-2;
taum0=10; %in the unit of the number per micrometer qubic
CVtaum=0;
sigmay=sqrt(log(1+CVtaum^2));
meany=log(taum0)-sigmay^2/2;
taum=exp(meany+sigmay*randn(1,ntot));
taum(1:2)=taum0;
decayp=zeros(1,ntot);
% decayp(10)=1/10;
% decayp(11)=1/10;
% decayp(12)=1/10;
ndecay=0;
%decayp(ntot-ndecay+1:end)=1/10;
vr=12*60; % number of amnino acids per min
vn=12*60;
% The length is measured in the number of codons
len=500*ones(1,np+2);
len(1)=1e3;
len(2)=1e4;
Lr=len(2);
Ln=len(1);
% critical number of RNAP and ribosomes
nc=1e4;
% typical cell mass at birth
Mb=1e9;
phi_r=mu0*len(2)/vr;
phi_n=len(1)/len(2)*phi_r*0.1;
%% MM constant for binding of RNAP and ribosome
% the density is in the unit of amino acids per micrometer qubic
Kn0=10*1e-6*6e23*10^-15; %in the unit of the number per micrometer qubic
Kn_mean=5e3;
CVKn=0;
sigmay=sqrt(log(1+CVKn^2));
meany=log(Kn0)-sigmay^2/2;
Kn=exp(meany+sigmay*randn(1,ntot));
% Kn(1)=Kn_mean;
% Kn(2)=Kn_mean;
% Kn=Kn0*ones(1,ntot);
% Kn(10)=20*Kn0;
% Kn(11)=0.2*Kn0;
% Kn(1:2)=Kn0;
Kr=10*1e-6*6e23*10^-15;
rho=1e10;
%ratio between total protein mass and cell volume (num of aa per micro qubic)
alpha=20; %ratio between nuclear volume and cytoplasmic volume, assumed to be constant
% An approximate expression of gene copy number assuming cn*Fn << Kn
% Once g_tot is chosen, it is fixed
gr=5; %all the other genes have gene copy number 1
g_tot=ones(1,ntot);
g_tot(2)=gr;
y=phi_n/phi_r*(g_tot(2)*taum(2)*len(2)/Kn(2))/(g_tot(1)*taum(1)*len(1)/Kn(1));
A=g_tot(2)*taum(2).*len(2)./Kn(2);
B=g_tot(1)*taum(1).*len(1)./Kn(1);
C=sum(g_tot(3:end).*taum(3:end).*len(3:end)./Kn(3:end));
x=(1/(phi_r)-1-y*B/A)*A/C;
kcatn_r=(nc-sum(g_tot))*vn/(g_tot(2)*len(2)+y*g_tot(1)*len(1)+...
x*sum(g_tot(3:end).*len(3:end)));
kcatn_n=y*kcatn_r;
kcatn=zeros(1,ntot);
kcatn(1)=kcatn_n;
kcatn(2)=kcatn_r;
kcatn(3:end)=kcatn_r*x;
kcatr=10;
Lambda_n=kcatn.*len/vn;
Lambda_r=kcatr*len/vr;
%% we first compute the fraction of free RNAP and ribosome
n=Mb*phi_n/len(1)
r=Mb*phi_r/len(2)
n0=n;
r0=r;
V=Mb/rho;
Vn=V/alpha; % nuclear volume
cn=n/Vn;
Gn=g_tot.*(1+Lambda_n);
temp=0;
test_0=1e8;
while(1)
temp1=n*(1-temp);
temp3=sum(Gn.*(cn*temp./(cn*temp+Kn)));
test=abs(temp1-temp3);
if test<test_0
test_0=test;
temp=temp+1e-5;
else
break;
end
end
Fn=temp;
m_tot=kcatn.*g_tot.*(cn*Fn./(cn*Fn+Kn)).*taum;
Gr=sum(m_tot.*(1+Lambda_r));
cr=r/(V-Vn);
temp=0;
test_0=1e8;
while(1)
temp2=r*(1-temp);
temp4=Gr*(cr*temp./(cr*temp+Kr));
test=abs(temp2-temp4);
if test<test_0
test_0=test;
temp=temp+1e-5;
else
break;
end
end
Fr=temp;
phi_tot=m_tot.*len/sum(m_tot.*len);
P_tot=Mb*phi_tot./len;
P_tot=P_tot*n/P_tot(1);% we make sure the number of RNAP is continuous in the beginning
M=sum(P_tot.*len);
Mb=M;
%Kn(1:2)=sum(phi_tot.*Kn);
tra=zeros(totaltime,np+3);
tram=zeros(totaltime,np+3);
tram1=zeros(totaltime,np+3);
Mt=zeros(totaltime,3);
Ft=zeros(totaltime,5);
next=1;
deltaM=0;
%%
record=1;
tnext=0;
t=0;
count=1;
while(1)
if t>=tnext
tra(record,:)=[t P_tot];
tram(record,:)=[t m_tot];
temp=kcatn.*g_tot.*cn*Fn./(cn*Fn+Kn);
tram1(record,:)=[t temp];
Mt(record,:)=[t M deltaM];
Ft(record,:)=[t Fn Fr cn*Fn./(cn*Fn+Kn0) cr*Fr/(cr*Fr+Kr)];
record=record+1;
tnext=t+1;
end
% we first compute the fraction of free RNAP and ribosome
n=P_tot(1);
r=P_tot(2);
Gr=sum(m_tot.*(1+Lambda_r));
V=M/rho;
Vn=V/alpha;
cn=n/Vn;
cr=r/(V-Vn);
test_0=1e8;
temp=0;
dtemp=1e-5;
while(1)
temp1=n*(1-temp);
temp3=sum(Gn.*(cn*temp./(cn*temp+Kn)));
test=abs(temp1-temp3);
if test<test_0
test_0=test;
temp=temp+dtemp;
else
break;
end
end
Fn=temp;
temp=0;
test_0=1e8;
dtemp=1e-5;
while(1)
temp2=r*(1-temp);
temp4=Gr*(cr*temp./(cr*temp+Kr));
test=abs(temp2-temp4);
if test<test_0
test_0=test;
temp=temp+dtemp;
else
break;
end
end
Fr=temp;
rate_transcription=kcatn.*g_tot.*(cn*Fn./(cn*Fn+Kn));
rate_mRNAdecay=m_tot./taum;
rate_translation=kcatr*m_tot.*(cr*Fr/(cr*Fr+Kr));
rate_proteindecay=P_tot.*decayp;
delta_t=5/max(rate_translation);
t=t+delta_t;
m_tot=m_tot+rate_transcription*delta_t-rate_mRNAdecay*delta_t;
P_tot=P_tot+rate_translation*delta_t-rate_proteindecay*delta_t;
Mold=M;
M=sum(P_tot.*len);
deltaM=deltaM+M-Mold;
if deltaM>=8*Mb
break;
end
end
tra=tra(1:record-1,:);
tram=tram(1:record-1,:);
tram1=tram1(1:record-1,:);
Mt=Mt(1:record-1,:);
Ft=Ft(1:record-1,:);
mtot=sum(tram(:,1:end),2);
phi=P_tot.*len/M;