install.packages(“tidyverse”) install.packages(“dplyr”) install.packages(“gtsummary”) install.packages(“readxl”) install.packages(“car”) install.packages(“broom.helpers”) install.packages(“ResourceSelection”) install.packages(“ggstats”) install.packages(“plotROC”) install.packages(“caret”) install.packages(“rms”) install.packages(“pROC”) install.packages(“boot”) install.packages(“ggalluvial”) install.packages(“knitr”) install.packages(“rlang”)
library(tidyverse) library(dplyr) library(gtsummary) library(readxl) library(broom.helpers) library(car) library(ResourceSelection) library(ggstats) library(plotROC) library(caret) library(rms) library(pROC) library(boot) library(ggalluvial) library(knitr) library(rlang)
database <- read_excel(“L:/Travaux de fond/Stats/GVH posaconazole/Recueil de données/database.xlsx”)
View(database)
distribution_age <- ggplot(database, aes(x = Age)) + geom_histogram(aes(y = after_stat(density)), color = “#000000”, fill = “#0099F8”) + geom_density(color = “#000000”, fill = “#F85700”, alpha = 0.6)+ theme_classic()+ labs( title = “Histogram of age distribution”, subtitle = “N total = 24”, x = “Age (years)”, y = “Density (%)” ) distribution_age
shapiro.test_age <- shapiro.test(database$Age) shapiro.test_age
distribution_albumine_avant <- ggplot(database, aes(x =
Albuminémie avant GVH)) + geom_histogram(aes(y =
after_stat(density)), color = “#000000”, fill = “#0099F8”) +
geom_density(color = “#000000”, fill = “#F85700”, alpha = 0.6)+
theme_classic()+ labs( title = “Histogram of albuminemia before
distribution”, subtitle = “N total = 24”, x = “Albuminémie avant GVH”, y
= “Density (%)” ) distribution_albumine_avant
shapiro.test_albumine_avant <-
shapiro.test(database$Albuminémie avant GVH)
shapiro.test_albumine_avant
distribution_albumine_après <- ggplot(database, aes(x =
Albuminémie après GVH)) + geom_histogram(aes(y =
after_stat(density)), color = “#000000”, fill = “#0099F8”) +
geom_density(color = “#000000”, fill = “#F85700”, alpha = 0.6)+
theme_classic()+ labs( title = “Histogram of albuminemia after
distribution”, subtitle = “N total = 24”, x = “Albuminémie après GVH”, y
= “Density (%)” ) distribution_albumine_après
shapiro.test_albumine_après <-
shapiro.test(database$Albuminémie après GVH)
shapiro.test_albumine_après
database <- database %>% mutate( Sexe = case_when( Sexe == “m” ~ “Masculin”, Sexe == “f” ~ “Féminin” ), Sexe = factor(Sexe, levels = c(“Féminin”, “Masculin”)) )
database <- database %>% mutate(
Origine cellules sources =
factor(Origine cellules sources) )
database <- database %>% mutate( Conditionnement = factor(Conditionnement) )
database <- database %>% mutate( Localisation GVH
= factor( Localisation GVH, levels = c(0, 1, 2), labels =
c(“Localisation basse”, “Localisation haute”, “Localisation haute et
basse”) ))
database <- database %>% mutate(Grade GVH =
case_when( Grade GVH %in% c(1, 2) ~ “Grade I-II”,
Grade GVH %in% c(3, 4) ~ “Grade III-IV”, TRUE ~
NA_character_ ), Grade GVH = factor(Grade GVH,
levels = c(“Grade I-II”, “Grade III-IV”)) )
table_1 <- database %>% tbl_summary( include = c(Sexe, Age,
Localisation GVH, Origine cellules sources,
Conditionnement, Albuminémie avant GVH,
Albuminémie après GVH,
Différentiel albuminémie avant/après GVH,
Résiduel posaconazole avant GVH,
Résiduel posaconazole après GVH,
Différentiel résiduel posaconazole avant/après GVH),
statistic = list( Age ~ “{median} [{p25} - {p75}]”,
Albuminémie avant GVH ~ “{mean} ± {sd}”,
Albuminémie après GVH ~ “{mean} ± {sd}”,
Différentiel albuminémie avant/après GVH ~ “{mean} ± {sd}”,
Résiduel posaconazole avant GVH ~ “{mean} ± {sd}”,
Résiduel posaconazole après GVH ~ “{mean} ± {sd}”,
Différentiel résiduel posaconazole avant/après GVH ~
“{mean} ± {sd}”, all_categorical() ~ “{n} ({p}%)” ), label = list( Sexe
~ “Sexe”, Age ~ “Age (années), médiane [intervalle
IQ]”, Localisation GVH ~ “Localisation
GVH”, Origine cellules sources ~ “Origine
cellules sources”, Conditionnement ~
“Conditionnement”, Albuminémie avant GVH ~
“Albuminémie avant GVH (g/L), moyenne ± ET”,
Albuminémie après GVH ~ “Albuminémie après GVH
(g/L), moyenne
± ET”, Différentiel albuminémie avant/après GVH ~
“Différentiel albuminémie, moyenne ± ET”,
Résiduel posaconazole avant GVH ~ “Résiduel
posaconazole avant GVH, moyenne ± ET”,
Résiduel posaconazole après GVH ~ “Résiduel
posaconazole après GVH, moyenne ± ET”,
Différentiel résiduel posaconazole avant/après GVH ~
“Différentiel résiduel posaconazole, moyenne ± ET” ),
missing = “no” ) %>% as_gt() %>% gt::fmt_markdown(columns = label)
%>% gt::tab_header( title = gt::html(“Tableau 1 :
Caractéristiques de la population étudiée traitée par posaconazole”)
)
table_1
t.test_posaco <- t.test(database\(`Résiduel posaconazole avant GVH`,
database\)Résiduel posaconazole après GVH,
paired = TRUE) t.test_posaco
wilcox.test_albumine <- wilcox.test(database\(`Albuminémie avant GVH`,
database\)Albuminémie après GVH,
paired = TRUE) wilcox.test_albumine
shapiro.test_diffposo_grade12 <- shapiro.test( database\(`Différentiel résiduel posaconazole avant/après
GVH`[database\)Grade GVH == “Grade I-II”])
shapiro.test_diffposo_grade12
shapiro.test_diffposo_grade34 <- shapiro.test( database\(`Différentiel résiduel posaconazole avant/après
GVH`[database\)Grade GVH == “Grade III-IV”])
shapiro.test_diffposo_grade34
sd_grade12 <- sd(database\(`Différentiel
résiduel posaconazole avant/après
GVH`[database\)Grade GVH == “Grade I-II”])
sd_grade34 <- sd(database\(`Différentiel
résiduel posaconazole avant/après
GVH`[database\)Grade GVH == “Grade III-IV”])
sd_grade12 / sd_grade34 # ratio = 1.19, homoscedasticite -> Student
classique (sans correction de Welch)
t.test_diffposo_grade <- t.test( database\(`Différentiel résiduel posaconazole avant/après
GVH` ~ database\)Grade GVH, var.equal = TRUE)
t.test_diffposo_grade
shapiro.test_diffposo_basse <- shapiro.test( database\(`Différentiel résiduel posaconazole avant/après
GVH`[database\)Localisation GVH == “Localisation
basse”]) shapiro.test_diffposo_haute <- shapiro.test( database\(`Différentiel résiduel posaconazole avant/après
GVH`[database\)Localisation GVH == “Localisation
haute”]) shapiro.test_diffposo_bassehaute <- shapiro.test(
database\(`Différentiel résiduel posaconazole
avant/après GVH`[database\)Localisation GVH ==
“Localisation haute et basse”]) shapiro.test_diffposo_basse
shapiro.test_diffposo_haute shapiro.test_diffposo_bassehaute # p>0.05
dans les 3 sous-groupes -> distributions normales # (NB :
sous-groupes tres petits, n=5 et n=6 -> puissance faible pour
detecter un ecart)
sds_loc <- tapply(database\(`Différentiel résiduel posaconazole avant/après
GVH`,
database\)Localisation GVH, sd)
max(sds_loc) / min(sds_loc) # ratio = 2.33, hors de l’intervalle 0.7-1.4
-> heteroscedasticite -> ANOVA avec correction de Welch
anova.test_diffposo_localisation <- oneway.test( database\(`Différentiel résiduel posaconazole avant/après
GVH` ~ database\)Localisation GVH, var.equal =
FALSE) anova.test_diffposo_localisation
kruskal.test_diffposo_localisation <- kruskal.test( database\(`Différentiel résiduel posaconazole avant/après
GVH` ~ database\)Localisation GVH)
kruskal.test_diffposo_localisation
t.test_posthoc_basse_haute <- t.test( database\(`Différentiel résiduel posaconazole avant/après
GVH`[database\)Localisation GVH == “Localisation
basse”], database\(`Différentiel résiduel
posaconazole avant/après
GVH`[database\)Localisation GVH == “Localisation
haute”])
t.test_posthoc_basse_bassehaute <- t.test( database\(`Différentiel résiduel posaconazole avant/après
GVH`[database\)Localisation GVH == “Localisation
basse”], database\(`Différentiel résiduel
posaconazole avant/après
GVH`[database\)Localisation GVH == “Localisation
haute et basse”])
t.test_posthoc_haute_bassehaute <- t.test( database\(`Différentiel résiduel posaconazole avant/après
GVH`[database\)Localisation GVH == “Localisation
haute”], database\(`Différentiel résiduel
posaconazole avant/après
GVH`[database\)Localisation GVH == “Localisation
haute et basse”])
t.test_posthoc_basse_haute # p = 0.075 -> non significatif apres Bonferroni t.test_posthoc_basse_bassehaute # p = 0.087 -> non significatif apres Bonferroni t.test_posthoc_haute_bassehaute # p = 0.0058 -> SIGNIFICATIF apres Bonferroni
#localisation haute” vs “localisation haute et basse” -> la localisation haute et basse combinée #est associée à une diminution plus marquée du résiduel posaconazole après GVH, comparativement #à la localisation haute isolée qui tend au contraire vers une augmentation (rappel: différentiel = (avant - après/avant))
tbl_bivar_grade <- database %>% tbl_summary( by =
Grade GVH, include =
Différentiel résiduel posaconazole avant/après GVH,
statistic = all_continuous() ~ “{mean} ± {sd}”, label =
Différentiel résiduel posaconazole avant/après GVH ~
“Différentiel résiduel posaconazole” ) %>% add_p(test = everything()
~ “t.test”) %>% bold_labels() %>% modify_caption(“Tableau
2a. Différentiel résiduel posaconazole selon le Grade GVH (test
de Student)”)
tbl_bivar_grade
tbl_bivar_localisation <- database %>% tbl_summary( by =
Localisation GVH, include =
Différentiel résiduel posaconazole avant/après GVH,
statistic = all_continuous() ~ “{mean} ± {sd}”, label =
Différentiel résiduel posaconazole avant/après GVH ~
“Différentiel résiduel posaconazole” ) %>% add_p(test = everything()
~ “kruskal.test”) %>% bold_labels() %>%
modify_caption(“Tableau 2b. Différentiel résiduel
posaconazole selon la Localisation GVH (test de Kruskal-Wallis)”) %>%
modify_source_note( “Résultat concordant avec l’ANOVA de Welch (p =
0,0078). Test post-hoc (Student, correction de Bonferroni, seuil =
0,05/3) : différence significative uniquement entre Localisation haute
et Localisation haute+basse (p = 0,0058) ; les autres comparaisons
deux-à-deux ne sont pas significatives.” )
tbl_bivar_localisation
database <- database %>%
mutate(Evolution résiduel posaconazole = case_when(
Différentiel résiduel posaconazole avant/après GVH > 0 ~
“Diminution après GVH”,
Différentiel résiduel posaconazole avant/après GVH < 0 ~
“Augmentation après GVH” ), Evolution résiduel posaconazole
= factor(Evolution résiduel posaconazole, levels =
c(“Diminution après GVH”, “Augmentation après GVH”)))
data_alluvial <- database %>% count(Grade GVH,
Localisation GVH,
Evolution résiduel posaconazole, name = “Effectif”)
sankey_grade_localisation_sens <- ggplot(data_alluvial, aes(axis1
= Grade GVH, axis2 = Localisation GVH, axis3 =
Evolution résiduel posaconazole, y = Effectif)) +
geom_alluvium(aes(fill = Grade GVH), width = 1/4, alpha =
0.8, color = “grey30”, linewidth = 0.25) + geom_stratum(width = 1/4,
fill = “grey90”, color = “black”) + geom_text(stat = “stratum”,
aes(label = paste0(after_stat(stratum), “=”, after_stat(count), ” (“,
round(100 * after_stat(count) / 24),”%)“)), size = 2.6) +
scale_x_discrete(limits = c(”Grade GVH”, “Localisation GVH”, “Evolution
résiduel posaconazole”), expand = c(0.12, 0.12)) + theme_classic() +
theme(legend.position = “none”) + labs( title = “Diagramme de Sankey
explorant la relation: grade de la GVH, localisation de la GVH et
évolution de résiduelle de posaconazole”, subtitle = “N total = 24”, x =
““, y =”Effectif” )
sankey_grade_localisation_sens
lm_sexe <-
lm(Différentiel résiduel posaconazole avant/après GVH ~
Sexe, data = database)
lm_age <-
lm(Différentiel résiduel posaconazole avant/après GVH ~
Age, data = database)
lm_grade <-
lm(Différentiel résiduel posaconazole avant/après GVH ~
Grade GVH, data = database)
lm_localisation <-
lm(Différentiel résiduel posaconazole avant/après GVH ~
Localisation GVH, data = database)
lm_origine <-
lm(Différentiel résiduel posaconazole avant/après GVH ~
Origine cellules sources, data = database)
lm_conditionnement <-
lm(Différentiel résiduel posaconazole avant/après GVH ~
Conditionnement, data = database)
lm_albumine_avant <-
lm(Différentiel résiduel posaconazole avant/après GVH ~
Albuminémie avant GVH, data = database)
tbl_uni_diffposo <- database %>% tbl_uvregression( method = lm,
y = Différentiel résiduel posaconazole avant/après GVH,
include = c(Sexe, Age, Grade GVH,
Localisation GVH, Origine cellules sources,
Conditionnement, Albuminémie avant GVH)) %>%
add_global_p()
tbl_uni_diffposo
lm_model_diffposo <- lm(
Différentiel résiduel posaconazole avant/après GVH ~
Localisation GVH + Grade GVH, data =
database)
vif(lm_model_diffposo) # VIF ~ 1 pour les deux -> pas de colinearite
tbl_regression(lm_model_diffposo) %>% add_global_p()
AIC(lm_localisation, lm_model_diffposo)
tbl_desc_diffposo <- database %>% tbl_summary( include =
c(Localisation GVH, Grade GVH), statistic =
list(all_categorical() ~ “{n} ({p}%)”) )
tbl_uni_gvh <- database %>% tbl_uvregression( y =
Différentiel résiduel posaconazole avant/après GVH, include
= c(Localisation GVH, Grade GVH), method = lm)
%>% add_global_p() %>% modify_column_hide(“stat_n”)
tbl_multi_gvh <- lm_model_diffposo %>% tbl_regression() %>% add_global_p()
table2_diffposo <- list(tbl_desc_diffposo, tbl_uni_gvh, tbl_multi_gvh) %>% tbl_merge( tab_spanner = c( NA, “Crude model”, “Adjusted model”)) %>% bold_labels()
table2_diffposo
plot_lm_diffposo <- lm_model_diffposo %>% ggstats::ggcoef_table()
plot_lm_diffposo