library(readxl)
collecte_tb_pharmacie_survey_ <- read_excel("collecte_tb_pharmacie_survey..xlsx")
attach(collecte_tb_pharmacie_survey_)
pharmacie=ifelse(collecte_tb_pharmacie_survey_$Nom_pharmacie=="Point de vente",yes =0,no=1)
pharmacie=factor(pharmacie,levels = c(0,1),labels = c("informelle","formelle"))
date_enquete="Date de l'enquête"

Age=collecte_tb_pharmacie_survey_$Age     

Sexe= collecte_tb_pharmacie_survey_$Sexe          

Residence= collecte_tb_pharmacie_survey_$`Résidence (quartier)`   

toux= collecte_tb_pharmacie_survey_$`Avez-vous toussé au delà de 2 semaines ?`  

fievre=collecte_tb_pharmacie_survey_$`Avez-vous de la fièvre activement ou pendant les deux dernieres semaines?`               

duree_signes= collecte_tb_pharmacie_survey_$`Si oui depuis combiens de temps? (nombre de jours)`                           
cohabite_contact=collecte_tb_pharmacie_survey_$`Avez-vous cohabité avec un tousseur les 6 derniers mois ?`   

temps_contact= collecte_tb_pharmacie_survey_$`Si oui ! pendant combiens de temps? (nombre mois)` 

Amaigrisement= collecte_tb_pharmacie_survey_$`Avez-vous maigri ces derniers temps ?`      

Date_col_crachat= collecte_tb_pharmacie_survey_$`Date de collecte de l'échantillon`                

Type_echantillon= collecte_tb_pharmacie_survey_$`Type d'échantillon` 

Aspect_crachat= collecte_tb_pharmacie_survey_$`Aspect visuel (traces de sang, mucopurulence ou présence de pu)`

Resultat_miscrop= ifelse(collecte_tb_pharmacie_survey_$`Resultats de la microscopie`=="neg",yes = 0,no=1)
Resultat_miscrop=factor(Resultat_miscrop,levels = c(0,1),labels = c("Négatif","Positif"))

Resultat_geneXpert= collecte_tb_pharmacie_survey_$`M. tuberculosis`  

Résistance_rifampicine=collecte_tb_pharmacie_survey_$`Résistance à la rifampicine`    

data_pharmay=data.frame(Age, Sexe , toux, fievre, duree_signes, cohabite_contact, temps_contact, Amaigrisement, Type_echantillon  , Aspect_crachat  , Resultat_miscrop, Resultat_geneXpert , Résistance_rifampicine,pharmacie)
detach(collecte_tb_pharmacie_survey_)

attach(data_pharmay)
library("gtsummary", lib.loc="/Library/Frameworks/R.framework/Versions/4.0/Resources/library")
## Warning: package 'gtsummary' was built under R version 4.0.1

Descrition des patients

data_pharmay%>%
  tbl_summary()%>%
  add_n()%>%
  bold_labels()
Characteristic N N = 10251
Age 1025 30 (21, 47)
Sexe 1025
f 470 (46%)
m 555 (54%)
toux 1025 923 (90%)
fievre 1025 903 (88%)
duree_signes 1025 14 (10, 15)
cohabite_contact 1025 139 (14%)
temps_contact 134 5.0 (3.0, 6.0)
Unknown 891
Amaigrisement 1025 493 (48%)
Type_echantillon 1025
crach 853 (83%)
crach_mil 172 (17%)
Aspect_crachat 1025
Mucopurulent 440 (43%)
Mucus 3 (0.3%)
Mucus+Salivaire 62 (6.0%)
Purulent 5 (0.5%)
Salivaire 512 (50%)
Sanguinolant 3 (0.3%)
Resultat_miscrop 1025
Négatif 890 (87%)
Positif 135 (13%)
Resultat_geneXpert 11
detect 3 (27%)
nondetect 8 (73%)
Unknown 1014
Résistance_rifampicine 6
nondet 5 (83%)
other 1 (17%)
Unknown 1019
pharmacie 1025
informelle 530 (52%)
formelle 495 (48%)

1 Statistics presented: median (IQR); n (%)

Repartition des patients selon les resultats de la microscopie

data_pharmay%>%
  tbl_summary(by="Resultat_miscrop")%>%
  add_p()%>%
  add_overall()%>%
  add_n()%>%
  bold_labels()
Characteristic N Overall, N = 1025 Négatif, N = 8901 Positif, N = 1351 p-value2
Age 1025 30 (21, 47) 31 (21, 48) 28 (21, 38) 0.024
Sexe 1025 0.004
f 470 (46%) 424 (48%) 46 (34%)
m 555 (54%) 466 (52%) 89 (66%)
toux 1025 923 (90%) 790 (89%) 133 (99%) <0.001
fievre 1025 903 (88%) 769 (86%) 134 (99%) <0.001
duree_signes 1025 14 (10, 15) 14 (9, 15) 14 (12, 16) 0.11
cohabite_contact 1025 139 (14%) 108 (12%) 31 (23%) 0.001
temps_contact 134 5.0 (3.0, 6.0) 5.0 (3.5, 6.0) 5.0 (2.5, 6.0) 0.5
Unknown 891 787 104
Amaigrisement 1025 493 (48%) 370 (42%) 123 (91%) <0.001
Type_echantillon 1025 0.024
crach 853 (83%) 731 (82%) 122 (90%)
crach_mil 172 (17%) 159 (18%) 13 (9.6%)
Aspect_crachat 1025 <0.001
Mucopurulent 440 (43%) 350 (39%) 90 (67%)
Mucus 3 (0.3%) 3 (0.3%) 0 (0%)
Mucus+Salivaire 62 (6.0%) 57 (6.4%) 5 (3.7%)
Purulent 5 (0.5%) 4 (0.4%) 1 (0.7%)
Salivaire 512 (50%) 473 (53%) 39 (29%)
Sanguinolant 3 (0.3%) 3 (0.3%) 0 (0%)
Resultat_geneXpert 11 0.2
detect 3 (27%) 1 (12%) 2 (67%)
nondetect 8 (73%) 7 (88%) 1 (33%)
Unknown 1014 882 132
Résistance_rifampicine 6 0.2
nondet 5 (83%) 5 (100%) 0 (0%)
other 1 (17%) 0 (0%) 1 (100%)
Unknown 1019 885 134
pharmacie 1025 0.011
informelle 530 (52%) 446 (50%) 84 (62%)
formelle 495 (48%) 444 (50%) 51 (38%)

1 Statistics presented: median (IQR); n (%)

2 Statistical tests performed: Wilcoxon rank-sum test; chi-square test of independence; Fisher's exact test

Repartition des patients selons les types de pharmacie frequentés

  data_pharmay%>%
    tbl_summary(by = "pharmacie")%>%
    add_p()%>%
    add_overall()%>%
    add_n()%>%
    bold_labels()
Characteristic N Overall, N = 1025 informelle, N = 5301 formelle, N = 4951 p-value2
Age 1025 30 (21, 47) 30 (21, 47) 30 (22, 47) 0.9
Sexe 1025 0.6
f 470 (46%) 238 (45%) 232 (47%)
m 555 (54%) 292 (55%) 263 (53%)
toux 1025 923 (90%) 496 (94%) 427 (86%) <0.001
fievre 1025 903 (88%) 522 (98%) 381 (77%) <0.001
duree_signes 1025 14 (10, 15) 14 (8, 14) 14 (12, 21) <0.001
cohabite_contact 1025 139 (14%) 74 (14%) 65 (13%) 0.8
temps_contact 134 5.0 (3.0, 6.0) 4.0 (3.0, 6.0) 6.0 (3.5, 7.0) 0.019
Unknown 891 459 432
Amaigrisement 1025 493 (48%) 269 (51%) 224 (45%) 0.089
Type_echantillon 1025 <0.001
crach 853 (83%) 497 (94%) 356 (72%)
crach_mil 172 (17%) 33 (6.2%) 139 (28%)
Aspect_crachat 1025 <0.001
Mucopurulent 440 (43%) 255 (48%) 185 (37%)
Mucus 3 (0.3%) 3 (0.6%) 0 (0%)
Mucus+Salivaire 62 (6.0%) 0 (0%) 62 (13%)
Purulent 5 (0.5%) 3 (0.6%) 2 (0.4%)
Salivaire 512 (50%) 267 (50%) 245 (49%)
Sanguinolant 3 (0.3%) 2 (0.4%) 1 (0.2%)
Resultat_miscrop 1025 0.011
Négatif 890 (87%) 446 (84%) 444 (90%)
Positif 135 (13%) 84 (16%) 51 (10%)
Resultat_geneXpert 11 0.5
detect 3 (27%) 0 (0%) 3 (38%)
nondetect 8 (73%) 3 (100%) 5 (62%)
Unknown 1014 527 487
Résistance_rifampicine 6 >0.9
nondet 5 (83%) 0 (NA%) 5 (83%)
other 1 (17%) 0 (NA%) 1 (17%)
Unknown 1019 530 489

1 Statistics presented: median (IQR); n (%)

2 Statistical tests performed: Wilcoxon rank-sum test; chi-square test of independence; Fisher's exact test

d=glm(as.factor(Resultat_miscrop)~Age+Sexe+toux+fievre+duree_signes+cohabite_contact+Amaigrisement+pharmacie ,family=binomial(logit), data=data_pharmay)
t1 <- tbl_regression(d, exponentiate = TRUE)
e=glm(pharmacie~Age+Sexe+toux+fievre+duree_signes+cohabite_contact+Amaigrisement+Resultat_miscrop ,family=binomial(logit), data=data_pharmay)
t2 <- tbl_regression(e, exponentiate = TRUE)
library("survival", lib.loc="/Library/Frameworks/R.framework/Versions/4.0/Resources/library")
library("survminer", lib.loc="/Library/Frameworks/R.framework/Versions/4.0/Resources/library")
## Warning: package 'ggplot2' was built under R version 4.0.1
n=coxph(Surv(duree_signes, as.numeric(Resultat_miscrop)) ~ Age+Sexe+toux+fievre+cohabite_contact+Amaigrisement+pharmacie,data = data_pharmay)%>%
  gtsummary::tbl_regression(exp = TRUE) 

Determinants de la TB chez les patients qui visitent les pharmacies

tbl_merge( tbls = list(t1,t2,n),tab_spanner = c("**Resultat de microscopie**", "**Type de pharmacie**","**Time to test**"))
Characteristic Resultat de microscopie Type de pharmacie Time to test
OR1 95% CI1 p-value OR1 95% CI1 p-value HR1 95% CI1 p-value
Age 0.98 0.97, 0.99 0.006 1.00 0.99, 1.01 0.5 0.99 0.98, 1.00 0.009
Sexe
f
m 1.57 1.04, 2.39 0.033 0.97 0.74, 1.27 0.8 1.35 0.95, 1.94 0.10
toux
no
yes 8.18 2.44, 50.9 0.004 0.85 0.50, 1.45 0.5 5.97 1.46, 24.3 0.013
fievre
no
yes 10.7 2.24, 193 0.021 0.06 0.03, 0.12 <0.001 9.40 1.31, 67.7 0.026
duree_signes 1.00 0.99, 1.02 0.6 1.05 1.04, 1.06 <0.001
cohabite_contact
no
yes 0.96 0.58, 1.54 0.9 1.08 0.71, 1.63 0.7 0.97 0.65, 1.46 0.9
Amaigrisement
no
yes 15.4 8.54, 30.2 <0.001 0.80 0.58, 1.08 0.14 11.7 6.40, 21.6 <0.001
pharmacie
informelle
formelle 0.73 0.47, 1.11 0.14 0.40 0.28, 0.58 <0.001
Resultat_miscrop
Négatif
Positif 0.79 0.52, 1.21 0.3

1 OR = Odds Ratio, CI = Confidence Interval, HR = Hazard Ratio

# Delai de depistage des patients frequantant les pharmacies

ggsurvplot(fit = survfit(Surv(duree_signes, as.numeric(Resultat_miscrop)) ~ 1,data =data_pharmay ), xlab = "Days", ylab = "Overall survival probability",pval = T,risk.table = T,conf.int = T,surv.median.line = "hv")
## Warning in .pvalue(fit, data = data, method = method, pval = pval, pval.coord = pval.coord, : There are no survival curves to be compared. 
##  This is a null model.
## Warning in .add_surv_median(p, fit, type = surv.median.line, fun = fun, : Median
## survival not reached.

# Comparaison des delais de diagnostic des patients entre les patients frequantant les pharmacies formelles et informelles

ggsurvplot(fit = survfit(Surv(duree_signes, as.numeric(Resultat_miscrop)) ~ pharmacie,data =data_pharmay ),  xlab = "Days", ylab = "Overall survival probability",pval = T,risk.table = T,conf.int = T,surv.median.line = "hv")
## Warning in .add_surv_median(p, fit, type = surv.median.line, fun = fun, : Median
## survival not reached.
## Warning: Vectorized input to `element_text()` is not officially supported.
## Results may be unexpected or may change in future versions of ggplot2.