##chargement des packages----
library(questionr)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tableone)
library(labelled)
library(gtsummary)
library(GGally)
library(readxl)
library(effects)
## Le chargement a nécessité le package : carData
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
library(survival)
library(survminer)
## Le chargement a nécessité le package : ggpubr
## Registered S3 method overwritten by 'car':
##   method           from
##   na.action.merMod lme4
## 
## Attachement du package : 'survminer'
## 
## L'objet suivant est masqué depuis 'package:survival':
## 
##     myeloma
library(ggplot2)
library(dplyr)
library(knitr)
library(cowplot)
## 
## Attachement du package : 'cowplot'
## 
## L'objet suivant est masqué depuis 'package:ggpubr':
## 
##     get_legend
## 
## L'objet suivant est masqué depuis 'package:lubridate':
## 
##     stamp
##chargement des données 

data_caro <- read_excel("U:/Internes/INTERNES MAI 2026 - NOV 2026/Caroline/Projet de fond/ivosidenib/data_caro.xlsx")
##creation de nouvelles variables
data_caro$periode <-ifelse(data_caro$time_vs_ivo<0, 0, 1)
data_ivo<-filter(data_caro, c(eligible=="oui"))
data_ciclo<-filter(data_ivo, c(DCI=="Ciclosporine"))
###graphiques evolution des concentrations globales de ciclo


ggplot(data_ciclo) +
  aes(x = time_vs_ivo, y = res_dose_jour, colour = antifongique) +
  geom_point() +
  xlab("Time vs ivosidenib") +
  ylab("concentrations/dail dose of cyclo")

##tableau descriptif toutes conc de ciclo selon periode selon critère de catégorie ----
tbl_summary(
  data_ciclo, include = c("res_dose_jour"),
  by="periode", 
  digits=all_categorical()~ c(0,1)
)%>%
  add_p()
Characteristic 0
N = 33
1
1
N = 29
1
p-value2
res_dose_jour 1.00 (0.91, 1.16) 0.53 (0.42, 0.72) <0.001
1 Median (Q1, Q3)
2 Wilcoxon rank sum exact test
##analyse des valeurs mmoyennes par patient

data_ciclo <- data_ciclo %>%
  group_by(Patient, periode) %>%
  mutate(moy_res_dose = mean(res_dose_jour, na.rm = TRUE)) %>%
  ungroup()

moy_par_patient_cat <- data_ciclo %>%
  group_by(Patient, periode) %>%
  summarise(moy_res_dose = mean(res_dose_jour, na.rm = TRUE),
            n_mesures = n(),
            .groups = "drop")

moy_par_patient_cat
## # A tibble: 8 × 4
##   Patient periode moy_res_dose n_mesures
##     <dbl>   <dbl>        <dbl>     <int>
## 1       1       0        1.08          9
## 2       1       1        0.556         4
## 3       2       0        1.71         12
## 4       2       1        0.748         6
## 5       8       0        0.669         3
## 6       8       1        0.393        11
## 7       9       0        1.29          9
## 8       9       1        0.751         8
## représenation graphique 

ggplot(moy_par_patient_cat) +
  aes(x = periode, y = moy_res_dose, group = Patient) +
  geom_line(alpha = 0.4) +
  geom_point(aes(colour = periode)) +
  labs(x = "periode", y = "Moyenne concentration / dose journalière")