Skip to content

Commit 9c3ef83

Browse files
committed
update SI
1 parent c7d3a2b commit 9c3ef83

File tree

3 files changed

+92
-6
lines changed

3 files changed

+92
-6
lines changed

code/2 Driver Sr turnover.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,21 @@ MCMC.CI.c$CI_high
145145
log(2)/MCMC.CI.c$CI_low
146146
log(2)/MCMC.CI.c$CI_high
147147

148+
MAP.flux.ratio <- map_estimate(post.misha.pc2p3$BUGSoutput$sims.list$flux.ratio)
149+
MAP.flux.ratio[1]
150+
MCMC.CI.flux.ratio <- hdi(post.misha.pc2p3$BUGSoutput$sims.list$flux.ratio,0.89)
151+
MCMC.CI.flux.ratio$CI_low
152+
MCMC.CI.flux.ratio$CI_high
153+
154+
MAP.pool.ratio <- map_estimate(post.misha.pc2p3$BUGSoutput$sims.list$pool.ratio)
155+
MAP.pool.ratio[1]
156+
MCMC.CI.pool.ratio <- hdi(post.misha.pc2p3$BUGSoutput$sims.list$pool.ratio,0.89)
157+
MCMC.CI.pool.ratio$CI_low
158+
MCMC.CI.pool.ratio$CI_high
159+
148160
#get posterior of intake ratio
149161
post.misha.pc2p3.Rin.89<- MCMC.CI.bound(post.misha.pc2p3$BUGSoutput$sims.list$Rin, 0.89)
150162
#calculate the mean of intake after switch
151163
intake.af <- mean(post.misha.pc2p3.Rin.89[[1]][90:750])
164+
165+

code/5 Driver inversion case study mammoth.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,17 @@ MCMC.CI.c.m$CI_low
173173
MCMC.CI.c.m$CI_high
174174
log(2)/MCMC.CI.c.m$CI_low
175175
log(2)/MCMC.CI.c.m$CI_high
176+
177+
flux.ratio.m <- post.misha.invmamm.i$BUGSoutput$sims.list$a.m/post.misha.invmamm.i$BUGSoutput$sims.list$b.m
178+
MAP.flux.ratio.m <- map_estimate(flux.ratio.m)
179+
MAP.flux.ratio.m[1]
180+
MCMC.CI.flux.ratio.m <- hdi(flux.ratio.m,0.89)
181+
MCMC.CI.flux.ratio.m$CI_low
182+
MCMC.CI.flux.ratio.m$CI_high
183+
184+
pool.ratio.m <- post.misha.invmamm.i$BUGSoutput$sims.list$c.m/post.misha.invmamm.i$BUGSoutput$sims.list$b.m
185+
MAP.pool.ratio.m <- map_estimate(pool.ratio.m)
186+
MAP.pool.ratio.m[1]
187+
MCMC.CI.pool.ratio.m <- hdi(pool.ratio.m,0.89)
188+
MCMC.CI.pool.ratio.m$CI_low
189+
MCMC.CI.pool.ratio.m$CI_high

code/6 Driver forward model.R

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ res60 <- forw.m(t = length(syn.input.60), input = syn.input.60, a = a, b = b, c
224224
a <- MAP.a[1]
225225
b <- MAP.b[1]
226226
c <- MAP.c[1]
227-
c/b
228-
227+
c/b #0.2909254
229228
a/b
230229
#to change pool ratio, change c; to change flux ratio, change a
231230
# flux.ratio <- a/b
@@ -255,7 +254,7 @@ reac.prog.tk <- reac.prog[101:length(reac.prog)]
255254
lm.res.misha.2 <- lm(log(reac.prog.tk[200:800]) ~ c(200:800))
256255
summary(lm.res.misha.2)
257256
lm.res.misha.2$coefficients[[1]] #intercept
258-
lm.res.misha.2$coefficients[[2]] #slope
257+
lm.res.misha.2$coefficients[[2]] #slope lambda2
259258

260259
exp(lm.res.misha.2$coefficients[[1]]) #f2
261260
-1/lm.res.misha.2$coefficients[[2]]*log(2) #t1/2 = 330 days
@@ -270,7 +269,7 @@ plot(c(1:150),reac.prog.res1,ylab="residual: ln(1-F)",xlab="Days")
270269
lm.res.misha.1 <- lm(reac.prog.res1 ~ c(1:150))
271270
summary(lm.res.misha.1)
272271
lm.res.misha.1$coefficients[[1]] #intercept
273-
lm.res.misha.1$coefficients[[2]] #slope
272+
lm.res.misha.1$coefficients[[2]] #slope lambda1
274273

275274
exp(lm.res.misha.1$coefficients[[1]]) #f1 = 0.48
276275
-1/lm.res.misha.1$coefficients[[2]]*log(2) #t1/2 = 20.5 days
@@ -281,13 +280,17 @@ exp(lm.res.misha.1$coefficients[[1]]) #f1 = 0.48
281280
# f1/f2 ~= flux ratio
282281
exp(lm.res.misha.1$coefficients[[1]])/exp(lm.res.misha.2$coefficients[[1]])
283282

283+
# lambda1/(lambda2*f1*f2) ~= pool ratio
284+
lm.res.misha.2$coefficients[[2]]/lm.res.misha.1$coefficients[[2]]/exp(lm.res.misha.1$coefficients[[1]])/exp(lm.res.misha.2$coefficients[[1]])
285+
284286
#################use a different ratio###################
285287
####begin forward model####
286288
#loading MAP estimates from posterior of the calibration
287289
a <- 0.04
288290
b <- MAP.b[1]
289291
c <- MAP.c[1]
290292
a/b
293+
c/b
291294
#to change pool ratio, change c; to change flux ratio, change a
292295
# flux.ratio <- a/b
293296
# pool.ratio <- c/b
@@ -317,7 +320,7 @@ lm.res.frl.2 <- lm(log(reac.prog.frl.tk[200:800]) ~ c(200:800))
317320
plot(1:length(reac.prog.frl.tk), log(reac.prog.frl.tk),ylab="ln(1-F)",xlab="Days",main="Slow turnover pool")
318321
summary(lm.res.frl.2)
319322
lm.res.frl.2$coefficients[[1]] #intercept
320-
lm.res.frl.2$coefficients[[2]] #slope
323+
lm.res.frl.2$coefficients[[2]] #slope lambda2
321324

322325
exp(lm.res.frl.2$coefficients[[1]]) #f2 = 0.2885
323326
-1/lm.res.frl.2$coefficients[[2]]*log(2) #t1/2 = 271 days
@@ -331,7 +334,7 @@ plot(c(1:150),reac.prog.frl.res1,ylab="residual: ln(1-F)",xlab="Days")
331334
lm.res.frl.1 <- lm(reac.prog.frl.res1 ~ c(1:150))
332335
summary(lm.res.frl.1)
333336
lm.res.frl.1$coefficients[[1]] #intercept
334-
lm.res.frl.1$coefficients[[2]] #slope
337+
lm.res.frl.1$coefficients[[2]] #slope lambda1
335338
exp(lm.res.frl.1$coefficients[[1]]) #f1 = 0.711
336339
-1/lm.res.frl.1$coefficients[[2]]*log(2) #t1/2 = 12.3 days
337340

@@ -340,3 +343,58 @@ exp(lm.res.frl.1$coefficients[[1]]) #f1 = 0.711
340343

341344
# f1/f2 ~= flux ratio
342345
exp(lm.res.frl.1$coefficients[[1]]) /exp(lm.res.frl.2$coefficients[[1]])
346+
347+
# lambda1/(lambda2*f1*f2) ~= pool ratio
348+
lm.res.frl.2$coefficients[[2]]/lm.res.frl.1$coefficients[[2]]/exp(lm.res.frl.1$coefficients[[1]])/exp(lm.res.frl.2$coefficients[[1]])
349+
##############use a different c #################
350+
a <- MAP.a[1]
351+
b <- MAP.b[1]
352+
c <- 0.001 #MAP.c = 0.0041
353+
c/b
354+
355+
#2 number of days in the simulation
356+
t <- 900
357+
358+
#3 generate input series with fixed duration#
359+
input.misha <- initiate.switch(t, n.switch=1, day.switch=100, a=0.706, gap=0.005, duration=360)
360+
361+
#4 generate serum and bone series based on input series and turnover parameters#
362+
res <- forw.m(t = 900, input = input.misha, a = a, b = b, c = c, R1.int = NULL, R2.int = NULL)
363+
res.prs <- res[[1]]
364+
365+
reac.prog.prs <- (0.711-res.prs)/(0.711-0.706)
366+
367+
reac.prog.prs.tk <- reac.prog.prs[101:length(reac.prog.prs)]
368+
369+
#after the inflection point: [200:800]
370+
371+
lm.res.prs.2 <- lm(log(reac.prog.prs.tk[200:800]) ~ c(200:800))
372+
plot(1:length(reac.prog.prs.tk), log(reac.prog.prs.tk),ylab="ln(1-F)",xlab="Days",main="Slow turnover pool")
373+
summary(lm.res.prs.2)
374+
lm.res.prs.2$coefficients[[1]] #intercept
375+
lm.res.prs.2$coefficients[[2]] #slope lambda2
376+
377+
exp(lm.res.prs.2$coefficients[[1]]) #f2 = 0.4700503
378+
-1/lm.res.prs.2$coefficients[[2]]*log(2) #t1/2 = 1284.937 days
379+
380+
#estimate of parameter c:
381+
-lm.res.prs.2$coefficients[[2]]/(1-exp(lm.res.prs.2$coefficients[[1]]))
382+
383+
#fit for pool 1
384+
reac.prog.prs.res1 <- log(reac.prog.prs.tk[1:150]-exp(1:150 * lm.res.prs.2$coefficients[[2]] +lm.res.prs.2$coefficients[[1]])) #first residual
385+
plot(c(1:150),reac.prog.prs.res1,ylab="residual: ln(1-F)",xlab="Days")
386+
lm.res.prs.1 <- lm(reac.prog.prs.res1 ~ c(1:150))
387+
summary(lm.res.prs.1)
388+
lm.res.prs.1$coefficients[[1]] #intercept
389+
lm.res.prs.1$coefficients[[2]] #slope lambda1
390+
exp(lm.res.prs.1$coefficients[[1]]) #f1 = 0.5343916
391+
-1/lm.res.prs.1$coefficients[[2]]*log(2) #t1/2 = 21.53086 days
392+
393+
#estimate of parameter a:
394+
-lm.res.prs.1$coefficients[[2]]*exp(lm.res.prs.1$coefficients[[1]])
395+
396+
# fin/f2 ~= flux ratio
397+
exp(lm.res.prs.1$coefficients[[1]]) /exp(lm.res.prs.2$coefficients[[1]])
398+
399+
# lambda1/(lambda2*f1*f2) ~= pool ratio
400+
lm.res.prs.2$coefficients[[2]]/lm.res.prs.1$coefficients[[2]]/exp(lm.res.prs.1$coefficients[[1]])/exp(lm.res.prs.2$coefficients[[1]])

0 commit comments

Comments
 (0)