-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIn vivo comparison calculations.R
1038 lines (781 loc) · 38.4 KB
/
In vivo comparison calculations.R
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Comparison to in vivo data
#author: Joris Jean van der Lugt
#date: 17-11-2022
library(RxODE)
library(tidyverse)
library(readxl)
library(readr)
library(truncnorm)
library(reshape2)
library(plotly)
library(PKNCA)
#Generating a file for the comparison with in vivo data
blood_data <- as.data.frame(solve.pbk_rat[,c(1,3,4)])
#write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
#going from umol/l to umol
blood_data[2]<- blood_data[2] * V_V
blood_data[3]<-blood_data[3] * V_A
#combining C_V + C_A to create a combined amount of cinnamaldehyde
blood_data[3]<-blood_data[2]+ blood_data[3]
#Dropping the second colum
blood_data<-blood_data[-c(2)]
#going back an amount to an amount per L
blood_data[2]<- blood_data[2]/ (V_V + V_A)
write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
Combined_data_file_for_graph_500mg <- read_delim("Combined data file for graph 500mg.csv",
delim = ";", escape_double = FALSE, trim_ws = TRUE)
colnames(Combined_data_file_for_graph_500mg) <- c("time","umol.l","ID")
p1 <- plot_ly(Combined_data_file_for_graph_500mg, x=~time, y=Combined_data_file_for_graph_500mg$'umol.l',
color = ~ ID ,
colors = "Set2",
type= "scatter",
mode= "markers",
shape= ~ID,
hovertext= ~sample)%>%
layout(title= 'Blood concentration comparison dose = 500mg/kg-bw',
xaxis= list(title= 'Time (hours)'),
yaxis= list(title= 'Cinnamaldehyde concentration in μmol/l', type="log"),
legend =list(title= list(text='Type of Data')))
p1
g <- ggplot(Combined_data_file_for_graph_500mg,aes(time,Combined_data_file_for_graph_500mg$'umol.l',color=ID))
g + geom_point(aes(shape=ID),size=2)+
scale_y_continuous(trans='log10',labels = function(x) sprintf("%g", x))+
scale_x_continuous(breaks= c(0:30))+
scale_shape_manual(values=c(0, 1, 1,1,2,17,8,5))+
theme_linedraw()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
title = element_text(size=20),
panel.grid = element_line(color = "#8ccde3",
size = 0.75,
linetype = 2),
)+
labs(subtitle="Oral dose 500 mg/kg-BW",
y="Cinnamaldehyde concentration (μmol/L)",
x="Time (H)",
title="Cinnamaldehyde concentration in blood",
caption="PBK model")
ggsave(plot=g,"CNMA in blood 500 mg oral comparison.png",
width= 11.69, height= 8.3, dpi= 250)
RAT_data_obs_1 <- Combined_data_file_for_graph_500mg[1:15,]
RAT_data_obs_2 <- Combined_data_file_for_graph_500mg[16:30,]
RAT_data_obs_3 <- Combined_data_file_for_graph_500mg[31:46,]
RAT_data_Zao <- Combined_data_file_for_graph_500mg[47:57,]
SIM_data_pred <-Combined_data_file_for_graph_500mg[c(79,89,100,114,124,132,150,169,190,210,231,252,273,302,322),]
SIM_data_pred_kiwa <- Combined_data_file_for_graph_500mg[c(380,390,401,415,425,433,451,470,491,511,532,553,574,603,623),]
SIM_data_ka <-Combined_data_file_for_graph_500mg[c(681,691,702,716,726,734,752,771,792,812,833,854,875,904,924),]
SIM_data_pred[,4]<- as.data.frame(RAT_data_obs_1[,2])
SIM_data_pred[,5]<- as.data.frame(RAT_data_obs_2[,2])
SIM_data_pred[,6]<- as.data.frame(RAT_data_obs_3[1:15,2])
SIM_data_pred[,7]<- as.data.frame(SIM_data_pred_kiwa[,2])
SIM_data_pred[,8]<- as.data.frame(SIM_data_ka[,2])
colnames(SIM_data_pred)<- c("Time","sim","ID","rat_1","rat_2","rat_3","SIM-Kiwa","ka")
#sim rat 1
rsmesim_rat1<-sqrt(mean((SIM_data_pred$sim - SIM_data_pred$rat_1)^2))
#sim rat 2
rsmesim_rat2<- sqrt(mean((SIM_data_pred$sim - SIM_data_pred$rat_2)^2))
#sim rat 3
rsmesim_rat3<- sqrt(mean((SIM_data_pred$sim - SIM_data_pred$rat_3)^2))
mean_RSME<-(rsmesim_rat1+rsmesim_rat2+rsmesim_rat3)/3
RSMD_500mg_1<- rmsd(a=SIM_data_pred$sim, b=SIM_data_pred$rat_1)
RSMD_500mg_2<- rmsd(a=SIM_data_pred$sim, b=SIM_data_pred$rat_2)
RSMD_500mg_3<- rmsd(a=SIM_data_pred$sim, b=SIM_data_pred$rat_3)
p<-ggplot(SIM_data_pred, aes(x=SIM_data_pred$sim, y=SIM_data_pred$rat_1)) +
geom_point() +
geom_abline(intercept=0, slope=1) +
geom_line(data=tibble(x=c(0, 60),y=c(0,60)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 60),y=c(0,60)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 60),y=c(0,60)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
annotate("text", x = 10, y = 75, label = "RSMD: 21.9", size= 8)+
labs(x='Predicted Values(μmol/L)', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 500mg/kg-BW oral dose',subtitle="Yuan et al 1992")+
geom_point(aes(x=SIM_data_pred$sim,y=SIM_data_pred$rat_2))+
geom_point(aes(x=SIM_data_pred$sim,y=SIM_data_pred$rat_3))+
theme_classic()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
p
ggsave(plot=p,"Pred vs actual 500mg oral data.png",
width= 11.69, height= 8.3, dpi= 250)
#sim rat 1
rsmesimka_rat1<-sqrt(mean((SIM_data_pred$ka - SIM_data_pred$rat_1)^2))
#sim rat 2
rsmesimka_rat2<- sqrt(mean((SIM_data_pred$ka - SIM_data_pred$rat_2)^2))
#sim rat 3
rsmesimka_rat3<- sqrt(mean((SIM_data_pred$ka - SIM_data_pred$rat_3)^2))
mean_RSME_ka<-(rsmesimka_rat1+rsmesimka_rat2+rsmesimka_rat3)/3
RSMD_500mg_ka_1<- rmsd(a=SIM_data_pred$ka, b=SIM_data_pred$rat_1)
RSMD_500mg_ka_2<- rmsd(a=SIM_data_pred$ka, b=SIM_data_pred$rat_2)
RSMD_500mg_ka_3<- rmsd(a=SIM_data_pred$ka, b=SIM_data_pred$rat_3)
#plotting new plot with adjusted parameters for ka
p<-ggplot(SIM_data_pred, aes(x=SIM_data_pred$ka, y=SIM_data_pred$rat_1)) +
geom_point() +
geom_abline(intercept=0, slope=1)+
geom_line(data=tibble(x=c(0, 15),y=c(0,15)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0,15),y=c(0,15)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0,15),y=c(0,15)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 500mg/kg-BW oral dose',subtitle="Yuan et al 1992, Ka = 0.2")+
annotate("text", x = 4, y = 20, label = "RSMD: 5.5", size= 8)+
geom_point(aes(x=SIM_data_pred$ka,y=SIM_data_pred$rat_2))+
geom_point(aes(x=SIM_data_pred$ka,y=SIM_data_pred$rat_3))+
theme_classic()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
p
ggsave(plot=p,"Pred vs actual 500mg oral ka .png",
width= 11.69, height= 8.3, dpi= 250)
#Making a pred vs pred plot
Kiwa_data <-Combined_data_file_for_graph_500mg[c(58,60:72),]
SIM_pred_pred <-Combined_data_file_for_graph_500mg[c(374,375,376,379,384,401,427,468,505,538,574,607,640,667),]
SIM_pred_pred[,3]<- as.data.frame(Kiwa_data[,2])
SIM_pred_pred[,4]<-SIM_pred_pred[,2]/SIM_pred_pred[,3]
SIM_pred_pred[,5]<-SIM_pred_pred[,3]/SIM_pred_pred[,2]
colnames(SIM_pred_pred)<- c("Time","sim","kiwa","sim/kiwa","kiwa/sim")
#sim ka vs kiwa
rsmesim_kiwa<-sqrt(mean((SIM_pred_pred$sim - SIM_pred_pred$kiwa)^2))
RSME_sim_kiwa<-(rsmesim_kiwa)
p<-ggplot(SIM_pred_pred, aes(x=sim, y=kiwa)) +
geom_point() +
geom_abline(intercept=0, slope=1) +
ylim(0,1000)+
xlim(0,1000)+
annotate("text", x = 200, y = 750, label = "Mean RSME: 167.03", size= 8)+
labs(x='Predicted Values R', y='Predicted values Kiwa', title='Predicted vs. Predicted Values 500mg oral dose')+
theme_classic()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
ggsave(plot=p,"Pred vs pred 500mg oral.png",
width= 11.69, height= 8.3, dpi= 250)
#Calculating AUC values vor the comparison graphs made above
AUC_data <-PKNCAconc(Combined_data_file_for_graph_500mg, umol.l~time|ID)
#Dosing data per Paper/simulation run
#Loading dosing file
d_dose <- read.csv("D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK/500m_comparison_doses.csv", sep=";")
dose_obj <- PKNCAdose(d_dose, dose~time|ID)
#letting pknc chose the end time of the auc calc
data_obj_automatic <- PKNCAdata(AUC_data, dose_obj)
#Computing the data both manual and automatic
results_obj_automatic <- pk.nca(data_obj_automatic)
#look at the data to get an impression
knitr::kable(head(as.data.frame(results_obj_automatic)))
summary(results_obj_automatic)
#saving data
write.csv(results_obj_automatic$result,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//500mg_oral_results.csv")
#RAT_1 calculation
x <- c(Combined_data_file_for_graph_500mg[1:15,1])
y <- c(Combined_data_file_for_graph_500mg[1:15,2])
RAT_1_AUC <- auc(x[["time"]],y[["umol.l"]], type=c("spline"))
#RAT_2
x <- c(Combined_data_file_for_graph_500mg[16:30,1])
y <- c(Combined_data_file_for_graph_500mg[16:30,2])
RAT_2_AUC <- auc(x[["time"]],y[["umol.l"]], type=c("spline"))
#RAT_3
x <- c(Combined_data_file_for_graph_500mg[31:46,1])
y <- c(Combined_data_file_for_graph_500mg[31:46,2])
RAT_3_AUC <- auc(x[["time"]],y[["umol.l"]], type=c("spline"))
#Zhao
x <- c(Combined_data_file_for_graph_500mg[47:57,1])
y <- c(Combined_data_file_for_graph_500mg[47:57,2])
ZHAO_AUC <- auc(x[["time"]],y[["umol.l"]], type=c("spline"))
#Generating a file for the comparison with in vivo data for 250 mg exposure
blood_data <- as.data.frame(solve.pbk_rat[,c(1,3,4)])
#write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
#going from umol/l to umol
blood_data[2]<- blood_data[2] * V_V
blood_data[3]<-blood_data[3] * V_A
#combining C_v + C_A to create a combined amount of cinnamaldehyde
blood_data[3]<-blood_data[2]+ blood_data[3]
#Dropping the second colum
blood_data<-blood_data[-c(2)]
#going back an amount to an amount per L
blood_data[2]<- blood_data[2]/ (V_V + V_A)
write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
Combined_data_file_for_graph_250mg <- read_delim("Combined data file for graph 250mg.csv",
delim = ";", escape_double = FALSE, trim_ws = TRUE)
p1 <- plot_ly(Combined_data_file_for_graph_250mg, x=~time, y=Combined_data_file_for_graph_250mg$`ug.ml`,
color = ~ ID ,
colors = "Set2",
type= "scatter",
mode= "markers",
hovertext= ~sample)%>%
layout(title= 'Blood concentration comparison dose = 250mg/kg-bw',
xaxis= list(title= 'Time (hours)'),
yaxis= list(title= 'Cinnamaldehyde concentration in umol/l', type="log"),
legend =list(title= list(text='Type of Data')))
p1
g <- ggplot(Combined_data_file_for_graph_250mg,aes(time,Combined_data_file_for_graph_250mg$`ug.ml`,color=ID))
g + geom_point(aes(shape=ID),size=2)+
scale_y_continuous(trans='log10',labels = function(x) sprintf("%g", x))+
scale_x_continuous(breaks= c(0:30))+
scale_shape_manual(values=c(0, 1, 1,1,2,17,8,5))+
theme_linedraw()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
title = element_text(size=20),
panel.grid = element_line(color = "#8ccde3",
size = 0.75,
linetype = 2),
)+
labs(subtitle="Oral dose 250 mg/kg-BW",
y="Cinnamaldehyde concentration (μmol/L)",
x="Time (H)",
title="Cinnamaldehyde concentration in blood",
caption="Cinnamaldehyde PBK model")
ggsave(plot=g,"CNMA in blood 250mg oral comparison.png",
width= 11.69, height= 8.3, dpi= 250)
RAT_data_obs_1 <- Combined_data_file_for_graph_250mg[21:36,]
RAT_data_obs_2 <- Combined_data_file_for_graph_250mg[37:52,]
RAT_data_obs_3 <- Combined_data_file_for_graph_250mg[53:68,]
RAT_data_Zao <- Combined_data_file_for_graph_250mg[1:8,]
SIM_data_pred <-Combined_data_file_for_graph_250mg[c(70,71,74,80,84,89,94,104,114,124,134,144,154,164,179,189),]
SIM_data_Ka <-Combined_data_file_for_graph_250mg[c(312,313,316,322,326,331,336,346,356,366,376,387,396,411,421,431),]
SIM_data_pred[,4]<- as.data.frame(RAT_data_obs_1[,2])
SIM_data_pred[,5]<- as.data.frame(RAT_data_obs_2[,2])
SIM_data_pred[,6]<- as.data.frame(RAT_data_obs_3[,2])
SIM_data_pred[,7]<- as.data.frame(SIM_data_Ka[,2])
#Calculating residual values
SIM_data_pred[,8] <- SIM_data_pred[,2]-SIM_data_pred[,4]
SIM_data_pred[,9] <- SIM_data_pred[,4]-SIM_data_pred[,7]
SIM_data_pred[,10] <- SIM_data_pred[,5]-SIM_data_pred[,7]
colnames(SIM_data_pred)<- c("Time","sim","ID","rat_1", "rat_2","rat_3","SIM_ka","Residual_Rat_1","Residual_Rat1_ka","Residual_Rat2_ka")
#sim rat 1
rsmesim_rat1_250<-sqrt(mean((SIM_data_pred$sim - SIM_data_pred$rat_1)^2))
#sim rat 2
rsmesim_rat2_250<- sqrt(mean((SIM_data_pred$sim - SIM_data_pred$rat_2)^2))
#sim rat 3
rsmesim_rat3_250<- sqrt(mean((SIM_data_pred$sim - SIM_data_pred$rat_3)^2))
mean_RSME_250<-mean(c(rsmesim_rat1_250,rsmesim_rat2_250,rsmesim_rat3_250))
RSMD_250mg_1<- rmsd(a=SIM_data_pred$sim, b=SIM_data_pred$rat_1)
RSMD_250mg_2<- rmsd(a=SIM_data_pred$sim, b=SIM_data_pred$rat_2)
RSMD_250mg_3<- rmsd(a=SIM_data_pred$sim, b=SIM_data_pred$rat_3)
predvsout_250mg <- ggplot(SIM_data_pred, aes(x=SIM_data_pred$sim, y=SIM_data_pred$rat_1)) +
geom_point() +
#geom_abline(intercept=0, slope=1)+
geom_line(data=tibble(x=c(0, 30),y=c(0,30)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 30),y=c(0,30)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 30),y=c(0,30)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 250mg/kg-BW oral',subtitle="Yuan et al 1992")+
annotate("text", x = 10, y = 40, label = "RSMD: 18.9", size= 8)+
theme_classic()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))+
geom_point(aes(x=SIM_data_pred$sim,y=SIM_data_pred$rat_2))+
geom_point(aes(x=SIM_data_pred$sim,y=SIM_data_pred$rat_3))
predvsout_250mg
ggsave(plot=predvsout_250mg,"Pred vs data 250mg oral.png",
width= 11.69, height= 8.3, dpi= 250)
predvsout_250mg
#sim rat 1
rsmesim_rat1_250ka<-sqrt(mean((SIM_data_pred$SIM_ka - SIM_data_pred$rat_1)^2))
#sim rat 2
rsmesim_rat2_250ka<- sqrt(mean((SIM_data_pred$SIM_ka - SIM_data_pred$rat_2)^2))
#sim rat 3
rsmesim_rat3_250ka<- sqrt(mean((SIM_data_pred$SIM_ka - SIM_data_pred$rat_3)^2))
mean_RSME_250ka<-mean(c(rsmesim_rat1_250ka,rsmesim_rat2_250ka,rsmesim_rat3_250ka))
RSMD_250mg_1_ka<- rmsd(a=SIM_data_pred$SIM_ka, b=SIM_data_pred$rat_1)
RSMD_250mg_2_ka<- rmsd(a=SIM_data_pred$SIM_ka, b=SIM_data_pred$rat_2)
RSMD_250mg_3_ka<- rmsd(a=SIM_data_pred$SIM_ka, b=SIM_data_pred$rat_3)
predvsout_250mg_ka <- ggplot(SIM_data_pred, aes(x=SIM_data_pred$SIM_ka, y=SIM_data_pred$rat_1)) +
geom_point() +
geom_abline(intercept=0, slope=1)+
geom_line(data=tibble(x=c(0, 7.5),y=c(0,7.5)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 7.5),y=c(0,7.5)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 7.5),y=c(0,7.5)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 250mg/kg-BW oral',subtitle="Yuan et al 1992, Ka= 0.2")+
annotate("text", x = 2.5, y = 17, label = "RSMD: 4.45", size= 8)+
geom_point(aes(x=SIM_data_pred$SIM_ka,y=SIM_data_pred$rat_2))+
geom_point(aes(x=SIM_data_pred$SIM_ka,y=SIM_data_pred$rat_3))+
theme_classic()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
predvsout_250mg_ka
ggsave(plot=predvsout_250mg_ka,"Pred vs actual 250mg oral ka data.png",
width= 11.69, height= 8.3, dpi= 250)
predvsout_250mg_ka
#plotting residual rat 1
ggplot(SIM_data_pred, aes(x=SIM_data_pred$Time, y=SIM_data_pred$Residual_Rat_1)) +
geom_point() +
geom_abline(slope = 0,intercept = 0)+
labs(x= "Time", y='Residual values', title='Residual Values 250mg oral Yuan data')
#plotting residual rat 1 vs ka
ggplot(SIM_data_pred, aes(x=SIM_data_pred$Time, y=SIM_data_pred$Residual_Rat1_ka)) +
geom_point() +
geom_abline(slope = 0,intercept = 0)+
labs(x= "Time", y='Residual values', title='Residual Values 250mg oral Yuan data ka')
#plotting residual rat 2 vs ka
ggplot(SIM_data_pred, aes(x=SIM_data_pred$Time, y=SIM_data_pred$Residual_Rat2_ka)) +
geom_point() +
geom_abline(slope = 0,intercept = 0)+
labs(x= "Time", y='Residual values', title='Residual Values 250mg oral Yuan data')
#Calculating AUC values for the comparison graphs made above
AUC_data <-PKNCAconc(Combined_data_file_for_graph_250mg, ug.ml~time|ID)
#Dosing data per Paper/simulation run
#Loading dosing file
d_dose <- read.csv("D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK/250mg_comparison_doses.csv", sep=";")
dose_obj <- PKNCAdose(d_dose, dose~time|ID)
#letting pknc chose the end time of the auc calc
data_obj_automatic <- PKNCAdata(AUC_data, dose_obj)
#Computing the data both manual and automatic
results_obj_automatic <- pk.nca(data_obj_automatic)
#look at the data to get an impression
knitr::kable(head(as.data.frame(results_obj_automatic)))
summary(results_obj_automatic)
#saving data
write.csv(results_obj_automatic$result,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//250mg_oral_results.csv")
#RAT_1 calculation
x <- c(Combined_data_file_for_graph_250mg[21:36,1])
y <- c(Combined_data_file_for_graph_250mg[21:36,2])
RAT_1_AUC <- auc(x[["time"]],y[["ug.ml"]], type=c("spline"))
#RAT_2
x <- c(Combined_data_file_for_graph_250mg[37:52,1])
y <- c(Combined_data_file_for_graph_250mg[37:52,2])
RAT_2_AUC <- auc(x[["time"]],y[["ug.ml"]], type=c("spline"))
#RAT_3
x <- c(Combined_data_file_for_graph_250mg[53:68,1])
y <- c(Combined_data_file_for_graph_250mg[53:68,2])
RAT_3_AUC <- auc(x[["time"]],y[["ug.ml"]], type=c("spline"))
#Zhao
x <- c(Combined_data_file_for_graph_250mg[1:8,1])
y <- c(Combined_data_file_for_graph_250mg[1:8,2])
ZHAO_AUC <- auc(x[["time"]],y[["ug.ml"]], type=c("spline"))
#Kiwa
x <- c(Combined_data_file_for_graph_250mg[9:20,1])
y <- c(Combined_data_file_for_graph_250mg[9:20,2])
Kiwa_AUC <- auc(x[["time"]],y[["ug.ml"]], type=c("spline"))
#iv concentration
#Generating a file for the comparison with in vivo data
blood_data <- as.data.frame(solve.pbk_rat[,c(1,3,4)])
#write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
#going from umol/l to umol
blood_data[2]<- blood_data[2] * V_V
blood_data[3]<-blood_data[3] * V_A
#combining C_v + C_A to create a combined amount of cinnamaldehyde
blood_data[3]<-blood_data[2]+ blood_data[3]
#Dropping the second colum
blood_data<-blood_data[-c(2)]
#going back an amount to an amount per L
blood_data[2]<- blood_data[2]/ (V_V + V_A)
write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
Combined_data_file_for_graph <- read.csv("D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK/IV_blood_Concentration.csv", sep=";")
p1 <- plot_ly(Combined_data_file_for_graph, x=~Time, y=Combined_data_file_for_graph$umol.L,
color = ~ ID ,
colors = "Set2",
type= "scatter",
mode= "markers",
hovertext= ~sample)%>%
layout(title= 'Blood concentration comparison dose = 20mg/kg-bw IV',
xaxis= list(title= 'Time (hours)'),
yaxis= list(title= 'Cinnamaldehyde concentration in umol/l', type="log"),
legend =list(title= list(text='Type of Data')))
p1
g <- ggplot(Combined_data_file_for_graph,aes(Time,umol.L,color=ID))
g + geom_point()+ scale_y_continuous(trans='log10')+
labs(subtitle="IV dose 20mg/kg/bw",
y="Cinnamaldehyde concentration in umol/l",
x="Time in Hours",
title="Cinnamaldehyde concentration in blood",
caption="PBK model")
KIWA_data <- Combined_data_file_for_graph[9:27,]
SIM_data_pred <-Combined_data_file_for_graph[c(29,30,31,32,33,34,35,36,37,38,40,43,46,49,52,55,58,61,63),]
SIM_data_kiwa <-Combined_data_file_for_graph[c(70,71,72,73,74,75,76,77,78,80,83,86,89,92,95,98,101,103,104),]
SIM_data_pred[,4]<- as.data.frame(KIWA_data[,2])
SIM_data_pred[,5]<- as.data.frame(SIM_data_kiwa[,2])
colnames(SIM_data_pred)<- c("Time","sim","ID","KIWA","sim kiwa")
#sim ka vs kiwa
RMSE_sim_kiwa_iv<-sqrt(mean((SIM_data_pred$sim - SIM_data_pred$KIWA)^2))
RSME_sim_kiwa<-(rsme_sim_kiwa)
p <-ggplot(SIM_data_pred, aes(x=SIM_data_pred$"sim kiwa", y=SIM_data_pred$KIWA)) +
geom_point(size=3) +
geom_abline(intercept=0, slope=1) +
labs(x='Predicted Values R', y='Predicted values Kiwa', title='Predicted vs. predicted Values 20mg IV dose Kiwa')+
theme_classic()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
ggsave(plot=p,"Pred vs pred 20mg iv.png",
width= 11.69, height= 8.3, dpi= 250)
ZAO_data_2014 <- Combined_data_file_for_graph[1:8,]
SIM_data <-Combined_data_file_for_graph[c(29,30,31,33,38,43,48,58),]
SIM_data[,3]<- as.data.frame(ZAO_data_2014[,2])
colnames(SIM_data)<- c("Time","sim","ZAO")
RSME_sim_IV<-sqrt(mean((SIM_data$sim - SIM_data$ZAO)^2))
RSMD<- rmsd(a=SIM_data$sim, b=SIM_data$ZAO)
p<-ggplot(SIM_data, aes(x=SIM_data$sim, y=SIM_data$ZAO)) +
geom_point(size=3) +
geom_abline(intercept=0, slope=1) +
geom_line(data=tibble(x=c(0, 11),y=c(0,11)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 11),y=c(0,11)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 11),y=c(0,11)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 20mg IV dose',subtitle="Zao et al 2014")+
theme_classic()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
p
ggsave(plot=p,"Pred vs actual 20mg iv.png",
width= 11.69, height= 8.3, dpi= 250)
p
#Generating a file for the comparison with in vivo data
blood_data <- as.data.frame(solve.pbk_rat[,c(1,3,4)])
#write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
#going from umol/l to umol
blood_data[2]<- blood_data[2] * V_V
blood_data[3]<-blood_data[3] * V_A
#combining C_v + C_A to create a combined amount of cinnamaldehyde
blood_data[3]<-blood_data[2]+ blood_data[3]
#Dropping the second colum
blood_data<-blood_data[-c(2)]
#going back an amount to an amount per L
blood_data[2]<- blood_data[2]/ (V_V + V_A)
write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
Combined_data_file_for_graph <- read.csv("D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK/IV_10mg_comparison.csv", sep=";")
p1 <- plot_ly(Combined_data_file_for_graph, x=~Time, y=Combined_data_file_for_graph$ug.ml,
color = ~ ID ,
colors = "Set2",
type= "scatter",
mode= "markers",
hovertext= ~sample)%>%
layout(title= 'Blood concentration comparison dose = 10mg/kg-BW IV',
xaxis= list(title= 'Time (hours)'),
yaxis= list(title= 'Cinnamaldehyde concentration in umol/l', type="log"),
legend =list(title= list(text='Type of Data')))
p1
g <- ggplot(Combined_data_file_for_graph,aes(Time,ug.ml,color=ID))
g + geom_point()+
labs(subtitle="IV dose 10mg/kg/bw",
y="Cinnamaldehyde concentration in umol/L",
x="Time in Hours",
title="Cinnamaldehyde concentration in blood",
caption="PBK model")
Shetty_data <- Combined_data_file_for_graph[1:8,]
SIM_data<- Combined_data_file_for_graph[c(11,14,19,24,29,40,89,129),]
SIM_data[,3]<- as.data.frame(Shetty_data[,2])
colnames(SIM_data)<- c("Time","sim","Shetty")
RSME_sim_IV_shetty<-sqrt(mean((SIM_data$sim - SIM_data$Shetty)^2))
RSMD<- rmsd(a=SIM_data$sim, b=SIM_data$Shetty)
p <-ggplot(SIM_data, aes(x=SIM_data$sim, y=SIM_data$Shetty)) +
geom_point(size=3) +
geom_abline(intercept=0, slope=1) +
geom_line(data=tibble(x=c(0, 75),y=c(0,75)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 75),y=c(0,75)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 75),y=c(0,75)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L) ', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 10mg/kg-BW IV dose',subtitle="Shetty et al 2020")+
theme_classic()+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
p
ggsave(plot=p,"Pred vs actual 10mg iv.png",
width= 11.69, height= 8.3, dpi= 250)
p
####-------------DONG et al 2022 data comparison--------------####
#Generating a file for the comparison with in vivo data
blood_data <- as.data.frame(solve.pbk_rat[,c(1,3,4)])
#write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
#going from umol/l to umol
blood_data[2]<- blood_data[2] * V_V
blood_data[3]<-blood_data[3] * V_A
#combining C_v + C_A to create a combined amount of cinnamaldehyde
blood_data[3]<-blood_data[2]+ blood_data[3]
#Dropping the second colum
blood_data<-blood_data[-c(2)]
#going back an amount to an amount per L
blood_data[2]<- blood_data[2]/ (V_V + V_A)
write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
Combined_data_file_for_graph <- read.csv("D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK/375 oral dose comparison DONG et al 2022.csv", sep=";")
p1 <- plot_ly(Combined_data_file_for_graph, x=~Time, y=Combined_data_file_for_graph$umol.l,
color = ~ ID ,
colors = "Set2",
type= "scatter",
mode= "markers",
hovertext= ~sample)%>%
layout(title= 'Blood concentration comparison dose = 375mg/kg/bw',
xaxis= list(title= 'Time (hours)'),
yaxis= list(title= 'Cinnamaldehyde concentration in umol/l', type="log"),
legend =list(title= list(text='Type of Data')))
p1
g <- ggplot(Combined_data_file_for_graph,aes(Time,umol.l,color=ID))
g + geom_point()+ scale_y_continuous(trans='log10')+
labs(subtitle="oral375mg/kg/bw dose",
y="Cinnamaldehyde concentration in umol/l",
x="Time in Hours",
title="Cinnamaldehyde concentration in blood",
caption="PBK model")
Dong_data <- Combined_data_file_for_graph[1:10,]
SIM_data <-Combined_data_file_for_graph[c(12,13,14,16,19,21,31,51,71,91),]
SIM_data_kiwa<-Combined_data_file_for_graph[c(93,94,95,97,100,102,112,132,152,172),]
SIM_data[,4]<- as.data.frame(Dong_data[,2])
SIM_data[,5]<- as.data.frame(SIM_data_kiwa[,2])
colnames(SIM_data)<- c("Time","sim","ID","Dong","simka")
#sim ka vs kiwa
RMSE_sim_dong<-sqrt(mean((SIM_data$sim - SIM_data$Dong)^2))
RSME_sim_kiwa<-(rsme_sim_kiwa)
RSMD<- rmsd(a=SIM_data$sim, b=SIM_data$Dong)
p <-ggplot(SIM_data, aes(x=SIM_data$"sim", y=SIM_data$Dong)) +
geom_point(size=3) +
geom_abline(intercept=0, slope=1) +
geom_line(data=tibble(x=c(0, 5000),y=c(0,5000)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 5000),y=c(0,5000)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 5000),y=c(0,5000)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Predicted values(μmol/L)', title='Predicted vs. predicted Values 375mg/kg-BW dose',subtitle="Dong et al 2022")+
theme_classic()+
annotate("text", x = 2000, y = 7500, label = "RSMD: 10201", size= 8)+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
p
ggsave(plot=p,"Pred vs actual 375mg oral.png",
width= 11.69, height= 8.3, dpi= 250)
RMSE_sim_dong_ka<-sqrt(mean((SIM_data$simka - SIM_data$Dong)^2))
RSMD<- rmsd(a=SIM_data$simka, b=SIM_data$Dong)
p <-ggplot(SIM_data, aes(x=SIM_data$"simka", y=SIM_data$Dong)) +
geom_point(size=3) +
geom_abline(intercept=0, slope=1) +
geom_line(data=tibble(x=c(0, 5000),y=c(0,5000)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 5000),y=c(0,5000)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 5000),y=c(0,5000)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Predicted values(μmol/L)', title='Predicted vs. predicted Values 375mg/kg-BW dose',subtitle="Dong et al 2022 Ka= 0.2")+
theme_classic()+
annotate("text", x = 2000, y = 7500, label = "RSMD: 10259", size= 8)+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
p
ggsave(plot=p,"Pred vs actual ka = 0.2 375mg oral.png",
width= 11.69, height= 8.3, dpi= 250)
####-------------JI et al 2015 data comparison--------------####
#Generating a file for the comparison with in vivo data
blood_data <- as.data.frame(solve.pbk_rat[,c(1,3,4)])
#write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
#going from umol/l to umol
blood_data[2]<- blood_data[2] * V_V
blood_data[3]<-blood_data[3] * V_A
#combining C_v + C_A to create a combined amount of cinnamaldehyde
blood_data[3]<-blood_data[2]+ blood_data[3]
#Dropping the second colum
blood_data<-blood_data[-c(2)]
#going back an amount to an amount per L
blood_data[2]<- blood_data[2]/ (V_V + V_A)
write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
Combined_data_file_for_graph <- read.csv("D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK/15 mg oral dose .csv", sep=";")
p1 <- plot_ly(Combined_data_file_for_graph, x=~Time, y=Combined_data_file_for_graph$umol.l,
color = ~ ID ,
colors = "Set2",
type= "scatter",
mode= "markers",
hovertext= ~sample)%>%
layout(title= 'Blood concentration comparison dose = 15mg/kg-bw IV',
xaxis= list(title= 'Time (hours)'),
yaxis= list(title= 'Cinnamaldehyde concentration in umol/l'),
legend =list(title= list(text='Type of Data')))
p1
Ji_data <- Combined_data_file_for_graph[1:11,]
SIM_data<- Combined_data_file_for_graph[c(13,15,17,22,27,32,42,52,92,132,252),]
SIM_data_ka<- Combined_data_file_for_graph[c(264,266,268,273,278,283,293,303,343,383,503),]
SIM_data[,3]<- as.data.frame(Ji_data[,2])
SIM_data[,4]<- as.data.frame(SIM_data_ka[,2])
colnames(SIM_data)<- c("Time","sim","Ji","simka")
RMSE_sim_ji<-sqrt(mean((SIM_data$sim - SIM_data$Ji)^2))
RMSD_sim_ji<- rmsd(a=SIM_data$sim, b=SIM_data$Ji )
p <-ggplot(SIM_data, aes(x=SIM_data$sim, y=SIM_data$Ji)) +
geom_point(size=3) +
geom_abline(intercept=0, slope=1) +
geom_line(data=tibble(x=c(0, 1.5),y=c(0,1.5)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 1.5),y=c(0,1.5)),linetype = "dashed",
aes(x=x,y=y*10),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 1.5),y=c(0,1.5)),linetype = "dashed",
aes(x=x,y=y*0.1),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 15mg/kg-BW oral dose',subtitle="Ji et al 2015" )+
theme_classic()+
annotate("text", x = 0.25, y = 2, label = "RSMD: 0.76", size= 8)+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
p
ggsave(plot=p,"Pred vs actual 15mg 10 fold difference oral.png",
width= 11.69, height= 8.3, dpi= 250)
g <- ggplot(Combined_data_file_for_graph,aes(Time,umol.l,color=ID))
g + geom_point()+ scale_y_continuous(trans='log10')+
labs(subtitle="IV dose 15mg/kg/bw",
y="Cinnamaldehyde concentration in umol/l",
x="Time in Hours",
title="Cinnamaldehyde concentration in blood",
caption="PBK model")
RMSE_sim_ka<-sqrt(mean((SIM_data$simka - SIM_data$Ji)^2))
RMSD_sim_ka<- rmsd(a=SIM_data$simka, b=SIM_data$Ji )
p <-ggplot(SIM_data, aes(x=SIM_data$simka, y=SIM_data$Ji)) +
geom_point(size=3) +
geom_abline(intercept=0, slope=1) +
geom_line(data=tibble(x=c(0, 0.3),y=c(0,0.3)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 0.3),y=c(0,0.3)),linetype = "dashed",
aes(x=x,y=y*5),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 0.3),y=c(0,0.3)),linetype = "dashed",
aes(x=x,y=y*0.2),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 15mg/kg-BW oral dose',subtitle="Ji et al 2015 ka= 0.2" )+
theme_classic()+
annotate("text", x = 0.05, y = 0.40, label = "RSMD: 0.102", size= 8)+
theme(axis.title = element_text(size=14),
axis.text = element_text(size = 12),
legend.position = "none",
title = element_text(size=20))
p
ggsave(plot=p,"Pred vs actual ka 15mg 5 fold difference oral.png",
width= 11.69, height= 8.3, dpi= 250)
####-------------YOUNG et al 2020 data comparison--------------####
#Generating a file for the comparison with in vivo data
blood_data <- as.data.frame(solve.pbk_rat[,c(1,3,4)])
#write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
#going from umol/l to umol
blood_data[2]<- blood_data[2] * V_V
blood_data[3]<-blood_data[3] * V_A
#combining C_v + C_A to create a combined amount of cinnamaldehyde
blood_data[3]<-blood_data[2]+ blood_data[3]
#Dropping the second colum
blood_data<-blood_data[-c(2)]
#going back an amount to an amount per L
blood_data[2]<- blood_data[2]/ (V_V + V_A)
write.csv(blood_data,"D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK//Blood_Data.csv")
Combined_data_file_for_graph <- read.csv("D:/Joris/Toxicology and Environmental Health/Master stage/R/Cinnamaldehyde PBK/Yong et al 2020 50mg-kg-bw.csv", sep=";")
p1 <- plot_ly(Combined_data_file_for_graph, x=~Time, y=Combined_data_file_for_graph$umol.l,
color = ~ ID ,
colors = "Set2",
type= "scatter",
mode= "markers",
hovertext= ~sample)%>%
layout(title= 'Blood concentration comparison dose = 50mg/kg/bw',
xaxis= list(title= 'Time (hours)'),
yaxis= list(title= 'Cinnamaldehyde concentration in umol/l', type="log"),
legend =list(title= list(text='Type of Data')))
p1
g <- ggplot(Combined_data_file_for_graph,aes(Time,umol.l,color=ID))
g + geom_point()+ scale_y_continuous(trans='log10')+
labs(subtitle="oral 50 mg/kg/bw dose",
y="Cinnamaldehyde concentration in umol/l",
x="Time in Hours",
title="Cinnamaldehyde concentration in blood",
caption="PBK model")
Yong_data <- Combined_data_file_for_graph[1:13,]
SIM_data<- Combined_data_file_for_graph[c(15,16,17,19,22,24,29,34,44,54,74,94,134),]
SIM_data_ka<- Combined_data_file_for_graph[c(136,137,138,140,143,145,150,155,165,175,195,215,255),]
SIM_data[,3]<- as.data.frame(Yong_data[,2])
SIM_data[,4]<- as.data.frame(SIM_data_ka[,2])
colnames(SIM_data)<- c("Time","sim","Yong","simka")
RMSE_sim_Yong<-sqrt(mean((SIM_data$sim - SIM_data$Yong)^2))
RMSD_sim_Yong<-rmsd(a=SIM_data$sim, b=SIM_data$Yong)
p <-ggplot(SIM_data, aes(x=SIM_data$sim, y=SIM_data$Yong)) +
geom_point(size=3) +
geom_abline(intercept=0, slope=1) +
geom_line(data=tibble(x=c(0, 5),y=c(0,5)),
aes(x=x,y=y),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 5),y=c(0,5)),linetype = "dashed",
aes(x=x,y=y*2),
inherit.aes = FALSE)+
geom_line(data=tibble(x=c(0, 5),y=c(0,5)),linetype = "dashed",
aes(x=x,y=y*0.5),
inherit.aes = FALSE)+
labs(x='Predicted Values(μmol/L)', y='Actual Values(μmol/L)', title='Predicted vs. Actual Values 50mg/kg-BW oral dose',subtitle="Yong et al 2020" )+
theme_classic()+