library(DescTools)
library(ggpubr)
## Loading required package: ggplot2
## Loading required package: magrittr
library(rcompanion)
library(gridExtra)
options(scipen = 999)
t = "C:\\Users\\Admin\\Google Drive\\HOC TAP\\NCKH\\Data ung thu\\Viet bai\\R code\\Xu ly du lieu lan 2\\thoigian_folfox2.csv"
duy = read.csv(t)
duy1 = subset(duy, duy$hoachat != "5-FU bolus")
duy2 = subset(duy, duy$hoachat == "5-FU bolus")
attach(duy)
head(duy)
##   bv  phacdo    hoachat thoigian drp drp_thoigian
## 1 TB FOLFOX4 5-FU bolus      400  Co      DRP-Cao
## 2 TB FOLFOX4 5-FU bolus      400  Co      DRP-Cao
## 3 TB FOLFOX4 5-FU bolus      400  Co      DRP-Cao
## 4 TB FOLFOX4 5-FU bolus      400  Co      DRP-Cao
## 5 TB FOLFOX4 5-FU bolus      400  Co      DRP-Cao
## 6 TB FOLFOX4 5-FU bolus      400  Co      DRP-Cao

Thống kê thời gian truyền hóa chất theo phác đồ

Desc(phacdo ~ hoachat, data = duy)
## ------------------------------------------------------------------------------ 
## phacdo ~ hoachat
## 
## 
## Summary: 
## n: 3'870, rows: 2, columns: 4
## 
## Pearson's Chi-squared test:
##   X-squared = 59.282, df = 3, p-value = 0.0000000000008366
## Likelihood Ratio:
##   X-squared = 55.49, df = 3, p-value = 0.000000000005397
## Mantel-Haenszel Chi-squared:
##   X-squared = 29.907, df = 1, p-value = 0.00000004533
## 
## Phi-Coefficient        0.124
## Contingency Coeff.     0.123
## Cramer's V             0.124
## 
##                                                                            
##            hoachat   5-FU bolus   5-FU iv   leucovorin   oxaliplatin    Sum
## phacdo                                                                     
##                                                                            
## FOLFOX4    freq             828       828          828           414  2'898
##            perc           21.4%     21.4%        21.4%         10.7%  74.9%
##            p.row          28.6%     28.6%        28.6%         14.3%      .
##            p.col          77.3%     77.3%        77.3%         63.0%      .
##                                                                            
## mFOLFOX6   freq             243       243          243           243    972
##            perc            6.3%      6.3%         6.3%          6.3%  25.1%
##            p.row          25.0%     25.0%        25.0%         25.0%      .
##            p.col          22.7%     22.7%        22.7%         37.0%      .
##                                                                            
## Sum        freq           1'071     1'071        1'071           657  3'870
##            perc           27.7%     27.7%        27.7%         17.0% 100.0%
##            p.row              .         .            .             .      .
##            p.col              .         .            .             .      .
## 

Biểu đồ tích lũy thời gian truyền của 5-FU bolus

p1 = ggplot(duy2, aes(thoigian, colour = hoachat)) + scale_x_continuous(name = "Relative duration (%)") + scale_y_continuous(name = "Cumulative percentage of prescriptions", breaks = seq(0,1,0.2)) + stat_ecdf() + theme(legend.position="top") + theme(legend.position="top") + geom_vline(xintercept=c(85,90,110,115), linetype="dashed", color = "purple", size=1.2)
p1

Biểu đồ tích lũy thời gian truyền của 5-FU iv, Leucovorin và Oxaliplatin

p2 = ggplot(duy1, aes(thoigian, colour = hoachat)) + scale_x_continuous(name = "Relative duration (%)") + scale_y_continuous(name = "Cumulative percentage of prescriptions", breaks = seq(0,1,0.2)) + stat_ecdf() + theme(legend.position="top") + theme(legend.position="top") + geom_vline(xintercept=c(85,90,110,115), linetype="dashed", color = "purple", size=1.2) 
p2

Thống kê cho 5-FU bolus

#Biểu đồ tích lũy thời gian truyền của 5-FU bolus
fu_bolus = subset(duy, hoachat == "5-FU bolus")
fu_iv = subset(duy, hoachat == "5-FU iv")
leuco = subset(duy, hoachat == "leucovorin")
oxa = subset(duy, hoachat == "oxaliplatin")
p3 = ggplot(fu_bolus, aes(thoigian, colour = phacdo)) + scale_x_continuous(name = "Relative duration (%)") + scale_y_continuous(name = "", breaks = seq(0,1,0.2)) + stat_ecdf() + theme(legend.position="top") + theme(legend.position="top") + geom_vline(xintercept=c(85,90,110,115), linetype="dashed", color = "purple", size=1.2) + ggtitle("5-FU bolus")
p3

# Tất cả các lượt truyền đều có DRP về thời gian bolus 5-FU
Desc(drp ~ phacdo, data = fu_bolus)
## ------------------------------------------------------------------------------ 
## drp ~ phacdo
## 
## 
## Summary: 
## n: 1'071, rows: 1, columns: 2
## 
## Pearson's Chi-squared test:
##   X-squared = 319.54, df = 1, p-value < 0.00000000000000022
## Likelihood Ratio:
##   X-squared = 337.7, df = 1, p-value < 0.00000000000000022
## Mantel-Haenszel Chi-squared:
##   X-squared = NaN, df = 1, p-value = NA
## 
## Phi-Coefficient        0.546
## Contingency Coeff.     0.479
## Cramer's V             Inf
## 
##                                         
##       phacdo   FOLFOX4   mFOLFOX6    Sum
## drp                                     
##                                         
## Co    freq         828        243  1'071
##       perc       77.3%      22.7% 100.0%
##       p.row      77.3%      22.7%      .
##       p.col     100.0%     100.0%      .
##                                         
## Sum   freq         828        243  1'071
##       perc       77.3%      22.7% 100.0%
##       p.row          .          .      .
##       p.col          .          .      .
## 

Thống kê cho 5-FU iv

#Biểu đồ tích lũy thời gian truyền của 5-FU iv
p4 = ggplot(fu_iv, aes(thoigian, colour = phacdo)) + scale_x_continuous(name = "Relative duration (%)") + scale_y_continuous(name = "", breaks = seq(0,1,0.2)) + stat_ecdf() + theme(legend.position="top") + theme(legend.position="top") + geom_vline(xintercept=c(85,90,110,115), linetype="dashed", color = "purple", size=1.2) + ggtitle("5-FU iv")
p4

#So sánh DRP về thời gian truyền của 5-FU iv
#Phiên giải giá trị: Pearson's Chi-squared test (cont. adj)
Desc(drp ~ phacdo, data = fu_iv)
## ------------------------------------------------------------------------------ 
## drp ~ phacdo
## 
## 
## Summary: 
## n: 1'071, rows: 2, columns: 2
## 
## Pearson's Chi-squared test (cont. adj):
##   X-squared = 64.47, df = 1, p-value = 0.00000000000000098
## Fisher's exact test p-value = 0.00000000000004464
## McNemar's chi-squared = 46.239, df = 1, p-value = 0.00000000001047
## 
##                     estimate lwr.ci upr.ci'
##                                           
## odds ratio             4.343  2.987  6.313
## rel. risk (col1)       1.626  1.370  1.929
## rel. risk (col2)       0.374  0.302  0.464
## 
## 
## Phi-Coefficient        0.249
## Contingency Coeff.     0.241
## Cramer's V             0.249
## 
##                                           
##         phacdo   FOLFOX4   mFOLFOX6    Sum
## drp                                       
##                                           
## Co      freq         760        175    935
##         perc       71.0%      16.3%  87.3%
##         p.row      81.3%      18.7%      .
##         p.col      91.8%      72.0%      .
##                                           
## Khong   freq          68         68    136
##         perc        6.3%       6.3%  12.7%
##         p.row      50.0%      50.0%      .
##         p.col       8.2%      28.0%      .
##                                           
## Sum     freq         828        243  1'071
##         perc       77.3%      22.7% 100.0%
##         p.row          .          .      .
##         p.col          .          .      .
##                                           
## 
## ----------
## ' 95% conf. level

#Thống kê DPR về thời gian truyền của 5-FU iv
Desc(drp_thoigian ~ phacdo, data = fu_iv)
## ------------------------------------------------------------------------------ 
## drp_thoigian ~ phacdo
## 
## 
## Summary: 
## n: 1'071, rows: 3, columns: 2
## 
## Pearson's Chi-squared test:
##   X-squared = 170.96, df = 2, p-value < 0.00000000000000022
## Likelihood Ratio:
##   X-squared = 151.09, df = 2, p-value < 0.00000000000000022
## Mantel-Haenszel Chi-squared:
##   X-squared = 9.9238, df = 1, p-value = 0.001632
## 
## Phi-Coefficient        0.400
## Contingency Coeff.     0.371
## Cramer's V             0.400
## 
##                                                  
##                phacdo   FOLFOX4   mFOLFOX6    Sum
## drp_thoigian                                     
##                                                  
## DRP-Cao        freq           0         27     27
##                perc        0.0%       2.5%   2.5%
##                p.row       0.0%     100.0%      .
##                p.col       0.0%      11.1%      .
##                                                  
## DRP-Thap       freq         760        148    908
##                perc       71.0%      13.8%  84.8%
##                p.row      83.7%      16.3%      .
##                p.col      91.8%      60.9%      .
##                                                  
## Khong          freq          68         68    136
##                perc        6.3%       6.3%  12.7%
##                p.row      50.0%      50.0%      .
##                p.col       8.2%      28.0%      .
##                                                  
## Sum            freq         828        243  1'071
##                perc       77.3%      22.7% 100.0%
##                p.row          .          .      .
##                p.col          .          .      .
## 

Thống kê cho Leucovorin

#Biểu đồ tích lũy thời gian truyền của Leucovorin
p5 = ggplot(leuco, aes(thoigian, colour = phacdo)) + scale_x_continuous(name = "Relative duration (%)") + scale_y_continuous(name = "", breaks = seq(0,1,0.2)) + stat_ecdf() + theme(legend.position="top") + theme(legend.position="top") + geom_vline(xintercept=c(85,90,110,115), linetype="dashed", color = "purple", size=1.2) + ggtitle("Leucovorin")
p5

#So sánh DRP về thời gian truyền của Leucovorin
#Phiên giải giá trị: Pearson's Chi-squared test (cont. adj)
Desc(drp ~ phacdo, data = leuco)
## ------------------------------------------------------------------------------ 
## drp ~ phacdo
## 
## 
## Summary: 
## n: 1'071, rows: 2, columns: 2
## 
## Pearson's Chi-squared test (cont. adj):
##   X-squared = 617.41, df = 1, p-value < 0.00000000000000022
## Fisher's exact test p-value < 0.00000000000000022
## McNemar's chi-squared = 439.56, df = 1, p-value < 0.00000000000000022
## 
##                     estimate   lwr.ci   upr.ci'
##                                               
## odds ratio           0.00358  0.00154  0.00835
## rel. risk (col1)     0.03896  0.01775  0.08550
## rel. risk (col2)    10.87470  8.80449 13.43170
## 
## 
## Phi-Coefficient        0.762
## Contingency Coeff.     0.606
## Cramer's V             0.762
## 
##                                           
##         phacdo   FOLFOX4   mFOLFOX6    Sum
## drp                                       
##                                           
## Co      freq           6        163    169
##         perc        0.6%      15.2%  15.8%
##         p.row       3.6%      96.4%      .
##         p.col       0.7%      67.1%      .
##                                           
## Khong   freq         822         80    902
##         perc       76.8%       7.5%  84.2%
##         p.row      91.1%       8.9%      .
##         p.col      99.3%      32.9%      .
##                                           
## Sum     freq         828        243  1'071
##         perc       77.3%      22.7% 100.0%
##         p.row          .          .      .
##         p.col          .          .      .
##                                           
## 
## ----------
## ' 95% conf. level

#Thống kê DPR về thời gian truyền của Leucovorin
Desc(drp_thoigian ~ phacdo, data = leuco)
## ------------------------------------------------------------------------------ 
## drp_thoigian ~ phacdo
## 
## 
## Summary: 
## n: 1'071, rows: 3, columns: 2
## 
## Pearson's Chi-squared test:
##   X-squared = 622.93, df = 2, p-value < 0.00000000000000022
## Likelihood Ratio:
##   X-squared = 559.39, df = 2, p-value < 0.00000000000000022
## Mantel-Haenszel Chi-squared:
##   X-squared = 554.03, df = 1, p-value < 0.00000000000000022
## 
## Phi-Coefficient        0.763
## Contingency Coeff.     0.606
## Cramer's V             0.763
## 
##                                                  
##                phacdo   FOLFOX4   mFOLFOX6    Sum
## drp_thoigian                                     
##                                                  
## DRP-Cao        freq           0         52     52
##                perc        0.0%       4.9%   4.9%
##                p.row       0.0%     100.0%      .
##                p.col       0.0%      21.4%      .
##                                                  
## DRP-Thap       freq           6        111    117
##                perc        0.6%      10.4%  10.9%
##                p.row       5.1%      94.9%      .
##                p.col       0.7%      45.7%      .
##                                                  
## Khong          freq         822         80    902
##                perc       76.8%       7.5%  84.2%
##                p.row      91.1%       8.9%      .
##                p.col      99.3%      32.9%      .
##                                                  
## Sum            freq         828        243  1'071
##                perc       77.3%      22.7% 100.0%
##                p.row          .          .      .
##                p.col          .          .      .
## 

Thống kê cho Oxaliplatin

#Biểu đồ tích lũy thời gian truyền của Oxaliplatin
p6 = ggplot(oxa, aes(thoigian, colour = phacdo)) + scale_x_continuous(name = "Relative duration (%)") + scale_y_continuous(name = "", breaks = seq(0,1,0.2)) + stat_ecdf() + theme(legend.position="top") + theme(legend.position="top") + geom_vline(xintercept=c(85,90,110,115), linetype="dashed", color = "purple", size=1.2) + ggtitle("Oxaliplatin")
p6

#So sánh DRP về thời gian truyền của oxaliplatin
#Phiên giải giá trị: Pearson's Chi-squared test (cont. adj)
Desc(drp ~ phacdo, data = oxa)
## ------------------------------------------------------------------------------ 
## drp ~ phacdo
## 
## 
## Summary: 
## n: 657, rows: 2, columns: 2
## 
## Pearson's Chi-squared test (cont. adj):
##   X-squared = 460.98, df = 1, p-value < 0.00000000000000022
## Fisher's exact test p-value < 0.00000000000000022
## McNemar's chi-squared = 78.293, df = 1, p-value < 0.00000000000000022
## 
##                       estimate     lwr.ci     upr.ci'
##                                                     
## odds ratio           0.0006116  0.0000838  0.0044614
## rel. risk (col1)     0.0057366  0.0008120  0.0405306
## rel. risk (col2)     9.3802198  7.1971197 12.2255189
## 
## 
## Phi-Coefficient        0.841
## Contingency Coeff.     0.644
## Cramer's V             0.841
## 
##                                           
##         phacdo   FOLFOX4   mFOLFOX6    Sum
## drp                                       
##                                           
## Co      freq           1        194    195
##         perc        0.2%      29.5%  29.7%
##         p.row       0.5%      99.5%      .
##         p.col       0.2%      79.8%      .
##                                           
## Khong   freq         413         49    462
##         perc       62.9%       7.5%  70.3%
##         p.row      89.4%      10.6%      .
##         p.col      99.8%      20.2%      .
##                                           
## Sum     freq         414        243    657
##         perc       63.0%      37.0% 100.0%
##         p.row          .          .      .
##         p.col          .          .      .
##                                           
## 
## ----------
## ' 95% conf. level

#Thống kê DPR về thời gian truyền của oxaliplatin
Desc(drp_thoigian ~ phacdo, data = oxa)
## ------------------------------------------------------------------------------ 
## drp_thoigian ~ phacdo
## 
## 
## Summary: 
## n: 657, rows: 2, columns: 2
## 
## Pearson's Chi-squared test (cont. adj):
##   X-squared = 460.98, df = 1, p-value < 0.00000000000000022
## Fisher's exact test p-value < 0.00000000000000022
## McNemar's chi-squared = 78.293, df = 1, p-value < 0.00000000000000022
## 
##                       estimate     lwr.ci     upr.ci'
##                                                     
## odds ratio           0.0006116  0.0000838  0.0044614
## rel. risk (col1)     0.0057366  0.0008120  0.0405306
## rel. risk (col2)     9.3802198  7.1971197 12.2255189
## 
## 
## Phi-Coefficient        0.841
## Contingency Coeff.     0.644
## Cramer's V             0.841
## 
##                                                  
##                phacdo   FOLFOX4   mFOLFOX6    Sum
## drp_thoigian                                     
##                                                  
## DRP-Cao        freq           1        194    195
##                perc        0.2%      29.5%  29.7%
##                p.row       0.5%      99.5%      .
##                p.col       0.2%      79.8%      .
##                                                  
## Khong          freq         413         49    462
##                perc       62.9%       7.5%  70.3%
##                p.row      89.4%      10.6%      .
##                p.col      99.8%      20.2%      .
##                                                  
## Sum            freq         414        243    657
##                perc       63.0%      37.0% 100.0%
##                p.row          .          .      .
##                p.col          .          .      .
##                                                  
## 
## ----------
## ' 95% conf. level

grid.arrange(p3, p4, p5,p6 + rremove("x.text"), ncol = 2, nrow = 2)