Data Processing

Read .xlsx file “Sintesi Dati Pazienti”

require("xlsx")
VDS <- read.xlsx("./Sintesi Dati Pazienti.xlsx",sheetIndex = 1, startRow =  2,)

Fix variables name

str(VDS)
## 'data.frame':    129 obs. of  42 variables:
##  $ Patient.ID                           : num  1 2 3 4 5 6 7 8 9 10 ...
##  $ DATA.NASCITA                         : Factor w/ 127 levels "10231","11324",..: 19 33 106 49 122 51 4 100 63 55 ...
##  $ BMI                                  : num  24 27 25 24 28 29 26 23 24 28 ...
##  $ Sesso                                : Factor w/ 4 levels "f","F","m","M": 2 2 4 4 4 4 4 4 4 4 ...
##  $ Rischio..secondario.iniziale         : num  44 21 54 54 5 56 39 13 27 51 ...
##  $ Procedura                            : Factor w/ 23 levels "bpac","BPAC",..: 2 23 15 13 2 2 2 2 15 2 ...
##  $ n.coronarie.critiche                 : num  2 1 2 3 1 3 2 3 1 2 ...
##  $ Complicanze.perioperatorie           : Factor w/ 2 levels "no","si": 1 2 2 1 1 1 1 1 1 1 ...
##  $ Infezioni                            : Factor w/ 3 levels "n","no","si": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Compromissione.meccanica.respiratoria: Factor w/ 3 levels "no","si","Si": 3 2 2 3 1 3 3 3 3 1 ...
##  $ Anemia                               : Factor w/ 3 levels "no","si","Si": 3 1 2 3 3 3 3 3 3 3 ...
##  $ Disturbi.neurologici                 : Factor w/ 3 levels "no","NO","si": 2 1 1 2 2 2 2 2 2 2 ...
##  $ Scompenso.diabetico                  : Factor w/ 3 levels "no","si","Si": 3 1 2 1 1 2 2 2 1 1 ...
##  $ Versamento.pleurico                  : Factor w/ 4 levels "n","no","si",..: 4 3 2 4 2 4 2 4 4 2 ...
##  $ Versamento.Pericardico               : Factor w/ 5 levels "no","NO","s",..: 2 4 1 2 2 2 2 4 2 2 ...
##  $ Trombo.embolismo                     : Factor w/ 3 levels "no","NO","si": 2 1 1 2 2 2 2 2 2 2 ...
##  $ ComorbiditÃ..pregresse               : Factor w/ 3 levels "no","si","Si": 3 2 2 3 1 3 3 3 3 1 ...
##  $ Barthel.Index                        : num  66 72 85 85 85 85 77 85 85 85 ...
##  $ MRC.Dyspnea.Scale                    : num  3 2 0 1 0 1 0 0 0 0 ...
##  $ FEV1                                 : num  50 55 65 50 68 55 50 55 65 65 ...
##  $ X6MWT                                : num  82 240 361 200 335 234 234 382 480 304 ...
##  $ BORG                                 : num  17 15 13 15 15 13 14 12 8 13 ...
##  $ Antipertensivi                       : Factor w/ 4 levels "no","s","si",..: 4 4 1 4 1 4 1 4 1 4 ...
##  $ Antidiabetici.insulina               : Factor w/ 3 levels "no","si","Si": 3 3 2 1 1 3 3 3 1 1 ...
##  $ Betabloccanti.Ivabradina             : Factor w/ 3 levels "no","si","Si": 3 2 2 1 3 3 3 3 3 3 ...
##  $ Nitroderivati                        : Factor w/ 4 levels "n","no","NO",..: 3 2 2 4 4 4 4 2 2 4 ...
##  $ Diuretici                            : Factor w/ 3 levels "no","si","Si": 3 2 2 3 3 3 3 1 3 3 ...
##  $ Inotropi                             : Factor w/ 2 levels "no","si": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Antiaritmici                         : Factor w/ 3 levels "no","NO","si": 2 1 1 3 2 3 2 3 2 3 ...
##  $ Anticoagulanti.Antiaggreganti        : Factor w/ 3 levels "n","si","Si": 3 2 2 3 3 3 3 3 3 1 ...
##  $ Psicoattivi                          : Factor w/ 2 levels "no","si": 1 1 1 1 1 2 1 1 1 1 ...
##  $ Altri.farmaci                        : Factor w/ 2 levels "si","Si": 2 1 1 2 2 2 2 2 2 2 ...
##  $ Classe.di.rischio                    : Factor w/ 4 levels "alto","basso",..: 1 1 4 1 1 1 1 4 2 1 ...
##  $ BMI.1                                : num  23 26 24 23 27 28 27 21 23 27 ...
##  $ Rischio.secondario..finale.          : num  30 20 19 14 5 12 21 8 24 18 ...
##  $ Barthel.Index.1                      : num  90 93 95 95 95 93 90 95 95 95 ...
##  $ MRC.Dyspnea.Scale.1                  : num  0 1 0 0 0 0 0 0 0 0 ...
##  $ FEV1.1                               : num  65 64 65 70 70 60 64 70 70 70 ...
##  $ X6MWT.1                              : num  155 264 480 330 470 300 400 474 500 460 ...
##  $ BORG.1                               : num  11 13 11 13 11 12 12 11 11 11 ...
##  $ Classe.di.rischio.1                  : Factor w/ 4 levels "alto","basso",..: 1 1 2 1 2 1 4 2 2 4 ...
##  $ Tipologia.riabilitazione             : Factor w/ 4 levels "A","B","C","D": 4 4 2 4 3 4 3 1 1 3 ...
names(VDS) <- gsub(pattern = "\\.(\\.)?",replacement = "_",x = names(VDS))
names(VDS) <- gsub(pattern = "_1",replacement = "_U",x = names(VDS))
names(VDS) <- gsub(pattern = "X6",replacement = "Six",x = names(VDS))
names(VDS) <- tolower(names(VDS))
names(VDS)[17] <- "comorbidità_pregresse"
#head(VDS)

# store a dataset copy
VDS_bkp <- VDS

Convert Date

# Fix data nascita pts nr. 84
VDS$data_nascita <- as.numeric(as.character(VDS$data_nascita))
## Warning: si è prodotto un NA per coercizione
VDS[VDS$patient_id==84,"data_nascita"] <- 11076
VDS$data_nascita <- as.Date(as.numeric(VDS$data_nascita), origin="1900-01-01")
summary(VDS$data_nascita)
##         Min.      1st Qu.       Median         Mean      3rd Qu.         Max. 
## "1928-01-06" "1939-01-03" "1946-07-08" "1946-06-29" "1952-09-13" "1971-09-01"
require(lubridate)
## Loading required package: lubridate
VDS$age <- 2014 - year(VDS$data_nascita)

Fix Categorical variables (Si/No): set values to lower case and change n->no, y->yes, media->medio

# values
require(plyr)
for(i in c(4,8:17,23:32)) {
      VDS[,i] <- tolower(VDS[,i])
      VDS[,i] <- factor(revalue(x = VDS[,i],replace = c(n="no",s="si",sno="no")))
          
}
VDS$classe_di_rischio <- factor(revalue(VDS$classe_di_rischio, c(media="medio")))
VDS$classe_di_rischio_u <- factor(revalue(VDS$classe_di_rischio_u, c(media="medio")))

VDS$classe_di_rischio <- factor(VDS$classe_di_rischio,levels = levels(VDS$classe_di_rischio),labels = c("alto","medio","basso"),ordered = T)
VDS$classe_di_rischio_u <- factor(VDS$classe_di_rischio_u,levels = levels(VDS$classe_di_rischio_u),labels = c("alto","medio","basso"),ordered = T)
names(VDS)[5] <- "rischio_secondario"
names(VDS)[35] <- "rischio_secondario_u"
str(VDS)
## 'data.frame':    129 obs. of  43 variables:
##  $ patient_id                           : num  1 2 3 4 5 6 7 8 9 10 ...
##  $ data_nascita                         : Date, format: "1936-06-06" "1939-01-09" ...
##  $ bmi                                  : num  24 27 25 24 28 29 26 23 24 28 ...
##  $ sesso                                : Factor w/ 2 levels "f","m": 1 1 2 2 2 2 2 2 2 2 ...
##  $ rischio_secondario                   : num  44 21 54 54 5 56 39 13 27 51 ...
##  $ procedura                            : Factor w/ 23 levels "bpac","BPAC",..: 2 23 15 13 2 2 2 2 15 2 ...
##  $ n_coronarie_critiche                 : num  2 1 2 3 1 3 2 3 1 2 ...
##  $ complicanze_perioperatorie           : Factor w/ 2 levels "no","si": 1 2 2 1 1 1 1 1 1 1 ...
##  $ infezioni                            : Factor w/ 2 levels "no","si": 1 1 1 1 1 1 1 1 1 1 ...
##  $ compromissione_meccanica_respiratoria: Factor w/ 2 levels "no","si": 2 2 2 2 1 2 2 2 2 1 ...
##  $ anemia                               : Factor w/ 2 levels "no","si": 2 1 2 2 2 2 2 2 2 2 ...
##  $ disturbi_neurologici                 : Factor w/ 2 levels "no","si": 1 1 1 1 1 1 1 1 1 1 ...
##  $ scompenso_diabetico                  : Factor w/ 2 levels "no","si": 2 1 2 1 1 2 2 2 1 1 ...
##  $ versamento_pleurico                  : Factor w/ 2 levels "no","si": 2 2 1 2 1 2 1 2 2 1 ...
##  $ versamento_pericardico               : Factor w/ 2 levels "no","si": 1 2 1 1 1 1 1 2 1 1 ...
##  $ trombo_embolismo                     : Factor w/ 2 levels "no","si": 1 1 1 1 1 1 1 1 1 1 ...
##  $ comorbidità_pregresse                : Factor w/ 2 levels "no","si": 2 2 2 2 1 2 2 2 2 1 ...
##  $ barthel_index                        : num  66 72 85 85 85 85 77 85 85 85 ...
##  $ mrc_dyspnea_scale                    : num  3 2 0 1 0 1 0 0 0 0 ...
##  $ fev1                                 : num  50 55 65 50 68 55 50 55 65 65 ...
##  $ sixmwt                               : num  82 240 361 200 335 234 234 382 480 304 ...
##  $ borg                                 : num  17 15 13 15 15 13 14 12 8 13 ...
##  $ antipertensivi                       : Factor w/ 2 levels "no","si": 2 2 1 2 1 2 1 2 1 2 ...
##  $ antidiabetici_insulina               : Factor w/ 2 levels "no","si": 2 2 2 1 1 2 2 2 1 1 ...
##  $ betabloccanti_ivabradina             : Factor w/ 2 levels "no","si": 2 2 2 1 2 2 2 2 2 2 ...
##  $ nitroderivati                        : Factor w/ 2 levels "no","si": 1 1 1 2 2 2 2 1 1 2 ...
##  $ diuretici                            : Factor w/ 2 levels "no","si": 2 2 2 2 2 2 2 1 2 2 ...
##  $ inotropi                             : Factor w/ 2 levels "no","si": 1 1 1 1 1 1 1 1 1 1 ...
##  $ antiaritmici                         : Factor w/ 2 levels "no","si": 1 1 1 2 1 2 1 2 1 2 ...
##  $ anticoagulanti_antiaggreganti        : Factor w/ 2 levels "no","si": 2 2 2 2 2 2 2 2 2 1 ...
##  $ psicoattivi                          : Factor w/ 2 levels "no","si": 1 1 1 1 1 2 1 1 1 1 ...
##  $ altri_farmaci                        : Factor w/ 1 level "si": 1 1 1 1 1 1 1 1 1 1 ...
##  $ classe_di_rischio                    : Ord.factor w/ 3 levels "alto"<"medio"<..: 1 1 3 1 1 1 1 3 2 1 ...
##  $ bmi_u                                : num  23 26 24 23 27 28 27 21 23 27 ...
##  $ rischio_secondario_u                 : num  30 20 19 14 5 12 21 8 24 18 ...
##  $ barthel_index_u                      : num  90 93 95 95 95 93 90 95 95 95 ...
##  $ mrc_dyspnea_scale_u                  : num  0 1 0 0 0 0 0 0 0 0 ...
##  $ fev1_u                               : num  65 64 65 70 70 60 64 70 70 70 ...
##  $ sixmwt_u                             : num  155 264 480 330 470 300 400 474 500 460 ...
##  $ borg_u                               : num  11 13 11 13 11 12 12 11 11 11 ...
##  $ classe_di_rischio_u                  : Ord.factor w/ 3 levels "alto"<"medio"<..: 1 1 2 1 2 1 3 2 2 3 ...
##  $ tipologia_riabilitazione             : Factor w/ 4 levels "A","B","C","D": 4 4 2 4 3 4 3 1 1 3 ...
##  $ age                                  : num  78 75 60 72 49 70 81 60 68 70 ...

Data Analysis

Creiamo alcune variabili categoriche da quelle continue per MRC dyspnea scale e BMI

VDS$mrc_cat <- cut(VDS$mrc_dyspnea_scale,breaks = c(0,1,2,5),right = F,labels = c("0","1",">1"))
VDS$mrc_cat_u <- cut(VDS$mrc_dyspnea_scale_u,breaks = c(0,1,2,5),right = F,labels = c("0","1",">1"))
VDS$bmi_cat <- cut(VDS$bmi,breaks = c(0,18.5,25,30,40),right = F,include.lowest = T,labels = c("UW","NW","OW","Obese"))
VDS$bmi_cat_u <- cut(VDS$bmi_u,breaks = c(0,18.5,25,30,40),right = F,include.lowest = T,labels = c("UW","NW","OW","Obese"))

Descriptive plots

Nel grafico possiamo chiaramente notare una (aspettata) correlazione tra l’età e il risulatato del 6MWT all’ingresso del paziente. Inoltre è chiaro dalla distribuzione dei tipi di riailitazione che il tipo A è effettuato su pazienti con un 6MWT migliore, così via via per i tipi B e C, fino al tipo D eseguito su pazienti con risultati peggiori al 6MWT (e più anziani)

Cosa che viene confermata nel grafici di seguito divisi per Tipologia di Riabilitazione e per classi di MRC Dyspnea Scale all’ingresso

La distribuzione sembra invece omogenea nei confronti del BMI all’ingresso

Non sembrano esserci evidenti associazioni tra il numero di coronarie coinvolte e la tipologia di riabilitazione

g <- ggplot(data = VDS[!is.na(VDS$tipologia_riabilitazione),], aes(x=tipologia_riabilitazione, fill=factor(n_coronarie_critiche)))
g + geom_bar(position=position_dodge()) + scale_fill_brewer(palette = "Set1", name="Nr. Critical Coronaries") + labs(x="Rehabilitation")

Basal Patients Condition

Grafici delle Comorbidità all’ingresso per Tipologia di Riabilitazione:

Grafici delle Terapie all’ingresso per Tipologia di Riabilitazione

Risk Class before and after rehab

Secondary Risk before and after rehab

Barthel Index before and after rehab

FEV before and after rehab

6MWT before and after rehab