precise dapt survey

able(date_table)

# carica pacchetti
library(readxl)
library(tableone)
library(DescTools)
DescToolsOptions(Fmt(digits=1)) # questo per aggiustare cifre decimali
library(chron)
library(tidyr)
library(ggplot2)
library(knitr)
library(lubridate)

Caricamento pacchetto: 'lubridate'
I seguenti oggetti sono mascherati da 'package:chron':

    days, hours, minutes, seconds, years
I seguenti oggetti sono mascherati da 'package:base':

    date, intersect, setdiff, union
library(plotly)

Caricamento pacchetto: 'plotly'
Il seguente oggetto è mascherato da 'package:ggplot2':

    last_plot
Il seguente oggetto è mascherato da 'package:stats':

    filter
Il seguente oggetto è mascherato da 'package:graphics':

    layout
library(dplyr)

Caricamento pacchetto: 'dplyr'
I seguenti oggetti sono mascherati da 'package:stats':

    filter, lag
I seguenti oggetti sono mascherati da 'package:base':

    intersect, setdiff, setequal, union
library(countrycode)
library(qwraps2)
db <- read_excel("dataset_survey.xlsx")
db <- as.data.frame(db)
db_original <- db
db$Year <- as.factor(db$Year)
db1 <- db[,c("Age", "Haemoglobin",  "WBC",  "Creatinine_Clearance", "Prior_bleeding",
             "Score",   "Cluster_risk", "Stent_type",   "Stent_brand",  "Stent_brand2",
             "Stent_Size",  "Stent_Lenght", "Polymer",  "Drug", "Stent_number",
             "strategy_change", "dapt_duration",    "DAPT_Long_Short",  "Concordance",
             "Antiplatelet_agents", "Year", "alternative_score")] 
# rinomino così ho un db pulito da date/time
db1$hbr <- if_else (db$Cluster_risk == "High", 1, 0, missing = NULL)
db1 <- as.data.frame(db1)
tone <- TOne(db1, add.length = TRUE, intref = "high", grp = db1$hbr,
     fmt = list(abs = Fmt("abs"), num  = Fmt("num"), per = Fmt("per"), TEST = TRUE,
                pval = as.fmt(fmt = "*", na.form = "")) )
Warning in chisq.test(table(x, g)): L'approssimazione al Chi-quadrato potrebbe
essere inesatta

Warning in chisq.test(table(x, g)): L'approssimazione al Chi-quadrato potrebbe
essere inesatta

Warning in chisq.test(table(x, g)): L'approssimazione al Chi-quadrato potrebbe
essere inesatta

Warning in chisq.test(table(x, g)): L'approssimazione al Chi-quadrato potrebbe
essere inesatta

Warning in chisq.test(table(x, g)): L'approssimazione al Chi-quadrato potrebbe
essere inesatta
kable(tone)
var total 0 1
n 1’215 511 (42.1%) 704 (57.9%)
Age 68 (13) 62 (11) 72 (13) *** ’
Haemoglobin 12 (2) 14 (2) 12 (2) *** ’
WBC 9 (8) 9 (6) 10 (10) *** ’
Creatinine_Clearance 58 (31) 81 (19) 42 (28) *** ’
Prior_bleeding (= 1) 201 (16.5%) 0 (0.0%) 201 (28.6%) *** ”
Score 30 (18) 14 (7) 42 (14) *** ’
Cluster_risk *** “”
High 704 (57.9%) 0 (0.0%) 704 (100.0%)
Low 327 (26.9%) 327 (64.0%) 0 (0.0%)
Moderate 184 (15.1%) 184 (36.0%) 0 (0.0%)
Stent_type “”
BMS 57 (5.5%) 24 (5.3%) 33 (5.6%)
BRS 10 (1.0%) 4 (0.9%) 6 (1.0%)
DES 974 (93.6%) 424 (93.8%) 550 (93.4%)
Stent_brand . “”
Absorb 1 (0.4%) 1 (0.7%) 0 (0.0%)
Angiolite 1 (0.4%) 0 (0.0%) 1 (0.7%)
BioFreedom 14 (5.0%) 1 (0.7%) 13 (9.0%)
Biomatrix 4 (1.4%) 3 (2.2%) 1 (0.7%)
Biomime 3 (1.1%) 1 (0.7%) 2 (1.4%)
Combo 4 (1.4%) 1 (0.7%) 3 (2.1%)
Cre8 10 (3.6%) 2 (1.5%) 8 (5.6%)
Cypher 3 (1.1%) 0 (0.0%) 3 (2.1%)
Driver 1 (0.4%) 0 (0.0%) 1 (0.7%)
Evermine 2 (0.7%) 0 (0.0%) 2 (1.4%)
Firebird 7 (2.5%) 3 (2.2%) 4 (2.8%)
Firehawk 1 (0.4%) 1 (0.7%) 0 (0.0%)
Orsiro 23 (8.3%) 12 (9.0%) 11 (7.6%)
Promus 27 (9.7%) 16 (11.9%) 11 (7.6%)
Rebel 1 (0.4%) 0 (0.0%) 1 (0.7%)
Resolute 56 (20.1%) 32 (23.9%) 24 (16.7%)
Stentys 1 (0.4%) 0 (0.0%) 1 (0.7%)
Synergy 31 (11.2%) 17 (12.7%) 14 (9.7%)
Tsunami Gold 1 (0.4%) 1 (0.7%) 0 (0.0%)
Ultimaster 29 (10.4%) 13 (9.7%) 16 (11.1%)
Xience 58 (20.9%) 30 (22.4%) 28 (19.4%)
Stent_brand2 “”
BioFreedom Ultra 2 (2.4%) 0 (0.0%) 2 (5.3%)
Cre8 Evo 3 (3.6%) 1 (2.2%) 2 (5.3%)
Endeavor Resolute 1 (1.2%) 0 (0.0%) 1 (2.6%)
Orsiro Mission 1 (1.2%) 1 (2.2%) 0 (0.0%)
Promus Element 7 (8.4%) 4 (8.9%) 3 (7.9%)
Promus Premiere 11 (13.3%) 8 (17.8%) 3 (7.9%)
Rebel 1 (1.2%) 0 (0.0%) 1 (2.6%)
Resolute Integrity 7 (8.4%) 4 (8.9%) 3 (7.9%)
Resolute Onyx 31 (37.3%) 19 (42.2%) 12 (31.6%)
Ultimaster Tansei 1 (1.2%) 1 (2.2%) 0 (0.0%)
Xience Alpine 1 (1.2%) 1 (2.2%) 0 (0.0%)
Xience Sierra 1 (1.2%) 0 (0.0%) 1 (2.6%)
Xience Alpine 4 (4.8%) 2 (4.4%) 2 (5.3%)
Xience Pro 2 (2.4%) 1 (2.2%) 1 (2.6%)
Xience Sierra 6 (7.2%) 1 (2.2%) 5 (13.2%)
Xience v 1 (1.2%) 0 (0.0%) 1 (2.6%)
Xience Xpedition 3 (3.6%) 2 (4.4%) 1 (2.6%)
Stent_Size 3 (0) 3 (0) 3 (0)
Stent_Lenght 24 (8) 26 (8) 23 (8)
Polymer ** “”
Anti CD-3 4 (2.7%) 1 (1.5%) 3 (3.7%)
Bioresorbable 37 (24.8%) 19 (27.9%) 18 (22.2%)
Durable 84 (56.4%) 45 (66.2%) 39 (48.1%)
No 24 (16.1%) 3 (4.4%) 21 (25.9%)
Drug . “”
Amphillimus 10 (6.4%) 2 (2.9%) 8 (9.2%)
Biolimus 18 (11.5%) 4 (5.7%) 14 (16.1%)
Everolimus 48 (30.6%) 22 (31.4%) 26 (29.9%)
Paclitaxel 1 (0.6%) 1 (1.4%) 0 (0.0%)
Sirolimus 41 (26.1%) 18 (25.7%) 23 (26.4%)
Zotarolimus 39 (24.8%) 23 (32.9%) 16 (18.4%)
Stent_number 2 (1) 2 (1) 2 (1) * ’
strategy_change (= Yes) 642 (62.1%) 222 (49.4%) 420 (71.8%) *** ”
dapt_duration 10 (7) 12 (8) 9 (5) *** ’
DAPT_Long_Short *** “”
<12 426 (37.4%) 126 (25.1%) 300 (47.0%)
>12 110 (9.7%) 82 (16.4%) 28 (4.4%)
12 603 (52.9%) 293 (58.5%) 310 (48.6%)
Concordance *** “”
Concordance 666 (58.5%) 375 (74.9%) 291 (45.6%)
Discordance Less 126 (11.1%) 126 (25.1%) 0 (0.0%)
Discordance More 347 (30.5%) 0 (0.0%) 347 (54.4%)
Antiplatelet_agents *** “”
ASA+Clopidogrel 570 (53.7%) 221 (47.0%) 349 (59.0%)
ASA+Prasugrel 61 (5.7%) 29 (6.2%) 32 (5.4%)
ASA+Ticagrelor 380 (35.8%) 198 (42.1%) 182 (30.7%)
Other 51 (4.8%) 22 (4.7%) 29 (4.9%)
Year “”
2017 299 (24.6%) 121 (23.7%) 178 (25.3%)
2018 220 (18.1%) 86 (16.8%) 134 (19.0%)
2019 206 (17.0%) 96 (18.8%) 110 (15.6%)
2020 164 (13.5%) 78 (15.3%) 86 (12.2%)
2021 229 (18.8%) 87 (17.0%) 142 (20.2%)
2022 97 (8.0%) 43 (8.4%) 54 (7.7%)
alternative_score 32 (21) 13 (8) 46 (16) *** ’
hbr (= 1) 704 (57.9%) 0 (0.0%) 704 (100.0%) *** ”
#inzio figure
#aggiungo dati per anno a tabella
# tone1 <- TOne(db1, add.length = TRUE, intref = "high", grp = db1$strategy_change,
#      fmt = list(abs = Fmt("abs"), num  = Fmt("num"), per = Fmt("per"), TEST = TRUE,
#                 pval = as.fmt(fmt = "*", na.form = "")) )
# kable(tone1)

# date_table <- data.frame(table(db$Year))
# date_table$strategy_no <- c(106, 51, 68, 55, 81, 31)
# date_table$strategy_si <- c(111, 138, 119, 92, 123, 59)
# date_table$daptless12 <- c(71, 91, 73, 59, 90, 42)
# date_table$dapt12 <- c(135, 111, 100, 88, 120, 49)
# date_table$daptmore12 <- c(29, 16, 30, 13, 17, 5)
# date_table$concordance <- c(133, 128, 113, 98, 130, 64)
# date_table$discordanceless <- c(25, 23, 27, 18, 23, 10)
# date_table$discordancemore <- c(77, 67, 63, 44, 74, 22)
# 
# 
# 
# #FIGURE INIZIALI NON DEFINITIVE -> GRAFICI A LINEE
# figure1 <- ggplot(date_table, aes(x=Var1, y=strategy_no)) +
#   geom_line(aes(x = Var1, y = strategy_no), size = 1, color="red", group = 1) +
#   geom_line(aes(x = Var1, y = strategy_si), size = 1, color="blue", group = 1) 
# 
# figure1 <- figure1 + theme(panel.background = element_rect(fill = 'white', color = 'black')) 
# figure1 <- figure1 + labs (y= "Did Score change yout attitude?", x = "")
# figure1
# 
# 
# figure2 <- ggplot(date_table) +
#   geom_line(aes(x = Var1, y = daptless12), size = 1, color="red", group = 1) +
#   geom_line(aes(x = Var1, y = dapt12), size = 1, color="blue", group = 1) +
#   geom_line(aes(x = Var1, y = daptmore12), size = 1, color="green", group = 1) 
# 
# figure2 <- figure2 + theme(panel.background = element_rect(fill = 'white', color = 'black')) 
# figure2 <- figure2 + labs (y= "Treatment duration assigned", x = "")
# figure2
# 
# figure3 <- ggplot(date_table) +
#   geom_line(aes(x = Var1, y = concordance), size = 1, color="red", group = 1) +
#   geom_line(aes(x = Var1, y = discordanceless), size = 1, color="blue", group = 1) +
#   geom_line(aes(x = Var1, y = discordancemore), size = 1, color="green", group = 1) 
# 
# figure3 <- figure3 + theme(panel.background = element_rect(fill = 'white', color = 'black')) 
# figure3 <- figure3 + labs (y= "Concordance/Discordance", x = "")
# figure3
# 
# library("writexl")
# write_xlsx(date_table,"date-table-survey.xlsx")

#INIZIO FIGURE CON PERCENTUALI E DEFINITIVE
date_table_per <- read_excel("date-table-per-survey.xlsx")
figure1per <- ggplot(date_table_per, aes(x=Var1, y=strategy_si)) +
  geom_line(aes(x = Var1, y = strategy_si), size = 1, color="#5c67ae", group = 1) +
  geom_point(aes(x = Var1, y = strategy_si), size = 3, color="#5b79b8", group = 1)
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
figure1per <- figure1per + theme_light() 
figure1per <- figure1per + ggtitle("Did Score change your attitude?") +
  theme(plot.title = element_text(hjust = 0.5)) + labs (y= "Changing DAPT Strategy (%)", x = "")
# figura 1 survey definitiva
figure1per

#date_table_per <- read_excel("date-table-per-survey.xlsx")
# figure2per <- ggplot(date_table_per, aes(x=Var1)) +
#   geom_line(aes(x = Var1, y = daptless12), size = 1, color="red", group = 1) +
#   geom_line(aes(x = Var1, y = dapt12), size = 1, color="blue", group = 1) +
#   geom_line(aes(x = Var1, y = daptmore12), size = 1, color="green", group = 1) 
# 
# figure2per <- figure2per + theme_linedraw() 
# figure2per <- figure2per + labs (y= "Treatment duration assigned overtime", x = "")
# figure2per
# 
# 
# figure3per <- ggplot(date_table_per) +
#   geom_line(aes(x = Var1, y = concordance), size = 1, color="red", group = 1) +
#   geom_line(aes(x = Var1, y = discordanceless), size = 1, color="blue", group = 1) +
#   geom_line(aes(x = Var1, y = discordancemore), size = 1, color="green", group = 1) 
# 
# figure3per <- figure3per + theme_linedraw() 
# figure3per <- figure3per + labs (y= "Concordance/Discordance", x = "")
# figure3per




date_table_per_new <- read_excel("date-table-per-survey1.xlsx")

figure1perbar <- ggplot(date_table_per_new, aes(fill=Strategy, y=value_strategy, x=Var1)) +
    geom_bar(position="stack", stat="identity")
figure1perbar <- figure1perbar + theme_linedraw() 
figure1perbar <- figure1perbar + labs (y= "Did Score change yout attitude?", x = "")
figure1perbar
Warning: Removed 6 rows containing missing values (`position_stack()`).

cols <- c("< 12 Months" = "#3aade0", "12 Months" = "#5b79b8", "> 12 Months" = "#5c67ae")
figure2perbar <- ggplot(date_table_per_new, aes(fill=`DAPT Duration`, color=`DAPT Duration`, y=value_dapt, x=Var1)) + geom_bar(position="stack", stat="identity") 
figure2perbar <- figure2perbar + theme_light() + scale_colour_manual(values = cols, aesthetics = c("colour", "fill"))
figure2perbar <- figure2perbar + ggtitle("Treatment duration assigned over time") +
  theme(plot.title = element_text(hjust = 0.5)) + labs (y= "DAPT Duration (%)", x = "")
#figura 2 DEFINITIVA
figure2perbar

cols2 <- c("Discordance Less" = "#3aade0", "Concordance" = "#5b79b8", "Discordance Excess" = "#5c67ae")
figure3perbar <- ggplot(date_table_per_new, aes(fill=concordance, color=concordance, y=value_concordance, x=Var1)) + 
    geom_bar(position="stack", stat="identity")
figure3perbar <- figure3perbar + theme_light() + scale_colour_manual(values = cols2, aesthetics = c("colour", "fill")) 
figure3perbar <- figure3perbar + ggtitle("Concordance Score - Assigned DAPT over time") +
  theme(plot.title = element_text(hjust = 0.5)) + labs (y= "Concordance/Discordance (%)", x = "")
#figura 3 DEFINITIVA
figure3perbar