library(readxl)
collecte_tb_covid_survey<- read_excel("~/Dropbox (Compte personnel)/TB_COVID_G_N/collecte_tb_covid_Final_Netoyer.xlsx")
View(collecte_tb_covid_survey)  
## Warning in system2("/usr/bin/otool", c("-L", shQuote(DSO)), stdout = TRUE):
## running command ''/usr/bin/otool' -L '/Library/Frameworks/R.framework/Resources/
## modules/R_de.so'' had status 1
#names(collecte_tb_covid_survey)

#recodage des données

pays=as.factor(collecte_tb_covid_survey$`selectionner un pays` )                                  
testes_covid19=collecte_tb_covid_survey$`Nombre de cas présumés/contact testés pour la Covid-19`
positifs_covid19=collecte_tb_covid_survey$`Nombre de cas positifs à la Covid-19`            
negatifs_covid19=collecte_tb_covid_survey$`Nombre négatifs à la Covid-19`
gueris_covid_19=collecte_tb_covid_survey$`Nombre cas guéris de covid-19`
nomb_test_TB=collecte_tb_covid_survey$`Nombre de patients présumés, positifs ou guérie Covid-19 testé pour la TB`

#creation d'un dataframe

data1=data.frame(pays,testes_covid19,positifs_covid19,negatifs_covid19,gueris_covid_19,nomb_test_TB)

# define function for lower and upper bounds of the mean CI
ll <- function(x) t.test(x)$conf.int[1]
ul <- function(x) t.test(x)$conf.int[2]

#Description des donneées]

library("gtsummary", lib.loc="/Library/Frameworks/R.framework/Versions/4.0/Resources/library")

t1 <-
  data1%>%
  #select(testes_covid19,positifs_covid19,negatifs_covid19,gueris_covid_19,nomb_test_TB)
  tbl_summary(by = pays,statistic = all_continuous() ~ "{sum}")%>%
add_overall()
  
 # modify_header(stat_0 ~ "**Mean (SD)**")
t1
Characteristic Overall, N = 2191 Gui, N = 1591 Nig, N = 601
testes_covid19 2,646 2,520 126
positifs_covid19 153.00 59.00 94.00
Unknown 1 1 0
negatifs_covid19 2,438 2,438 NA
Unknown 60 0 60
gueris_covid_19 175.00 117.00 58.00
nomb_test_TB 846.0 758.0 88.0

1 Statistics presented: sum

#plot t2

t2 <-
  data1%>%
  #select(testes_covid19,positifs_covid19,negatifs_covid19,gueris_covid_19,nomb_test_TB)
  tbl_summary(statistic = all_continuous() ~ "{ll}, {ul}",by = pays)
  #modify_header(stat_0 ~ "**95% CI for Mean**")
t2
Characteristic Gui, N = 1591 Nig, N = 601
testes_covid19 13, 18 2, 3
positifs_covid19 0.21, 0.53 0.96, 2.17
Unknown 1 0
negatifs_covid19 13, 18 NA, NA
Unknown 0 60
gueris_covid_19 0.47, 1.00 0.48, 1.46
nomb_test_TB 4.0, 5.5 1.1, 1.9

1 Statistics presented: ll, ul

tbl_merge(list(t1, t2)) %>%
  #modify_footnote(everything() ~ NA_character_) 
  modify_spanning_header(everything() ~ NA_character_)
Characteristic Overall, N = 2191 Gui, N = 1591 Nig, N = 601 Gui, N = 1592 Nig, N = 602
testes_covid19 2,646 2,520 126 13, 18 2, 3
positifs_covid19 153.00 59.00 94.00 0.21, 0.53 0.96, 2.17
Unknown 1 1 0 1 0
negatifs_covid19 2,438 2,438 NA 13, 18 NA, NA
Unknown 60 0 60 0 60
gueris_covid_19 175.00 117.00 58.00 0.47, 1.00 0.48, 1.46
nomb_test_TB 846.0 758.0 88.0 4.0, 5.5 1.1, 1.9

1 Statistics presented: sum

2 Statistics presented: ll, ul

#Importation de countrepeat
datarepeat <- read_excel("~/Dropbox (Compte personnel)/TB_COVID_G_N/collecte_tb_covid_Final_Netoyer.xlsx", sheet = "patient_repeat")

#names(datarepeat)

t3 <-
  datarepeat%>%
  select(Age,Sexe,Pays,`Antécédent de traitement TB`,`Avez vous tousse au delà de 2 semaines ?`,`Avez-vous de la fièvre activement ?`,`Avez-vous cohabite avec un tousseur ?`,`Avez-vous de la fièvre activement ?`,`Avez-vous perdu du poids ces derniers temps ?`,`Resultats du test Covod-19 (PCR)`,`Quel examen a été realisé pour la recherche de la TB`,`Resultats de la microscopie`,`Résistance à la rifampicine`,`Tuberculose confirmée`)%>%
  tbl_summary(by = Pays,statistic = all_continuous() ~ "{mean} ({sd})") 


t4 <-
  datarepeat%>%
  select(Age,Sexe,Pays,`Antécédent de traitement TB`,`Avez vous tousse au delà de 2 semaines ?`,`Avez-vous de la fièvre activement ?`,`Avez-vous cohabite avec un tousseur ?`,`Avez-vous de la fièvre activement ?`,`Avez-vous perdu du poids ces derniers temps ?`,`Resultats du test Covod-19 (PCR)`,`Quel examen a été realisé pour la recherche de la TB`,`Resultats de la microscopie`,`Résistance à la rifampicine`,`Tuberculose confirmée`)%>%
tbl_summary(statistic = all_continuous() ~ "{ll}, {ul}",by = Pays)%>%
  add_overall()


tbl_merge(list(t3, t4)) %>%
  #modify_footnote(everything() ~ NA_character_) 
  modify_spanning_header(everything() ~ NA_character_)
Characteristic Guinee, N = 7581 Niger, N = 1051 Overall, N = 8632 Guinee, N = 7582 Niger, N = 1052
Age 36 (14) 50 (20) 36, 38 35, 37 46, 54
Sexe
f 314 (41%) 28 (27%) 342 (40%) 314 (41%) 28 (27%)
m 444 (59%) 77 (73%) 521 (60%) 444 (59%) 77 (73%)
Antécédent de traitement TB 38 (5.1%) 2 (1.9%) 40 (4.7%) 38 (5.1%) 2 (1.9%)
Unknown 6 1 7 6 1
Avez vous tousse au delà de 2 semaines ? 369 (49%) 58 (55%) 427 (49%) 369 (49%) 58 (55%)
Avez-vous de la fièvre activement ? 335 (44%) 49 (47%) 384 (45%) 335 (44%) 49 (47%)
Unknown 4 1 5 4 1
Avez-vous cohabite avec un tousseur ? 133 (18%) 7 (6.7%) 140 (16%) 133 (18%) 7 (6.7%)
Unknown 4 1 5 4 1
Avez-vous perdu du poids ces derniers temps ? 211 (28%) 50 (48%) 261 (30%) 211 (28%) 50 (48%)
Unknown 2 1 3 2 1
Resultats du test Covod-19 (PCR)
neg 744 (98%) 57 (54%) 801 (93%) 744 (98%) 57 (54%)
pos 13 (1.7%) 48 (46%) 61 (7.1%) 13 (1.7%) 48 (46%)
Unknown 1 0 1 1 0
Quel examen a été realisé pour la recherche de la TB
GeneXp 32 (4.2%) 29 (28%) 61 (7.1%) 32 (4.2%) 29 (28%)
Mic_Xpert 1 (0.1%) 14 (13%) 15 (1.7%) 1 (0.1%) 14 (13%)
Microscop 722 (95%) 62 (59%) 784 (91%) 722 (95%) 62 (59%)
rad 3 (0.4%) 0 (0%) 3 (0.3%) 3 (0.4%) 0 (0%)
Resultats de la microscopie
neg 726 (97%) 98 (96%) 824 (97%) 726 (97%) 98 (96%)
other 1 (0.1%) 0 (0%) 1 (0.1%) 1 (0.1%) 0 (0%)
plus_plus 4 (0.5%) 3 (2.9%) 7 (0.8%) 4 (0.5%) 3 (2.9%)
rare 3 (0.4%) 1 (1.0%) 4 (0.5%) 3 (0.4%) 1 (1.0%)
une_croix 13 (1.7%) 0 (0%) 13 (1.5%) 13 (1.7%) 0 (0%)
Unknown 11 3 14 11 3
Résistance à la rifampicine
det 1 (7.7%) 0 (0%) 1 (5.9%) 1 (7.7%) 0 (0%)
nondet 12 (92%) 4 (100%) 16 (94%) 12 (92%) 4 (100%)
Unknown 745 101 846 745 101
Tuberculose confirmée
TB_No 723 (95%) 97 (92%) 820 (95%) 723 (95%) 97 (92%)
TB_Yes 35 (4.6%) 8 (7.6%) 43 (5.0%) 35 (4.6%) 8 (7.6%)

1 Statistics presented: Mean (SD); n (%)

2 Statistics presented: ll, ul; n (%)

t5 <-
  datarepeat%>%
  select(Age,Sexe,Pays,`Antécédent de traitement TB`,`Avez vous tousse au delà de 2 semaines ?`,`Avez-vous de la fièvre activement ?`,`Avez-vous cohabite avec un tousseur ?`,`Avez-vous de la fièvre activement ?`,`Avez-vous perdu du poids ces derniers temps ?`,`Resultats du test Covod-19 (PCR)`,`Quel examen a été realisé pour la recherche de la TB`,`Resultats de la microscopie`,`Résistance à la rifampicine`,`Tuberculose confirmée`)%>%
  tbl_summary(by =`Tuberculose confirmée` ,statistic = all_continuous() ~ "{mean} ({sd})") %>%
  add_overall()%>%
  add_p()
## There was an error in 'add_p()' for variable 'Résistance à la rifampicine', p-value omitted:
## Error in stats::fisher.test(data[[variable]], as.factor(data[[by]])): 'x' and 'y' must have at least 2 levels
t5
Characteristic Overall, N = 8631 TB_No, N = 8201 TB_Yes, N = 431 p-value2
Age 37 (16) 37 (16) 38 (17) >0.9
Sexe 0.036
f 342 (40%) 332 (40%) 10 (23%)
m 521 (60%) 488 (60%) 33 (77%)
Pays 0.3
Guinee 758 (88%) 723 (88%) 35 (81%)
Niger 105 (12%) 97 (12%) 8 (19%)
Antécédent de traitement TB 40 (4.7%) 38 (4.7%) 2 (4.9%) >0.9
Unknown 7 5 2
Avez vous tousse au delà de 2 semaines ? 427 (49%) 392 (48%) 35 (81%) <0.001
Avez-vous de la fièvre activement ? 384 (45%) 344 (42%) 40 (93%) <0.001
Unknown 5 5 0
Avez-vous cohabite avec un tousseur ? 140 (16%) 133 (16%) 7 (16%) >0.9
Unknown 5 5 0
Avez-vous perdu du poids ces derniers temps ? 261 (30%) 222 (27%) 39 (91%) <0.001
Unknown 3 3 0
Resultats du test Covod-19 (PCR) 0.2
neg 801 (93%) 763 (93%) 38 (88%)
pos 61 (7.1%) 56 (6.8%) 5 (12%)
Unknown 1 1 0
Quel examen a été realisé pour la recherche de la TB <0.001
GeneXp 61 (7.1%) 46 (5.6%) 15 (35%)
Mic_Xpert 15 (1.7%) 13 (1.6%) 2 (4.7%)
Microscop 784 (91%) 759 (93%) 25 (58%)
rad 3 (0.3%) 2 (0.2%) 1 (2.3%)
Resultats de la microscopie <0.001
neg 824 (97%) 819 (100%) 5 (17%)
other 1 (0.1%) 0 (0%) 1 (3.4%)
plus_plus 7 (0.8%) 1 (0.1%) 6 (21%)
rare 4 (0.5%) 0 (0%) 4 (14%)
une_croix 13 (1.5%) 0 (0%) 13 (45%)
Unknown 14 0 14
Résistance à la rifampicine
det 1 (5.9%) 0 (NA%) 1 (5.9%)
nondet 16 (94%) 0 (NA%) 16 (94%)
Unknown 846 820 26

1 Statistics presented: Mean (SD); n (%)

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