#Clear environment

rm(list = ls())

#Load libraries

library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(kableExtra)
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
library(stringr)
library(tibble)
library(reshape2)
library(ggpubr)
library(rstatix)
## 
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
## 
##     filter
library(RVAideMemoire)
## *** Package RVAideMemoire v 0.9-83-11 ***
library(tidyr)
## 
## Attaching package: 'tidyr'
## The following object is masked from 'package:reshape2':
## 
##     smiths
library(purrr)
library(sandwich)
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(tidyr)
library(gt)
library(gtsummary)
library(forcats)
library(purrr)
library(flextable)
## 
## Attaching package: 'flextable'
## The following object is masked from 'package:gtsummary':
## 
##     continuous_summary
## The following object is masked from 'package:purrr':
## 
##     compose
## The following objects are masked from 'package:ggpubr':
## 
##     border, font, rotate
## The following objects are masked from 'package:kableExtra':
## 
##     as_image, footnote
library(geepack)

#Import and reformat data

#metadata
HH<-read.csv("AnExII_ODKdata_qPCRMST_KJ.csv")%>%
  select(c(9, 82, 85, 105:106, 126, 128, 180, 184, 186, 207, 209:210, 212, 232, 234, 238, 255:260, 293:295, 297, 315:318))%>%
  mutate(Household=factor(Household))

#abundance data
data<-read.csv("Updated_AnExII.csv")%>%
  dplyr::mutate_at(vars(6:11), as.numeric)%>%
  dplyr::mutate(GenBac_log=log10(GenBac))%>%
  dplyr::mutate(GenBac_log=str_replace(GenBac_log, "BDL", "1250"))%>%
  dplyr::mutate(GenBac_log=str_replace(GenBac_log, "DNQ", "2500"))%>%
  dplyr::mutate(across(starts_with("GenBac"), as.numeric))%>%
  dplyr::mutate(Household=factor(Household))%>%
  dplyr::mutate(Site=factor(Site))%>%
  dplyr::mutate(Sample_Type=factor(Sample_Type))%>%
  dplyr::mutate(Sample_Type = if_else(Sample_Type == "Mom's hands", "Adult hands", Sample_Type))%>%
  dplyr::mutate(Sample_Type = if_else(Sample_Type == "Child's hands", "Child hands", Sample_Type))%>%
  left_join(HH, by = "Household")

#marker presence absence
prev<-read.csv("Updated_AnExII GenBac raw.csv")%>%
  dplyr::mutate(across(6:11, ~str_replace(., "BDL", "0")))%>%
  dplyr::mutate(across(6:11, ~str_replace(., "DNQ", "1")))%>%
  mutate_at(vars(6:11), as.numeric)%>%
  mutate(Site=as.factor(Site))%>%
  mutate(Sample_Type=as.factor(Sample_Type))%>%
  mutate(Household=as.factor(Household))%>%
  rowwise()%>%
  dplyr::mutate(Any_animal_marker=sum(dplyr::c_across(8:11)))%>%
  dplyr::mutate(Any_host_marker=sum(dplyr::c_across(7:11)))%>%
  dplyr::mutate(Any_marker=sum(dplyr::c_across(6:11)))%>%
  dplyr::mutate(across(6:14, ~if_else(. >0, 1, .)))%>%
  mutate(Sample_Type = if_else(Sample_Type == "Mom's hands", "Adult hands", Sample_Type))%>%
  mutate(Sample_Type = if_else(Sample_Type == "Child's hands", "Child hands", Sample_Type))%>%
  left_join(HH, by = "Household")

samples<-table(data$Sample_Type)%>%
  as.data.frame()%>%
  dplyr::rename(Sample_Type=Var1)

#MST marker prevalence in any sample

prev <- prev %>%
  mutate(any_host = as.integer(HF183 == 1 | Rum2Bac == 1 | Pig2Bac == 1 | DG37 == 1 | GFD == 1),
         any_animal = as.integer(Rum2Bac == 1 | Pig2Bac == 1 | DG37 == 1 | GFD == 1))

perc_all <- data.frame(
  GenBac = sum(prev$GenBac) / 586 * 100,
  HF183 = sum(prev$HF183) / 586 * 100,
  DG37 = sum(prev$DG37) / 586 * 100,
  GFD = sum(prev$GFD) / 586 * 100,
  Pig2Bac = sum(prev$Pig2Bac) / 586 * 100,
  Rum2Bac = sum(prev$Rum2Bac) / 586 * 100,
  Any_Host = sum(prev$any_host) / 586 * 100,
  Any_Animal = sum(prev$any_animal) / 586 * 100
) %>%
  mutate(across(where(is.numeric), round, 2))

kbl(perc_all) %>%
  kable_styling(latex_options = "scale_down", font_size = 14) %>%
  kable_styling(bootstrap_options = "hover", full_width = FALSE) %>%
  add_header_above(c("MST marker % prevalence in any sample" = 8))
MST marker % prevalence in any sample
GenBac HF183 DG37 GFD Pig2Bac Rum2Bac Any_Host Any_Animal
77.82 15.36 3.58 4.1 2.05 0.51 19.97 8.36
total_pos <- data.frame(
  GenBac = sum(prev$GenBac),
  HF183 = sum(prev$HF183),
  DG37 = sum(prev$DG37),
  GFD = sum(prev$GFD),
  Pig2Bac = sum(prev$Pig2Bac),
  Rum2Bac = sum(prev$Rum2Bac),
  Any_Host = sum(prev$any_host),
  Any_Animal = sum(prev$any_animal)
)

kbl(total_pos) %>%
  kable_styling(latex_options = "scale_down", font_size = 14) %>%
  kable_styling(bootstrap_options = "hover", full_width = FALSE) %>%
  add_header_above(c("MST marker detections in any sample" = 8))
MST marker detections in any sample
GenBac HF183 DG37 GFD Pig2Bac Rum2Bac Any_Host Any_Animal
456 90 21 24 12 3 117 49

#MST marker prevalence by sample type

prev_melt<-prev %>%
  melt(id.vars=c("Code", "Sample_Type", "Site", "Household"), variable.name=("measurement"), value.name="value")
  
detections<-prev%>%
  select(c(3, 6:14))%>%
  melt(id.vars=c("Sample_Type"), variable.name=("MST marker"), value.name="value")%>%
  group_by(Sample_Type, `MST marker`)%>%
  dplyr::summarize(`Positive sample n`=sum(value), `Total sample n`=n(), Percent= (sum(value)/n()*100))%>%
  mutate(across(where(is.numeric), ~ round(., 2)))

kbl(detections)%>%
  kable_styling(latex_options="scale_down", font_size=14)%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  add_header_above(c("MST marker prevalence by sample type"=5))
MST marker prevalence by sample type
Sample_Type MST marker Positive sample n Total sample n Percent
Adult hands GenBac 59 59 100.00
Adult hands HF183 31 59 52.54
Adult hands Rum2Bac 1 59 1.69
Adult hands Pig2Bac 4 59 6.78
Adult hands DG37 4 59 6.78
Adult hands GFD 3 59 5.08
Adult hands Any_animal_marker 10 59 16.95
Adult hands Any_host_marker 35 59 59.32
Adult hands Any_marker 59 59 100.00
Cellphone GenBac 29 30 96.67
Cellphone HF183 1 30 3.33
Cellphone Rum2Bac 0 30 0.00
Cellphone Pig2Bac 0 30 0.00
Cellphone DG37 1 30 3.33
Cellphone GFD 0 30 0.00
Cellphone Any_animal_marker 1 30 3.33
Cellphone Any_host_marker 2 30 6.67
Cellphone Any_marker 29 30 96.67
Child hands GenBac 31 31 100.00
Child hands HF183 15 31 48.39
Child hands Rum2Bac 0 31 0.00
Child hands Pig2Bac 0 31 0.00
Child hands DG37 5 31 16.13
Child hands GFD 2 31 6.45
Child hands Any_animal_marker 7 31 22.58
Child hands Any_host_marker 17 31 54.84
Child hands Any_marker 31 31 100.00
Dish drying surface GenBac 9 10 90.00
Dish drying surface HF183 0 10 0.00
Dish drying surface Rum2Bac 0 10 0.00
Dish drying surface Pig2Bac 0 10 0.00
Dish drying surface DG37 0 10 0.00
Dish drying surface GFD 0 10 0.00
Dish drying surface Any_animal_marker 0 10 0.00
Dish drying surface Any_host_marker 0 10 0.00
Dish drying surface Any_marker 9 10 90.00
Domestic water GenBac 40 48 83.33
Domestic water HF183 5 48 10.42
Domestic water Rum2Bac 0 48 0.00
Domestic water Pig2Bac 0 48 0.00
Domestic water DG37 0 48 0.00
Domestic water GFD 0 48 0.00
Domestic water Any_animal_marker 0 48 0.00
Domestic water Any_host_marker 5 48 10.42
Domestic water Any_marker 40 48 83.33
Doorknob GenBac 58 59 98.31
Doorknob HF183 6 59 10.17
Doorknob Rum2Bac 0 59 0.00
Doorknob Pig2Bac 2 59 3.39
Doorknob DG37 1 59 1.69
Doorknob GFD 2 59 3.39
Doorknob Any_animal_marker 5 59 8.47
Doorknob Any_host_marker 11 59 18.64
Doorknob Any_marker 58 59 98.31
Drinking water GenBac 39 55 70.91
Drinking water HF183 0 55 0.00
Drinking water Rum2Bac 0 55 0.00
Drinking water Pig2Bac 0 55 0.00
Drinking water DG37 0 55 0.00
Drinking water GFD 1 55 1.82
Drinking water Any_animal_marker 1 55 1.82
Drinking water Any_host_marker 1 55 1.82
Drinking water Any_marker 39 55 70.91
Floor GenBac 53 59 89.83
Floor HF183 17 59 28.81
Floor Rum2Bac 1 59 1.69
Floor Pig2Bac 3 59 5.08
Floor DG37 9 59 15.25
Floor GFD 15 59 25.42
Floor Any_animal_marker 20 59 33.90
Floor Any_host_marker 27 59 45.76
Floor Any_marker 53 59 89.83
Food GenBac 12 57 21.05
Food HF183 0 57 0.00
Food Rum2Bac 0 57 0.00
Food Pig2Bac 0 57 0.00
Food DG37 0 57 0.00
Food GFD 0 57 0.00
Food Any_animal_marker 0 57 0.00
Food Any_host_marker 0 57 0.00
Food Any_marker 12 57 21.05
Food- prep surface GenBac 55 57 96.49
Food- prep surface HF183 6 57 10.53
Food- prep surface Rum2Bac 0 57 0.00
Food- prep surface Pig2Bac 2 57 3.51
Food- prep surface DG37 0 57 0.00
Food- prep surface GFD 1 57 1.75
Food- prep surface Any_animal_marker 2 57 3.51
Food- prep surface Any_host_marker 8 57 14.04
Food- prep surface Any_marker 55 57 96.49
House keys GenBac 12 19 63.16
House keys HF183 0 19 0.00
House keys Rum2Bac 0 19 0.00
House keys Pig2Bac 1 19 5.26
House keys DG37 0 19 0.00
House keys GFD 0 19 0.00
House keys Any_animal_marker 1 19 5.26
House keys Any_host_marker 1 19 5.26
House keys Any_marker 12 19 63.16
Soil GenBac 14 54 25.93
Soil HF183 0 54 0.00
Soil Rum2Bac 0 54 0.00
Soil Pig2Bac 0 54 0.00
Soil DG37 1 54 1.85
Soil GFD 0 54 0.00
Soil Any_animal_marker 1 54 1.85
Soil Any_host_marker 1 54 1.85
Soil Any_marker 14 54 25.93
TV remote control GenBac 16 16 100.00
TV remote control HF183 2 16 12.50
TV remote control Rum2Bac 0 16 0.00
TV remote control Pig2Bac 0 16 0.00
TV remote control DG37 0 16 0.00
TV remote control GFD 0 16 0.00
TV remote control Any_animal_marker 0 16 0.00
TV remote control Any_host_marker 2 16 12.50
TV remote control Any_marker 16 16 100.00
Toy GenBac 29 31 93.55
Toy HF183 7 31 22.58
Toy Rum2Bac 1 31 3.23
Toy Pig2Bac 0 31 0.00
Toy DG37 0 31 0.00
Toy GFD 0 31 0.00
Toy Any_animal_marker 1 31 3.23
Toy Any_host_marker 7 31 22.58
Toy Any_marker 29 31 93.55

#Prevalence plot

#format data
counts<-prev %>%
  select(-matches("Number"))%>%
  select(c(3, 6:11))%>% #can update this line to include additional data (ex: any host, any animal marker)
  melt(id.vars= c("Sample_Type"))%>%
  group_by(Sample_Type, variable)%>%
  dplyr::summarize(cnt=n())
## `summarise()` has grouped output by 'Sample_Type'. You can override using the
## `.groups` argument.
sums<- prev %>%
  select(-matches("Number"))%>%
  select(c(3, 6:11))%>% #can update this line to include additional data (ex: any host, any animal marker)
  melt(id.vars= c("Sample_Type"))%>%
  group_by(Sample_Type, variable)%>%
  dplyr::summarise(across(value, sum))
## `summarise()` has grouped output by 'Sample_Type'. You can override using the
## `.groups` argument.
prev_sampletype<-data.frame(Sample_Type=counts$Sample_Type, 
                            Assay=counts$variable, 
                            Total_Samples=counts$cnt, 
                            Total_Pos=sums$value, 
                            Percent_Pos=sums$value/counts$cnt*100)

prev_sampletype_balloon<-prev_sampletype %>%
  subset(Assay != "Human_positive" & Assay != "Any_positive" & Assay != "Any_animal_pos" & Assay != "Any_source_spec_pos")

#plot
prev_sampletype_balloon$Assay <- factor(prev_sampletype_balloon$Assay, levels = c("Rum2Bac", "Pig2Bac", "GFD", "DG37", "HF183", "GenBac"))

labels<-c("Rum2Bac (ruminant)", "Pig2Bac (pig)", "GFD (bird)", "DG37 (dog)", "HF183 (human)", "GenBac3 (general)")


cols <- c("GenBac"="#FF9DA7", "HF183"="#59A14F", "DG37"="#76B7B4", "GFD"="#E15759", "Pig2Bac"="#F28E2B", "Rum2Bac"="#4E79A7")

prevalence_plot<-ggballoonplot(prev_sampletype_balloon, 
             x="Sample_Type",
             y="Assay",
             fill="Assay", 
             size="Percent_Pos",
             ggtheme=theme_minimal())+
  scale_fill_manual(values=cols, labels=scales::percent)+
  scale_y_discrete(labels=labels)+
  #scale_x_discrete(labels=labels2)+
  ggtitle("Prevalence of MST markers")+
  guides(fill = "none",
         size=guide_legend(title="Positive\nsamples (%)"))+
  theme(axis.text.y=element_text(size=14),
        axis.text.x=element_text(size=14), 
        legend.background=element_rect(color=NA),
        legend.text=element_text(size=12),
        legend.title=element_text(size=13),
        panel.border=element_rect(color="black", fill=NA))
  
prevalence_plot

#Sample type and MST marker detection

markers<-c("GenBac", "HF183", "DG37", "Pig2Bac", "Pig2Bac", "Rum2Bac")

#GenBac
GenBac_counts<-prev%>%
  group_by(Sample_Type)%>%
  dplyr::summarize(detected=sum(GenBac))%>%
  left_join(samples, by= "Sample_Type")%>%
  mutate(not_detected=Freq-detected)%>%
  select(-c(Freq))

GenBac_mosaic<-GenBac_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()
mosaicplot(GenBac_mosaic, color=TRUE, las=3)

fisher_GenBac<-GenBac_counts%>%
  column_to_rownames("Sample_Type")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_GenBac #p<0.0001, run pairwise posthoc tests
## # A tibble: 1 × 3
##       n      p p.signif
## * <dbl>  <dbl> <chr>   
## 1   585 0.0001 ****
fisher_GenBac_multi_corrected<-GenBac_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()%>%
  fisher.multcomp(p.method = "BH")
fisher_GenBac_multi_corrected$p.value%>%
  as.data.frame()%>%
  mutate(across(where(is.numeric), ~ round(., 3)))%>%
  kbl()%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  add_header_above(c("GenBac pairwise Fisher's test adj p-values"=14))
GenBac pairwise Fisher’s test adj p-values
Adult hands Cellphone Child hands Dish drying surface Domestic water Doorknob Drinking water Floor Food Food- prep surface House keys Soil TV remote control
Cellphone 0.487 NA NA NA NA NA NA NA NA NA NA NA NA
Child hands 1.000 0.639 NA NA NA NA NA NA NA NA NA NA NA
Dish drying surface 0.259 0.592 0.396 NA NA NA NA NA NA NA NA NA NA
Domestic water 0.003 0.258 0.041 1.000 NA NA NA NA NA NA NA NA NA
Doorknob 1.000 1.000 1.000 0.413 0.025 NA NA NA NA NA NA NA NA
Drinking water 0.000 0.011 0.001 0.413 0.289 0.000 NA NA NA NA NA NA NA
Floor 0.057 0.565 0.177 1.000 0.542 0.216 0.036 NA NA NA NA NA NA
Food 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 NA NA NA NA NA
Food- prep surface 0.396 1.000 0.684 0.542 0.083 0.746 0.001 0.413 0.000 NA NA NA NA
House keys 0.000 0.010 0.002 0.338 0.202 0.000 0.714 0.029 0.004 0.002 NA NA NA
Soil 0.000 0.000 0.000 0.001 0.000 0.000 0.000 0.000 0.784 0.000 0.014 NA NA
TV remote control 1.000 1.000 1.000 0.542 0.317 1.000 0.034 0.486 0.000 1.000 0.023 0 NA
Toy 0.216 1.000 0.639 1.000 0.448 0.413 0.032 0.839 0.000 0.746 0.040 0 0.684
#write.csv(fisher_GenBac_multi_corrected$p.value, file="GenBac_fisher_pvalues.csv")

fisher_GenBac3_posthoc <- fisher_GenBac_multi_corrected$p.value %>%
  as.data.frame() %>%
  mutate(across(where(is.numeric), ~ case_when(
    is.na(.)    ~ "",
    . < 0.001   ~ "<0.001",
    TRUE        ~ formatC(., format = "f", digits = 3)
  )))
#write.csv(fisher_GenBac3_posthoc, file = "fisher_GenBac3_posthoc.csv")

#HF183
HF183_counts<-prev%>%
  dplyr::group_by(Sample_Type)%>%
  dplyr::summarize(detected=sum(HF183))%>%
  dplyr::left_join(samples, by= "Sample_Type")%>%
  mutate(not_detected=Freq-detected)%>%
  select(-c(Freq))

HF183_mosaic<-HF183_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()
mosaicplot(HF183_mosaic, color=TRUE, las=3)

fisher_HF183<-HF183_counts%>%
  column_to_rownames("Sample_Type")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_HF183 #p<0.0001, run pairwise posthoc tests
## # A tibble: 1 × 3
##       n      p p.signif
## * <dbl>  <dbl> <chr>   
## 1   585 0.0001 ****
fisher_HF183_multi_corrected<-HF183_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()%>%
  fisher.multcomp(p.method = "BH")
fisher_HF183_multi_corrected$p.value%>%
  as.data.frame()%>%
  mutate(across(where(is.numeric), ~ round(., 3)))%>%
  kbl()%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  add_header_above(c("HF183 pairwise Fisher's test adj p-values"=14))
HF183 pairwise Fisher’s test adj p-values
Adult hands Cellphone Child hands Dish drying surface Domestic water Doorknob Drinking water Floor Food Food- prep surface House keys Soil TV remote control
Cellphone 0.000 NA NA NA NA NA NA NA NA NA NA NA NA
Child hands 1.000 0.000 NA NA NA NA NA NA NA NA NA NA NA
Dish drying surface 0.006 1.000 0.024 NA NA NA NA NA NA NA NA NA NA
Domestic water 0.000 0.565 0.002 0.757 NA NA NA NA NA NA NA NA NA
Doorknob 0.000 0.573 0.001 0.757 1.000 NA NA NA NA NA NA NA NA
Drinking water 0.000 0.516 0.000 1.000 0.054 0.062 NA NA NA NA NA NA NA
Floor 0.045 0.016 0.189 0.109 0.063 0.054 0.000 NA NA NA NA NA NA
Food 0.000 0.514 0.000 1.000 0.054 0.062 1.000 0.000 NA NA NA NA NA
Food- prep surface 0.000 0.573 0.001 0.757 1.000 1.000 0.062 0.054 0.062 NA NA NA NA
House keys 0.000 1.000 0.001 1.000 0.496 0.501 1.000 0.027 1.000 0.501 NA NA NA
Soil 0.000 0.516 0.000 1.000 0.055 0.062 1.000 0.000 1.000 0.062 1.000 NA NA
TV remote control 0.016 0.445 0.062 0.690 1.000 0.855 0.098 0.501 0.094 1.000 0.340 0.098 NA
Toy 0.025 0.102 0.115 0.288 0.340 0.225 0.002 0.795 0.002 0.342 0.075 0.002 0.869
#write.csv(fisher_HF183_multi_corrected$p.value, file="HF183_fisher_pvalues.csv")

fisher_HF183_posthoc <- fisher_HF183_multi_corrected$p.value %>%
  as.data.frame() %>%
  mutate(across(where(is.numeric), ~ case_when(
    is.na(.)    ~ "",
    . < 0.001   ~ "<0.001",
    TRUE        ~ formatC(., format = "f", digits = 3)
  )))
write.csv(fisher_HF183_posthoc, file = "fisher_HF183_posthoc.csv")

#DG37
DG37_counts<-prev%>%
  dplyr::group_by(Sample_Type)%>%
  dplyr::summarize(detected=sum(DG37))%>%
  dplyr::left_join(samples, by= "Sample_Type")%>%
  mutate(not_detected=Freq-detected)%>%
  select(-c(Freq))

DG37_mosaic<-DG37_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()
mosaicplot(DG37_mosaic, color=TRUE, las=3)

fisher_DG37<-DG37_counts%>%
  column_to_rownames("Sample_Type")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_DG37 #p<0.0001, run pairwise posthoc tests
## # A tibble: 1 × 3
##       n      p p.signif
## * <dbl>  <dbl> <chr>   
## 1   585 0.0001 ****
fisher_DG37_multi_corrected<-DG37_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()%>%
  fisher.multcomp(p.method = "BH")
fisher_DG37_multi_corrected$p.value%>%
  as.data.frame()%>%
  mutate(across(where(is.numeric), ~ round(., 3)))%>%
  kbl()%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  add_header_above(c("DG37 pairwise Fisher's test adj p-values"=14))
DG37 pairwise Fisher’s test adj p-values
Adult hands Cellphone Child hands Dish drying surface Domestic water Doorknob Drinking water Floor Food Food- prep surface House keys Soil TV remote control
Cellphone 1.000 NA NA NA NA NA NA NA NA NA NA NA NA
Child hands 0.929 0.741 NA NA NA NA NA NA NA NA NA NA NA
Dish drying surface 1.000 1.000 0.980 NA NA NA NA NA NA NA NA NA NA
Domestic water 0.603 1.000 0.086 1.00 NA NA NA NA NA NA NA NA NA
Doorknob 0.980 1.000 0.144 1.00 1.000 NA NA NA NA NA NA NA NA
Drinking water 0.603 0.980 0.063 1.00 1.000 1.000 NA NA NA NA NA NA NA
Floor 0.870 0.640 1.000 0.98 0.063 0.144 0.063 NA NA NA NA NA NA
Food 0.603 0.980 0.063 1.00 1.000 1.000 1.000 0.063 NA NA NA NA NA
Food- prep surface 0.603 0.980 0.063 1.00 1.000 1.000 1.000 0.063 1 NA NA NA NA
House keys 1.000 1.000 0.640 1.00 1.000 1.000 1.000 0.603 1 1 NA NA NA
Soil 0.980 1.000 0.172 1.00 1.000 1.000 1.000 0.144 1 1 1 NA NA
TV remote control 1.000 1.000 0.640 1.00 1.000 1.000 1.000 0.741 1 1 1 1 NA
Toy 0.980 1.000 0.341 1.00 1.000 1.000 1.000 0.174 1 1 1 1 1
#write.csv(fisher_HF183_multi_corrected$p.value, file="DG37_fisher_pvalues.csv")

fisher_DG37_posthoc <- fisher_DG37_multi_corrected$p.value %>%
  as.data.frame() %>%
  mutate(across(where(is.numeric), ~ case_when(
    is.na(.)    ~ "",
    . < 0.001   ~ "<0.001",
    TRUE        ~ formatC(., format = "f", digits = 3)
  )))
#write.csv(fisher_DG37_posthoc, file = "fisher_DG367_posthoc.csv")

#GFD
GFD_counts<-prev%>%
  dplyr::group_by(Sample_Type)%>%
  dplyr::summarize(detected=sum(GFD))%>%
  dplyr::left_join(samples, by= "Sample_Type")%>%
  mutate(not_detected=Freq-detected)%>%
  select(-c(Freq))

GFD_mosaic<-GFD_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()
mosaicplot(GFD_mosaic, color=TRUE, las=3)

fisher_GFD<-GFD_counts%>%
  column_to_rownames("Sample_Type")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_GFD #p<0.0001, run pairwise posthoc tests
## # A tibble: 1 × 3
##       n      p p.signif
## * <dbl>  <dbl> <chr>   
## 1   585 0.0001 ****
fisher_GFD_multi_corrected<-GFD_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()%>%
  fisher.multcomp(p.method = "BH")
fisher_GFD_multi_corrected$p.value%>%
  as.data.frame()%>%
  mutate(across(where(is.numeric), ~ round(., 3)))%>%
  kbl()%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  add_header_above(c("GFD pairwise Fisher's test adj p-values"=14))
GFD pairwise Fisher’s test adj p-values
Adult hands Cellphone Child hands Dish drying surface Domestic water Doorknob Drinking water Floor Food Food- prep surface House keys Soil TV remote control
Cellphone 1.000 NA NA NA NA NA NA NA NA NA NA NA NA
Child hands 1.000 1.000 NA NA NA NA NA NA NA NA NA NA NA
Dish drying surface 1.000 1.000 1.000 NA NA NA NA NA NA NA NA NA NA
Domestic water 1.000 1.000 0.858 1.000 NA NA NA NA NA NA NA NA NA
Doorknob 1.000 1.000 1.000 1.000 1.000 NA NA NA NA NA NA NA NA
Drinking water 1.000 1.000 1.000 1.000 1.000 1.000 NA NA NA NA NA NA NA
Floor 0.039 0.021 0.341 0.724 0.003 0.016 0.004 NA NA NA NA NA NA
Food 1.000 1.000 0.790 1.000 1.000 1.000 1.000 0.001 NA NA NA NA NA
Food- prep surface 1.000 1.000 1.000 1.000 1.000 1.000 1.000 0.004 1 NA NA NA NA
House keys 1.000 1.000 1.000 1.000 1.000 1.000 1.000 0.147 1 1 NA NA NA
Soil 1.000 1.000 0.790 1.000 1.000 1.000 1.000 0.001 1 1 1 NA NA
TV remote control 1.000 1.000 1.000 1.000 1.000 1.000 1.000 0.255 1 1 1 1 NA
Toy 1.000 1.000 1.000 1.000 1.000 1.000 1.000 0.021 1 1 1 1 1
#write.csv(fisher_HF183_multi_corrected$p.value, file="GFD_fisher_pvalues.csv")

fisher_GFD_posthoc <- fisher_GFD_multi_corrected$p.value %>%
  as.data.frame() %>%
  mutate(across(where(is.numeric), ~ case_when(
    is.na(.)    ~ "",
    . < 0.001   ~ "<0.001",
    TRUE        ~ formatC(., format = "f", digits = 3)
  )))
write.csv(fisher_GFD_posthoc, file = "fisher_GFD_posthoc.csv")


#Rum2Bac
Rum2Bac_counts<-prev%>%
  dplyr::group_by(Sample_Type)%>%
  dplyr::summarize(detected=sum(Rum2Bac))%>%
  dplyr::left_join(samples, by= "Sample_Type")%>%
  mutate(not_detected=Freq-detected)%>%
  select(-c(Freq))

Rum2Bac_mosaic<-Rum2Bac_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()
mosaicplot(Rum2Bac_mosaic, color=TRUE, las=3)

fisher_Rum2Bac<-Rum2Bac_counts%>%
  column_to_rownames("Sample_Type")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Rum2Bac #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1   585 0.706 ns
#Pig2Bac
Pig2Bac_counts<-prev%>%
  dplyr::group_by(Sample_Type)%>%
  dplyr::summarize(detected=sum(Pig2Bac))%>%
  dplyr::left_join(samples, by= "Sample_Type")%>%
  mutate(not_detected=Freq-detected)%>%
  select(-c(Freq))

Pig2Bac_mosaic<-Pig2Bac_counts%>%
  column_to_rownames("Sample_Type")%>%
  as.matrix()
mosaicplot(Pig2Bac_mosaic, color=TRUE, las=3)

fisher_Pig2Bac<-Pig2Bac_counts%>%
  column_to_rownames("Sample_Type")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4) #ns; p>0.05

#summarize p-values
prev_fisher<-list(GenBac=fisher_GenBac, HF183=fisher_HF183, DG37=fisher_DG37, GFD=fisher_GFD, Rum2Bac=fisher_Rum2Bac, Pig2Bac=fisher_Pig2Bac)
combined_prev_fisher<-map_df(prev_fisher, bind_rows, .id="source")
combined_prev_fisher
## # A tibble: 6 × 4
##   source      n      p p.signif
##   <chr>   <dbl>  <dbl> <chr>   
## 1 GenBac    585 0.0001 ****    
## 2 HF183     585 0.0001 ****    
## 3 DG37      585 0.0001 ****    
## 4 GFD       585 0.0001 ****    
## 5 Rum2Bac   585 0.706  ns      
## 6 Pig2Bac   585 0.173  ns

#Abundance plot

data_melt<-read.csv("Updated_AnExII GenBac raw.csv")%>%
  mutate_at(vars(6:11), as.numeric)%>%
  mutate(GenBac_log=log10(GenBac))%>%
  mutate(HF183_log=log10(HF183))%>%
  mutate(DG37_log=log10(DG37))%>%
  mutate(GFD_log=log10(GFD))%>%
  mutate(Rum2Bac_log=log10(Rum2Bac))%>%
  mutate(Pig2Bac_log=log10(Pig2Bac))%>%
  mutate(Sample_Type = if_else(Sample_Type == "Mom's hands", "Adult hands", Sample_Type))%>%
  mutate(Sample_Type = if_else(Sample_Type == "Child's hands", "Child hands", Sample_Type))%>%
  select(c(Sample_Type, Code, Site, Household, GenBac_log, HF183_log, DG37_log, GFD_log, Rum2Bac_log, Pig2Bac_log))%>%
  melt(id.vars=c("Code", "Sample_Type", "Site", "Household"), variable.name=("measurement"), value.name="value")
data_melt$value<-as.numeric(data_melt$value)

data_melt$measurement <- factor(data_melt$measurement, levels = c("GenBac_log", "HF183_log", "DG37_log", "GFD_log", "Pig2Bac_log", "Rum2Bac_log"))

labels<-c("GenBac3 (general)", "HF183 (human)", "DG37 (dog)", "GFD (bird)", "Pig2Bac (pig)", "Rum2Bac (ruminant)")

cols <- c("GenBac_log"="#FF9DA7", "HF183_log"="#59A14F", "DG37_log"="#76B7B4", "GFD_log"="#E15759", "Pig2Bac_log"="#F28E2B", "Rum2Bac_log"="#4E79A7")

abundance_boxplot <- ggplot(data = data_melt, 
                            aes(x = measurement, y = value, fill = measurement)) +
  geom_boxplot(outlier.shape = NA) +
  theme_minimal() +
  scale_fill_manual(values = cols, labels = labels) +
  scale_x_discrete(labels = labels) +
  guides(fill = guide_legend(title = "Marker")) +
  facet_wrap(~Sample_Type, nrow = 3) +
  labs(y = expression(Log[10]*" gene copies per sample")) +
  theme(
    axis.line = element_line(),
    axis.text.y = element_text(size = 10),
    axis.title.y = element_text(size = 14),
    legend.background = element_rect(color = NA),
    legend.text = element_text(size = 11),
    legend.title = element_text(size = 13),
    axis.text.x = element_blank(),
    axis.ticks.x = element_blank(),
    axis.title.x = element_blank(),
    strip.text.x = element_text(size = 13), 
    panel.spacing.x = unit(0, "line"),
    panel.spacing.y = unit(0, "line"), 
    panel.border = element_rect(color = "black", fill = NA)
  )

abundance_boxplot

#GenBac concentration testing

#Plot abundances
GenBac_plot<-data%>%
  subset(!(Sample_Type %in% c("Food", "Soil"))) %>%
  ggplot(aes(x=reorder(Sample_Type, GenBac_log, na.rm=TRUE), GenBac_log, fill="#FF9DA7"))+
  geom_boxplot()+
  theme_minimal()+
  labs(y = expression(Log[10]*" gene copies per sample")) +
  ggtitle("GenBac3 abundance by sample type")+
  theme(axis.line=element_line(),
        axis.text.y=element_text(size=10),
        axis.title.y=element_text(size=12),
        legend.position="none",
        axis.ticks.x=element_blank(),
        axis.title.x=element_blank(),
        strip.text.x=element_text(size=13), 
        panel.spacing.x=unit(0, "line"),
        panel.spacing.y=unit(0, "line"), 
        panel.border=element_rect(color="black", fill=NA), 
        axis.text.x = element_text(angle = 45, hjust=1, size=12))


GenBac_plot

#normality
shapiro.test(data$GenBac_log) #data is non-normal
## 
##  Shapiro-Wilk normality test
## 
## data:  data$GenBac_log
## W = 0.98557, p-value = 1.564e-05
#Kruskal Wallis testing by sample type
kruskal.test(data$GenBac_log ~ data$Sample_Type) #p<2.2e-16; run pairwise posthoc Dunn's tests
## 
##  Kruskal-Wallis rank sum test
## 
## data:  data$GenBac_log by data$Sample_Type
## Kruskal-Wallis chi-squared = 344.32, df = 13, p-value < 2.2e-16
dunn_GenBac<-dunn_test(data=data, GenBac_log ~ Sample_Type, p.adjust.method="BH")
dunn_GenBac%>%
  select(-c(".y."))%>%
  mutate(across(where(is.numeric), ~ round(., 3)))%>%
  kbl()
group1 group2 n1 n2 statistic p p.adj p.adj.signif
Adult hands Cellphone 59 30 -5.422 0.000 0.000 ****
Adult hands Child hands 59 31 0.708 0.479 0.507 ns
Adult hands Dish drying surface 59 10 -5.825 0.000 0.000 ****
Adult hands Domestic water 59 47 -7.045 0.000 0.000 ****
Adult hands Doorknob 59 59 -4.930 0.000 0.000 ****
Adult hands Drinking water 59 55 -12.054 0.000 0.000 ****
Adult hands Floor 59 59 -7.713 0.000 0.000 ****
Adult hands Food 59 57 -8.973 0.000 0.000 ****
Adult hands Food- prep surface 59 57 -8.747 0.000 0.000 ****
Adult hands House keys 59 19 -7.276 0.000 0.000 ****
Adult hands Soil 59 54 -13.128 0.000 0.000 ****
Adult hands Toy 59 31 -2.671 0.008 0.013
Adult hands TV remote control 59 16 -3.232 0.001 0.002 **
Cellphone Child hands 30 31 5.360 0.000 0.000 ****
Cellphone Dish drying surface 30 10 -2.126 0.033 0.052 ns
Cellphone Domestic water 30 47 -0.692 0.489 0.512 ns
Cellphone Doorknob 30 59 1.374 0.170 0.214 ns
Cellphone Drinking water 30 55 -4.598 0.000 0.000 ****
Cellphone Floor 30 59 -0.912 0.362 0.392 ns
Cellphone Food 30 57 -1.999 0.046 0.068 ns
Cellphone Food- prep surface 30 57 -1.813 0.070 0.099 ns
Cellphone House keys 30 19 -2.399 0.016 0.026
Cellphone Soil 30 54 -5.519 0.000 0.000 ****
Cellphone Toy 30 31 2.434 0.015 0.024
Cellphone TV remote control 30 16 0.984 0.325 0.365 ns
Child hands Dish drying surface 31 10 -5.910 0.000 0.000 ****
Child hands Domestic water 31 47 -6.632 0.000 0.000 ****
Child hands Doorknob 31 59 -4.800 0.000 0.000 ****
Child hands Drinking water 31 55 -10.759 0.000 0.000 ****
Child hands Floor 31 59 -7.110 0.000 0.000 ****
Child hands Food 31 57 -8.172 0.000 0.000 ****
Child hands Food- prep surface 31 57 -7.983 0.000 0.000 ****
Child hands House keys 31 19 -7.126 0.000 0.000 ****
Child hands Soil 31 54 -11.669 0.000 0.000 ****
Child hands Toy 31 31 -2.951 0.003 0.006 **
Child hands TV remote control 31 16 -3.470 0.001 0.001 **
Dish drying surface Domestic water 10 47 1.765 0.077 0.107 ns
Dish drying surface Doorknob 10 59 3.171 0.002 0.003 **
Dish drying surface Drinking water 10 55 -0.777 0.437 0.468 ns
Dish drying surface Floor 10 59 1.673 0.094 0.128 ns
Dish drying surface Food 10 57 0.950 0.342 0.375 ns
Dish drying surface Food- prep surface 10 57 1.072 0.284 0.327 ns
Dish drying surface House keys 10 19 0.187 0.852 0.861 ns
Dish drying surface Soil 10 54 -1.395 0.163 0.209 ns
Dish drying surface Toy 10 31 3.849 0.000 0.000 ***
Dish drying surface TV remote control 10 16 2.682 0.007 0.013
Domestic water Doorknob 47 59 2.402 0.016 0.026
Domestic water Drinking water 47 55 -4.440 0.000 0.000 ****
Domestic water Floor 47 59 -0.219 0.827 0.845 ns
Domestic water Food 47 57 -1.468 0.142 0.187 ns
Domestic water Food- prep surface 47 57 -1.255 0.210 0.254 ns
Domestic water House keys 47 19 -1.993 0.046 0.068 ns
Domestic water Soil 47 54 -5.489 0.000 0.000 ****
Domestic water Toy 47 31 3.392 0.001 0.001 **
Domestic water TV remote control 47 16 1.611 0.107 0.144 ns
Doorknob Drinking water 59 55 -7.211 0.000 0.000 ****
Doorknob Floor 59 59 -2.783 0.005 0.010 **
Doorknob Food 59 57 -4.086 0.000 0.000 ***
Doorknob Food- prep surface 59 57 -3.860 0.000 0.000 ***
Doorknob House keys 59 19 -3.834 0.000 0.000 ***
Doorknob Soil 59 54 -8.308 0.000 0.000 ****
Doorknob Toy 59 31 1.421 0.155 0.202 ns
Doorknob TV remote control 59 16 -0.012 0.990 0.990 ns
Drinking water Floor 55 59 4.477 0.000 0.000 ****
Drinking water Food 55 57 3.136 0.002 0.003 **
Drinking water Food- prep surface 55 57 3.358 0.001 0.002 **
Drinking water House keys 55 19 1.278 0.201 0.247 ns
Drinking water Soil 55 54 -1.112 0.266 0.314 ns
Drinking water Toy 55 31 7.422 0.000 0.000 ****
Drinking water TV remote control 55 16 4.746 0.000 0.000 ****
Floor Food 59 57 -1.327 0.185 0.230 ns
Floor Food- prep surface 59 57 -1.101 0.271 0.316 ns
Floor House keys 59 19 -1.892 0.059 0.085 ns
Floor Soil 59 54 -5.587 0.000 0.000 ****
Floor Toy 59 31 3.731 0.000 0.000 ***
Floor TV remote control 59 16 1.806 0.071 0.099 ns
Food Food- prep surface 57 57 0.224 0.823 0.845 ns
Food House keys 57 19 -0.953 0.340 0.375 ns
Food Soil 57 54 -4.243 0.000 0.000 ****
Food Toy 57 31 4.813 0.000 0.000 ****
Food TV remote control 57 16 2.670 0.008 0.013
Food- prep surface House keys 57 19 -1.112 0.266 0.314 ns
Food- prep surface Soil 57 54 -4.465 0.000 0.000 ****
Food- prep surface Toy 57 31 4.625 0.000 0.000 ****
Food- prep surface TV remote control 57 16 2.522 0.012 0.019
House keys Soil 19 54 -2.074 0.038 0.058 ns
House keys Toy 19 31 4.553 0.000 0.000 ****
House keys TV remote control 19 16 2.971 0.003 0.006 **
Soil Toy 54 31 8.343 0.000 0.000 ****
Soil TV remote control 54 16 5.485 0.000 0.000 ****
Toy TV remote control 31 16 -1.035 0.301 0.342 ns
write.csv(dunn_GenBac, file="Dunn_posthoc_GenBac.csv")

#Floor sample metadata

prev_floor<-prev%>%
   subset(Sample_Type=="Floor")

Floor_types<-prev_floor %>%
  dplyr::group_by(Floor.type)%>%
  dplyr::rename(Floor=Floor.type)%>%
  dplyr::summarize(Count=n())

Floors_cleaned<-prev_floor %>%
  dplyr::group_by(floor.floor_cleaning)%>%
  dplyr::rename(Floor = floor.floor_cleaning)%>%
  dplyr::summarize(Count=n())

Floors<-Floor_types%>%
  rbind(Floors_cleaned)%>%
  kbl(col.names=NULL)%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  pack_rows("Floor Type", 1, 6)%>%
  pack_rows("Floors cleaned in past 24h", 7,8)%>%
  add_header_above(c("Floor sample metadata(n=59)"=2))
Floors
Floor sample metadata(n=59)
Floor Type
Carpet 1
Cement 22
Ceramic tiles 16
Other 1
Vinyl/asphalt 4
Wooden boards 15
Floors cleaned in past 24h
No 50
Yes 9

#Floor type and MST marker detection in floor samples

#GenBac
Floor_type_GenBac_counts<-prev%>%
  dplyr::rename("Floor"="Floor.type")%>%
  subset(Sample_Type=="Floor")%>%
  dplyr::group_by(Floor)%>%
  dplyr::summarize(detected=sum(GenBac))%>%
  dplyr::left_join(Floor_types, by= "Floor")%>%
  dplyr::mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_type_GenBac_mosaic<-Floor_type_GenBac_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_type_GenBac_mosaic, color=TRUE, las=3)

fisher_floor_type_GenBac<-Floor_type_GenBac_counts%>%
  column_to_rownames("Floor")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_type_GenBac #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59  0.34 ns
#HF183
Floor_type_HF183_counts<-prev%>%
  dplyr::rename("Floor"="Floor.type")%>%
  subset(Sample_Type=="Floor")%>%
  dplyr::group_by(Floor)%>%
  dplyr::summarize(detected=sum(HF183))%>%
  left_join(Floor_types, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_type_HF183_mosaic<-Floor_type_HF183_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_type_HF183_mosaic, color=TRUE, las=3)

fisher_floor_type_HF183<-Floor_type_HF183_counts%>%
  column_to_rownames("Floor")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_type_HF183 #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59 0.693 ns
#DG37
Floor_type_DG37_counts<-prev%>%
  dplyr::rename("Floor"="Floor.type")%>%
  subset(Sample_Type=="Floor")%>%
  dplyr::group_by(Floor)%>%
  dplyr::summarize(detected=sum(DG37))%>%
  left_join(Floor_types, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_type_DG37_mosaic<-Floor_type_DG37_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_type_DG37_mosaic, color=TRUE, las=3)

fisher_floor_type_DG37<-Floor_type_DG37_counts%>%
  column_to_rownames("Floor")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_type_DG37 #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59  0.14 ns
#GFD
Floor_type_GFD_counts<-prev%>%
  dplyr::rename("Floor"="Floor.type")%>%
  subset(Sample_Type=="Floor")%>%
  dplyr::group_by(Floor)%>%
  dplyr::summarize(detected=sum(GFD))%>%
  left_join(Floor_types, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_type_GFD_mosaic<-Floor_type_GFD_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_type_GFD_mosaic, color=TRUE, las=3)

fisher_floor_type_GFD<-Floor_type_GFD_counts%>%
  column_to_rownames("Floor")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_type_GFD #ns; p>0.0
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59 0.743 ns
#Rum2Bac
Floor_type_Rum2Bac_counts<-prev%>%
  dplyr::rename("Floor"="Floor.type")%>%
  subset(Sample_Type=="Floor")%>%
  dplyr::group_by(Floor)%>%
  dplyr::summarize(detected=sum(Rum2Bac))%>%
  left_join(Floor_types, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_type_Rum2Bac_mosaic<-Floor_type_Rum2Bac_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_type_Rum2Bac_mosaic, color=TRUE, las=3)

fisher_floor_type_Rum2Bac<-Floor_type_Rum2Bac_counts%>%
  column_to_rownames("Floor")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_type_Rum2Bac #ns; p>0.0
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59 0.633 ns
#Pig2Bac
Floor_type_Pig2Bac_counts<-prev%>%
  dplyr::rename("Floor"="Floor.type")%>%
  subset(Sample_Type=="Floor")%>%
  group_by(Floor)%>%
  dplyr::summarize(detected=sum(Pig2Bac))%>%
  left_join(Floor_types, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_type_Pig2Bac_mosaic<-Floor_type_Pig2Bac_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_type_Pig2Bac_mosaic, color=TRUE, las=3)

fisher_floor_type_Pig2Bac<-Floor_type_Pig2Bac_counts%>%
  column_to_rownames("Floor")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_type_Pig2Bac%>%
  kbl()%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  add_header_above(c("Pig2Bac floor type pairwise Fisher's test p-value"=3)) #ns; p>0.0
Pig2Bac floor type pairwise Fisher’s test p-value
n p p.signif
59 0.466 ns

#Floor cleaning and MST marker detection in floor samples

#GenBac
Floor_clean_GenBac_counts<-prev%>%
  dplyr::rename("Floor"="floor.floor_cleaning")%>%
  subset(Sample_Type=="Floor")%>%
  group_by(Floor)%>%
  dplyr::summarize(detected=sum(GenBac))%>%
  left_join(Floors_cleaned, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_clean_GenBac_mosaic<-Floor_clean_GenBac_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_clean_GenBac_mosaic, color=TRUE, las=3)

fisher_floor_clean_GenBac<-Floor_clean_GenBac_counts%>%
  column_to_rownames("Floor")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_clean_GenBac #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.02117174 12.22868590
## sample estimates:
## odds ratio 
##    1.12271
#HF183
Floor_clean_HF183_counts<-prev%>%
  dplyr::rename("Floor"="floor.floor_cleaning")%>%
  subset(Sample_Type=="Floor")%>%
  group_by(Floor)%>%
  dplyr::summarize(detected=sum(HF183))%>%
  left_join(Floors_cleaned, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_clean_HF183_mosaic<-Floor_clean_HF183_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_clean_HF183_mosaic, color=TRUE, las=3)

fisher_floor_clean_HF183<-Floor_clean_HF183_counts%>%
  column_to_rownames("Floor")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_clean_HF183 #ns; p<0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.263
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##    0.4308151 177.1758865
## sample estimates:
## odds ratio 
##   3.698822
#DG37
Floor_clean_DG37_counts<-prev%>%
  dplyr::rename("Floor"="floor.floor_cleaning")%>%
  subset(Sample_Type=="Floor")%>%
  group_by(Floor)%>%
  dplyr::summarize(detected=sum(DG37))%>%
  left_join(Floors_cleaned, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_clean_DG37_mosaic<-Floor_clean_DG37_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_clean_DG37_mosaic, color=TRUE, las=3)

fisher_floor_clean_DG37<-Floor_clean_DG37_counts%>%
  column_to_rownames("Floor")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_clean_DG37#ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.3293
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3511247       Inf
## sample estimates:
## odds ratio 
##        Inf
#GFD
Floor_clean_GFD_counts<-prev%>%
  dplyr::rename("Floor"="floor.floor_cleaning")%>%
  subset(Sample_Type=="Floor")%>%
  group_by(Floor)%>%
  dplyr::summarize(detected=sum(GFD))%>%
  left_join(Floors_cleaned, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_clean_GFD_mosaic<-Floor_clean_GFD_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_clean_GFD_mosaic, color=TRUE, las=3)

fisher_floor_clean_GFD<-Floor_clean_GFD_counts%>%
  column_to_rownames("Floor")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_clean_GFD #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.19674 13.56727
## sample estimates:
## odds ratio 
##   1.225553
#Rum2Bac
Floor_clean_Rum2Bac_counts<-prev%>%
  dplyr::rename("Floor"="floor.floor_cleaning")%>%
  subset(Sample_Type=="Floor")%>%
  group_by(Floor)%>%
  dplyr::summarize(detected=sum(Rum2Bac))%>%
  left_join(Floors_cleaned, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_clean_Rum2Bac_mosaic<-Floor_clean_Rum2Bac_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_clean_Rum2Bac_mosaic, color=TRUE, las=3)

fisher_floor_clean_Rum2Bac<-Floor_clean_Rum2Bac_counts%>%
  column_to_rownames("Floor")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_clean_Rum2Bac #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.004630938         Inf
## sample estimates:
## odds ratio 
##        Inf
#Pig2Bac
Floor_clean_Pig2Bac_counts<-prev%>%
  dplyr::rename("Floor"="floor.floor_cleaning")%>%
  subset(Sample_Type=="Floor")%>%
  group_by(Floor)%>%
  dplyr::summarize(detected=sum(Pig2Bac))%>%
  left_join(Floors_cleaned, by= "Floor")%>%
  mutate(not_detected=Count-detected)%>%
  select(-c(Count))

Floor_clean_Pig2Bac_mosaic<-Floor_clean_Pig2Bac_counts%>%
  column_to_rownames("Floor")%>%
  as.matrix()
mosaicplot(Floor_clean_Pig2Bac_mosaic, color=TRUE, las=3)

fisher_floor_clean_Pig2Bac<-Floor_clean_Pig2Bac_counts%>%
  column_to_rownames("Floor")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_floor_clean_Pig2Bac #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.3971
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.01595398 22.09992924
## sample estimates:
## odds ratio 
##  0.3419146

#Hand rinse metadata

prev_adult_hands<-prev %>%
  subset(Sample_Type=="Adult hands")

prev_child_hands<-prev %>%
  subset(Sample_Type=="Child hands")

Adult_hands_nails<-prev_adult_hands%>%
  mutate(handrinse.nails_madre=str_replace(handrinse.nails_madre, "yes", "Dirty nails"))%>%
  mutate(handrinse.nails_madre=str_replace(handrinse.nails_madre, "no", "Clean nails"))%>%
  group_by(handrinse.nails_madre)%>%
  dplyr::summarize(Count=n())%>%
  dplyr::rename("Clean_dirty"=handrinse.nails_madre)

Adult_hands_dirt<-prev_adult_hands%>%
  mutate(handrinse.dirt_madre=str_replace(handrinse.dirt_madre, "yes", "Dirty hands"))%>%
  mutate(handrinse.dirt_madre=str_replace(handrinse.dirt_madre, "no", "Clean hands"))%>%
  group_by(handrinse.dirt_madre)%>%
  dplyr::summarize(Count=n())%>%
  dplyr::rename("Clean_dirty"=handrinse.dirt_madre)

Adult_hands_washed<-prev_adult_hands%>%
  group_by(handrinse.mother_handwash)%>%
  dplyr::summarize(Count=n())%>%
  dplyr::rename("Clean_dirty"=handrinse.mother_handwash)

Adult_hands_nails<-prev_adult_hands%>%
  mutate(handrinse.nails_madre=str_replace(handrinse.nails_madre, "yes", "Dirty nails"))%>%
  mutate(handrinse.nails_madre=str_replace(handrinse.nails_madre, "no", "Clean nails"))%>%
  group_by(handrinse.nails_madre)%>%
  dplyr::summarize(Count=n())%>%
  dplyr::rename("Clean_dirty"=handrinse.nails_madre)

Adult_hands <-Adult_hands_dirt%>%
  rbind(Adult_hands_nails)%>%
  rbind(Adult_hands_washed)%>%
  group_by(Clean_dirty)%>%
  dplyr::rename(" "=Clean_dirty)%>%
  kbl(col.names=NULL)%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  pack_rows("Adult hands", 1, 2) %>%
  pack_rows("Adult nails", 3, 4) %>%
  pack_rows("Adult last washed", 5, 8)%>%
  add_header_above(c("Adult handwash metadata (n=59)"=2))
Adult_hands
Adult handwash metadata (n=59)
Adult hands
No 41
Yes 18
Adult nails
No 30
Yes 29
Adult last washed
Less than one hour ago 28
More than two hours ago 9
One hour ago 8
Two hours ago 14
Child_hands_nails<-prev_child_hands%>%
  mutate(handrinse.nails_bebe=str_replace(handrinse.nails_bebe, "yes", "Dirty nails"))%>%
  mutate(handrinse.nails_bebe=str_replace(handrinse.nails_bebe, "no", "Clean nails"))%>%
  group_by(handrinse.nails_bebe)%>%
  dplyr::summarize(Count=n())%>%
  dplyr::rename("Clean_dirty"=handrinse.nails_bebe)

Child_hands_dirt<-prev_child_hands%>%
  mutate(handrinse.dirt_bebe=str_replace(handrinse.dirt_bebe, "yes", "Dirty hands"))%>%
  mutate(handrinse.dirt_bebe=str_replace(handrinse.dirt_bebe, "no", "Clean hands"))%>%
  group_by(handrinse.dirt_bebe)%>%
  dplyr::summarize(Count=n())%>%
  dplyr::rename("Clean_dirty"=handrinse.dirt_bebe)

Child_hands_washed<-prev_child_hands%>%
  group_by(handrinse.child_handwash)%>%
  dplyr::summarize(Count=n())%>%
  dplyr::rename("Clean_dirty"=handrinse.child_handwash)

Child_hands <-Child_hands_dirt%>%
  rbind(Child_hands_nails)%>%
  rbind(Child_hands_washed)%>%
  group_by(Clean_dirty)%>%
  dplyr::rename(" "=Clean_dirty)%>%
  kbl(col.names=NULL)%>%
  kable_styling(bootstrap_options="hover", full_width=F)%>%
  pack_rows("Child hands", 1, 2) %>%
  pack_rows("Child nails", 3, 4) %>%
  pack_rows("Child last washed", 5, 8)%>%
  add_header_above(c("Child hand wash metadata(n=31)"=2))
Child_hands
Child hand wash metadata(n=31)
Child hands
No 20
Yes 11
Child nails
No 11
Yes 20
Child last washed
Less than one hour ago 6
More than two hours ago 7
One hour ago 11
Two hours ago 7

#Adult hand cleanliness and MST marker detection in adult hand washes

#No test for GenBac; GenBac marker present in all adult hand washes

#HF183
AdultHands_dirt_HF183_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultHands_dirty"="handrinse.dirt_madre")%>%
  group_by(AdultHands_dirty)%>%
  dplyr::summarize(detected=sum(HF183), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

AdultHands_dirt_HF183_mosaic<-AdultHands_dirt_HF183_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  as.matrix()
mosaicplot(AdultHands_dirt_HF183_mosaic, color=TRUE, las=3)

fisher_AdultHands_dirty_HF183<-AdultHands_dirt_HF183_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultHands_dirty_HF183 #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.3295875 4.0589675
## sample estimates:
## odds ratio 
##   1.155013
#DG37
AdultHands_dirt_DG37_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultHands_dirty"="handrinse.dirt_madre")%>%
  group_by(AdultHands_dirty)%>%
  dplyr::summarize(detected=sum(DG37), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

AdultHands_dirt_DG37_mosaic<-AdultHands_dirt_DG37_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  as.matrix()
mosaicplot(AdultHands_dirt_DG37_mosaic, color=TRUE, las=3)

fisher_AdultHands_dirty_DG37<-AdultHands_dirt_DG37_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultHands_dirty_DG37 #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.5784
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.02797107 6.21640476
## sample estimates:
## odds ratio 
##  0.4172632
#GFD
AdultHands_dirt_GFD_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultHands_dirty"="handrinse.dirt_madre")%>%
  group_by(AdultHands_dirty)%>%
  dplyr::summarize(detected=sum(GFD), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

AdultHands_dirt_GFD_mosaic<-AdultHands_dirt_GFD_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  as.matrix()
mosaicplot(AdultHands_dirt_GFD_mosaic, color=TRUE, las=3)

fisher_AdultHands_dirty_GFD<-AdultHands_dirt_GFD_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultHands_dirty_GFD #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.546
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1799433       Inf
## sample estimates:
## odds ratio 
##        Inf
#Rum2Bac
AdultHands_dirt_Rum2Bac_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultHands_dirty"="handrinse.dirt_madre")%>%
  group_by(AdultHands_dirty)%>%
  dplyr::summarize(detected=sum(Rum2Bac), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

AdultHands_dirt_Rum2Bac_mosaic<-AdultHands_dirt_Rum2Bac_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  as.matrix()
mosaicplot(AdultHands_dirt_Rum2Bac_mosaic, color=TRUE, las=3)

fisher_AdultHands_dirty_Rum2Bac<-AdultHands_dirt_Rum2Bac_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultHands_dirty_Rum2Bac #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.01127248        Inf
## sample estimates:
## odds ratio 
##        Inf
#Pig2Bac
AdultHands_dirt_Pig2Bac_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultHands_dirty"="handrinse.dirt_madre")%>%
  group_by(AdultHands_dirty)%>%
  dplyr::summarize(detected=sum(Pig2Bac), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count)) 

AdultHands_dirt_Pig2Bac_mosaic<-AdultHands_dirt_Pig2Bac_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  as.matrix()
mosaicplot(AdultHands_dirt_Pig2Bac_mosaic, color=TRUE, las=3)

fisher_AdultHands_dirty_Pig2Bac<-AdultHands_dirt_Pig2Bac_counts%>%
  column_to_rownames("AdultHands_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultHands_dirty_Pig2Bac#ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.3027
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2902469       Inf
## sample estimates:
## odds ratio 
##        Inf

#Adult nail cleanliness and MST marker detection in adult hand washes

#No test for GenBac; GenBac marker present in all adult hand washes

#HF183
AdultNails_dirt_HF183_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultNails_dirty"="handrinse.nails_madre")%>%
  group_by(AdultNails_dirty)%>%
  dplyr::summarize(detected=sum(HF183), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

AdultNails_dirt_HF183_mosaic<-AdultNails_dirt_HF183_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  as.matrix()
mosaicplot(AdultNails_dirt_HF183_mosaic, color=TRUE, las=3)

fisher_AdultNails_dirty_HF183<-AdultNails_dirt_HF183_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultNails_dirty_HF183 #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.340446 3.343857
## sample estimates:
## odds ratio 
##    1.06549
#DG37
AdultNails_dirt_DG37_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultNails_dirty"="handrinse.nails_madre")%>%
  group_by(AdultNails_dirty)%>%
  dplyr::summarize(detected=sum(DG37), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

AdultNails_dirt_DG37_mosaic<-AdultNails_dirt_DG37_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  as.matrix()
mosaicplot(AdultNails_dirt_DG37_mosaic, color=TRUE, las=3)

fisher_AdultNails_dirty_DG37<-AdultNails_dirt_DG37_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultNails_dirty_DG37 #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.06559677 14.19203434
## sample estimates:
## odds ratio 
##    0.96487
#GFD
AdultNails_dirt_GFD_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultNails_dirty"="handrinse.nails_madre")%>%
  group_by(AdultNails_dirty)%>%
  dplyr::summarize(detected=sum(GFD), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

AdultNails_dirt_GFD_mosaic<-AdultNails_dirt_GFD_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  as.matrix()
mosaicplot(AdultNails_dirt_GFD_mosaic, color=TRUE, las=3)

fisher_AdultNails_dirty_GFD<-AdultNails_dirt_GFD_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultNails_dirty_GFD #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.1124
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.000000 2.287783
## sample estimates:
## odds ratio 
##          0
#Rum2Bac
AdultNails_dirt_Rum2Bac_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultNails_dirty"="handrinse.nails_madre")%>%
  group_by(AdultNails_dirty)%>%
  dplyr::summarize(detected=sum(Rum2Bac), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

AdultNails_dirt_Rum2Bac_mosaic<-AdultNails_dirt_Rum2Bac_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  as.matrix()
mosaicplot(AdultNails_dirt_Rum2Bac_mosaic, color=TRUE, las=3)

fisher_AdultNails_dirty_Rum2Bac<-AdultNails_dirt_Rum2Bac_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultNails_dirty_Rum2Bac #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.4915
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.0000 37.7005
## sample estimates:
## odds ratio 
##          0
#Pig2Bac
AdultNails_dirt_Pig2Bac_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("AdultNails_dirty"="handrinse.nails_madre")%>%
  group_by(AdultNails_dirty)%>%
  dplyr::summarize(detected=sum(Pig2Bac), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count)) 

AdultNails_dirt_Pig2Bac_mosaic<-AdultNails_dirt_Pig2Bac_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  as.matrix()
mosaicplot(AdultNails_dirt_Pig2Bac_mosaic, color=TRUE, las=3)

fisher_AdultNails_dirty_Pig2Bac<-AdultNails_dirt_Pig2Bac_counts%>%
  column_to_rownames("AdultNails_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_AdultNails_dirty_Pig2Bac #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.3533
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.005512171 4.064058509
## sample estimates:
## odds ratio 
##  0.3046125

#Adult last washed and MST marker detection in adult hand washes

#No test for GenBac; GenBac marker present in all adult hand washes

#HF183
Adult_lastwashed_HF183_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("Adult_lastwashed"="handrinse.mother_handwash")%>%
  group_by(Adult_lastwashed)%>%
  dplyr::summarize(detected=sum(HF183), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

Adult_lastwashed_HF183_mosaic<-Adult_lastwashed_HF183_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  as.matrix()
mosaicplot(Adult_lastwashed_HF183_mosaic, color=TRUE, las=3)

fisher_Adult_lastwashed_HF183<-Adult_lastwashed_HF183_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Adult_lastwashed_HF183 #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59 0.529 ns
#DG37
Adult_lastwashed_DG37_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("Adult_lastwashed"="handrinse.mother_handwash")%>%
  group_by(Adult_lastwashed)%>%
  dplyr::summarize(detected=sum( DG37), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

Adult_lastwashed_DG37_mosaic<-Adult_lastwashed_DG37_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  as.matrix()
mosaicplot(Adult_lastwashed_DG37_mosaic, color=TRUE, las=3)

fisher_Adult_lastwashed_DG37<-Adult_lastwashed_DG37_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Adult_lastwashed_DG37 #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59 0.563 ns
#GFD
Adult_lastwashed_GFD_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("Adult_lastwashed"="handrinse.mother_handwash")%>%
  group_by(Adult_lastwashed)%>%
  dplyr::summarize(detected=sum(GFD), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

Adult_lastwashed_GFD_mosaic<-Adult_lastwashed_GFD_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  as.matrix()
mosaicplot(Adult_lastwashed_GFD_mosaic, color=TRUE, las=3)

fisher_Adult_lastwashed_GFD<-Adult_lastwashed_GFD_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Adult_lastwashed_GFD #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59 0.616 ns
#Rum2Bac
Adult_lastwashed_Rum2Bac_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("Adult_lastwashed"="handrinse.mother_handwash")%>%
  group_by(Adult_lastwashed)%>%
  dplyr::summarize(detected=sum(Rum2Bac), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

Adult_lastwashed_Rum2Bac_mosaic<-Adult_lastwashed_Rum2Bac_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  as.matrix()
mosaicplot(Adult_lastwashed_Rum2Bac_mosaic, color=TRUE, las=3)

fisher_Adult_lastwashed_Rum2Bac<-Adult_lastwashed_Rum2Bac_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Adult_lastwashed_Rum2Bac #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59     1 ns
#Pig2Bac
Adult_lastwashed_Pig2Bac_counts<-prev%>%
  subset(Sample_Type=="Adult hands")%>%
  dplyr::rename("Adult_lastwashed"="handrinse.mother_handwash")%>%
  group_by(Adult_lastwashed)%>%
  dplyr::summarize(detected=sum(Pig2Bac), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

Adult_lastwashed_Pig2Bac_mosaic<-Adult_lastwashed_Pig2Bac_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  as.matrix()
mosaicplot(Adult_lastwashed_Pig2Bac_mosaic, color=TRUE, las=3)

fisher_Adult_lastwashed_Pig2Bac<-Adult_lastwashed_Pig2Bac_counts%>%
  column_to_rownames("Adult_lastwashed")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Adult_lastwashed_Pig2Bac #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    59     1 ns

#Child hand cleanliness and MST marker detection in child hand washes

#No test for GenBac; GenBac marker present in all child hand washes

#HF183
ChildHands_dirt_HF183_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("ChildHands_dirty"="handrinse.dirt_bebe")%>%
  group_by(ChildHands_dirty)%>%
  dplyr::summarize(detected=sum(HF183), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

ChildHands_dirt_HF183_mosaic<-ChildHands_dirt_HF183_counts%>%
  column_to_rownames("ChildHands_dirty")%>%
  as.matrix()
mosaicplot(ChildHands_dirt_HF183_mosaic, color=TRUE, las=3)

fisher_ChildHands_dirty_HF183<-ChildHands_dirt_HF183_counts%>%
  column_to_rownames("ChildHands_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_ChildHands_dirty_HF183 #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.4578
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.3785269 13.1296857
## sample estimates:
## odds ratio 
##   2.086411
#DG37
ChildHands_dirt_DG37_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("ChildHands_dirty"="handrinse.dirt_bebe")%>%
  group_by(ChildHands_dirty)%>%
  dplyr::summarize(detected=sum(DG37), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

ChildHands_dirt_DG37_mosaic<-ChildHands_dirt_DG37_counts%>%
  column_to_rownames("ChildHands_dirty")%>%
  as.matrix()
mosaicplot(ChildHands_dirt_DG37_mosaic, color=TRUE, las=3)

fisher_ChildHands_dirty_DG37<-ChildHands_dirt_DG37_counts%>%
  column_to_rownames("ChildHands_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_ChildHands_dirty_DG37 #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 1
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##   0.07601926 11.23365764
## sample estimates:
## odds ratio 
##  0.8001944
#GFD
ChildHands_dirt_GFD_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("ChildHands_dirty"="handrinse.dirt_bebe")%>%
  group_by(ChildHands_dirty)%>%
  dplyr::summarize(detected=sum(GFD), count=n())%>%
  dplyr::mutate(not_detected=count-detected)%>%
  select(-c(count))

ChildHands_dirt_GFD_mosaic<-ChildHands_dirt_GFD_counts%>%
  column_to_rownames("ChildHands_dirty")%>%
  as.matrix()
mosaicplot(ChildHands_dirt_GFD_mosaic, color=TRUE, las=3)

fisher_ChildHands_dirty_GFD<-ChildHands_dirt_GFD_counts%>%
  column_to_rownames("ChildHands_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_ChildHands_dirty_GFD #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.5269
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1022909       Inf
## sample estimates:
## odds ratio 
##        Inf
#Rum2Bac not detected in child hand washes

#Pig2Bac not detected in child handwashes

#Child nail cleanliness and MST marker detection in child hand washes

#No test for GenBac; GenBac marker present in all child hand washes

#HF183
ChildNails_dirt_HF183_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("ChildNails_dirty"="handrinse.nails_madre")%>%
  group_by(ChildNails_dirty)%>%
  dplyr::summarize(detected=sum(HF183), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

ChildNails_dirt_HF183_mosaic<-ChildNails_dirt_HF183_counts%>%
  column_to_rownames("ChildNails_dirty")%>%
  as.matrix()
mosaicplot(ChildNails_dirt_HF183_mosaic, color=TRUE, las=3)

fisher_ChildNails_dirty_HF183<-ChildNails_dirt_HF183_counts%>%
  column_to_rownames("ChildNails_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_ChildNails_dirty_HF183 #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.716
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.2904229 8.6414424
## sample estimates:
## odds ratio 
##   1.533399
#DG37
ChildNails_dirt_DG37_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("ChildNails_dirty"="handrinse.nails_madre")%>%
  group_by(ChildNails_dirty)%>%
  dplyr::summarize(detected=sum(DG37), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

ChildNails_dirt_DG37_mosaic<-ChildNails_dirt_DG37_counts%>%
  column_to_rownames("ChildNails_dirty")%>%
  as.matrix()
mosaicplot(ChildNails_dirt_DG37_mosaic, color=TRUE, las=3)

fisher_ChildNails_dirty_DG37<-ChildNails_dirt_DG37_counts%>%
  column_to_rownames("ChildNails_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_ChildNails_dirty_DG37 #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.6236
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##    0.2358204 157.2291624
## sample estimates:
## odds ratio 
##   2.843649
#GFD
ChildNails_dirt_GFD_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("ChildNails_dirty"="handrinse.nails_madre")%>%
  group_by(ChildNails_dirty)%>%
  dplyr::summarize(detected=sum(GFD), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

ChildNails_dirt_GFD_mosaic<-ChildNails_dirt_GFD_counts%>%
  column_to_rownames("ChildNails_dirty")%>%
  as.matrix()
mosaicplot(ChildNails_dirt_GFD_mosaic, color=TRUE, las=3)

fisher_ChildNails_dirty_GFD<-ChildNails_dirt_GFD_counts%>%
  column_to_rownames("ChildNails_dirty")%>%
  fisher.test(simulate.p.value = TRUE, B= 1e4)
fisher_ChildNails_dirty_GFD #ns; p>0.05
## 
##  Fisher's Exact Test for Count Data
## 
## data:  .
## p-value = 0.5097
## alternative hypothesis: true odds ratio is not equal to 1
## 95 percent confidence interval:
##  0.1180383       Inf
## sample estimates:
## odds ratio 
##        Inf
#Rum2Bac not detected in child hand washes

#Pig2Bac not detected in child hand washes

#Child last washed and MST marker detection in child hand washes

#No test for GenBac; GenBac marker present in all adult hand washes

#HF183
Child_lastwashed_HF183_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("Child_lastwashed"="handrinse.child_handwash")%>%
  group_by(Child_lastwashed)%>%
  dplyr::summarize(detected=sum(HF183), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

Child_lastwashed_HF183_mosaic<-Child_lastwashed_HF183_counts%>%
  column_to_rownames("Child_lastwashed")%>%
  as.matrix()
mosaicplot(Child_lastwashed_HF183_mosaic, color=TRUE, las=3)

fisher_Child_lastwashed_HF183<-Child_lastwashed_HF183_counts%>%
  column_to_rownames("Child_lastwashed")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Child_lastwashed_HF183 #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    31 0.358 ns
#DG37
Child_lastwashed_DG37_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("Child_lastwashed"="handrinse.child_handwash")%>%
  group_by(Child_lastwashed)%>%
  dplyr::summarize(detected=sum( DG37), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

Child_lastwashed_DG37_mosaic<-Child_lastwashed_DG37_counts%>%
  column_to_rownames("Child_lastwashed")%>%
  as.matrix()
mosaicplot(Child_lastwashed_DG37_mosaic, color=TRUE, las=3)

fisher_Child_lastwashed_DG37<-Child_lastwashed_DG37_counts%>%
  column_to_rownames("Child_lastwashed")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Child_lastwashed_DG37 #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    31     1 ns
#GFD
Child_lastwashed_GFD_counts<-prev%>%
  subset(Sample_Type=="Child hands")%>%
  dplyr::rename("Child_lastwashed"="handrinse.child_handwash")%>%
  group_by(Child_lastwashed)%>%
  dplyr::summarize(detected=sum(GFD), count=n())%>%
  mutate(not_detected=count-detected)%>%
  select(-c(count))

Child_lastwashed_GFD_mosaic<-Child_lastwashed_GFD_counts%>%
  column_to_rownames("Child_lastwashed")%>%
  as.matrix()
mosaicplot(Child_lastwashed_GFD_mosaic, color=TRUE, las=3)

fisher_Child_lastwashed_GFD<-Child_lastwashed_GFD_counts%>%
  column_to_rownames("Child_lastwashed")%>%
  fisher_test(simulate.p.value = TRUE, B= 1e4)
fisher_Child_lastwashed_GFD #ns; p>0.05
## # A tibble: 1 × 3
##       n     p p.signif
## * <dbl> <dbl> <chr>   
## 1    31     1 ns
#Rum2Bac not detected in child hand washes

#Pig2Bac not detected in child hand washes

#HF183 detections in adult hand washes and other sample types with GEE and HH-level clustering

#run Poisson regression with GEE 
run_poisson_gee <- function(data, target_sample_type) {
  df <- data %>%
    filter(Sample_Type %in% c("Adult hands", target_sample_type)) %>%
    group_by(Household) %>%
    filter(n() == 2) %>%
    ungroup() %>%
    select(Household, Sample_Type, HF183) %>%
    pivot_wider(names_from = Sample_Type, values_from = HF183, values_fill = 0)

  names(df)[names(df) == target_sample_type] <- "target"
  names(df)[names(df) == "Adult hands"] <- "adult"

  df <- df %>%
    mutate(
      target_detect = ifelse(target > 0, 1, 0),
      adult_detect = ifelse(adult > 0, 1, 0)
    )

  model <- geeglm(
    target_detect ~ adult_detect,
    family = poisson(link = "log"),
    id = Household,
    corstr = "exchangeable",
    data = df
  )

  est <- coef(model)["adult_detect"]
  se <- summary(model)$coefficients["adult_detect", "Std.err"]
  RR <- exp(est)
  CI_lower <- exp(est - 1.96 * se)
  CI_upper <- exp(est + 1.96 * se)
  pval <- summary(model)$coefficients["adult_detect", "Pr(>|W|)"]

  return(data.frame(
    Comparison = target_sample_type,
    Risk_Ratio = round(RR, 2),
    CI_Lower = round(CI_lower, 2),
    CI_Upper = round(CI_upper, 2),
    P_value = signif(pval, 3),
    N_Households = nrow(df)
  ))
}

sample_types <- c("Child hands", "Floor", "Doorknob", "Toy",
                  "Food- prep surface", "Domestic water", "Cellphone")

poisson_gee_results <- lapply(sample_types, function(type) {
  run_poisson_gee(prev, type)
}) %>%
  bind_rows()

print(poisson_gee_results)
##                          Comparison   Risk_Ratio     CI_Lower     CI_Upper
## adult_detect...1        Child hands 4.270000e+00 1.490000e+00 1.220000e+01
## adult_detect...2              Floor 6.770000e+00 1.700000e+00 2.704000e+01
## adult_detect...3           Doorknob 8.109013e+22 3.736757e+22 1.759710e+23
## adult_detect...4                Toy 4.405801e+24 2.699110e+24 7.191660e+24
## adult_detect...5 Food- prep surface 4.500000e+00 5.600000e-01 3.613000e+01
## adult_detect...6     Domestic water 3.355966e+20 1.341829e+20 8.393401e+20
## adult_detect...7          Cellphone 3.026194e+18 4.262649e+17 2.148394e+19
##                  P_value N_Households
## adult_detect...1 0.00681           31
## adult_detect...2 0.00675           59
## adult_detect...3 0.00000           59
## adult_detect...4 0.00000           31
## adult_detect...5 0.15700           57
## adult_detect...6 0.00000           48
## adult_detect...7 0.00000           30
#write.csv(poisson_gee_results, file="HF183_poisson_gee_results.csv")

#forest plot
filtered_poisson_plot_data <- poisson_gee_results %>%
  filter(!Comparison %in% c("Doorknob", "Toy", "Domestic water", "Cellphone")) %>%
  mutate(
    Comparison = factor(Comparison, levels = rev(unique(Comparison)))
  ) #filters results where HF183 is present in all adult hand rinses where the other sample type is also positive (perfect concordance)

#forest plot
poisson_forest_plot <- ggplot(filtered_poisson_plot_data, aes(y = Comparison, x = Risk_Ratio)) +
  geom_errorbarh(
    aes(xmin = CI_Lower, xmax = CI_Upper),
    height = 0.2,
    color = "black"
  ) +
  geom_point(size = 3, color = "#59A14F") +
  geom_vline(xintercept = 1, linetype = "dashed", color = "gray40") +
  scale_x_log10() +
  labs(
    x = expression("Risk Ratio (" * log[10] * " scale)"),
    y = NULL,
    title = NULL
  ) +
  theme_minimal() +
  theme(
    axis.text.y = element_text(size = 12),
    axis.text.x = element_text(size = 10),
    axis.title.x = element_text(size = 13),
    plot.title = element_text(size = 14, face = "bold", hjust = 0.5)
  )

poisson_forest_plot

#Sample characteristics summary table

var_lookup <- tibble::tibble(
  Variable = c(
    "handrinse.mother_handwash",
    "handrinse.nails_madre",
    "handrinse.dirt_madre",
    "handrinse.child_handwash",
    "handrinse.nails_bebe",
    "handrinse.dirt_bebe",
    "Floor.type",
    "floor.floor_cleaning",
    "door.door_selection",
    "food.food_container",
    "food.food_storecond",
    "food.food_options",
    "foodprep.foodprep_cleaning",
    "foodprep.foodprep_surface", 
    "soil.soil_animal",
    "soil.soil_feces",
    "soil.soil_moisture",
    "domestic_water.dwater_animals",
    "domestic_water.dwater_store",
    "domestic_water.dwater_container",
    "domestic_water.dwater_child",
    "drinkingwater.water_store",
    "drinkingwater.water_treat",
    "drinkingwater.fuente",
    "drinkingwater.water_container",
    "toys.toy_material",
    "toys.toy_clean"
  ),
  Sample_characteristic = c(
    "Adult last washed", "Adult clean nails", "Adult clean hands",
    "Child last washed", "Child clean nails", "Child clean hands",
    "Floor type", "Floor cleaned in the past 24h",
    "Door location",   "Food container",
    "Food temperature", "Food type",
    "Food-prep surface last cleaned", "Food-prep surface material",
    "Visible human feces", "Visible animal feces", "Soil moisture",
    "Animals access domestic water", "Domestic water stored", "Domestic water container type", "Child access to domestic water",
    "Drinking water stored", "Drinking water treated", "Drinking water source", "Drinking water container type",
    "Toy material", "Toy dirty/clean"
  ),
  Sample_group = c(
    rep("Adult hands", 3),
    rep("Child hands", 3),
    rep("Floor", 2),
    rep("Doorknob", 1),
    rep("Food", 3),
    rep("Food- prep surface", 2),
    rep("Soil", 3),
    rep("Domestic water", 4),
    rep("Drinking water", 4),
    rep("Toy", 2)
  )
)

summary_clean <- map_dfr(seq_len(nrow(var_lookup)), function(i) {
  var <- var_lookup$Variable[i]
  label <- var_lookup$Sample_characteristic[i]
  group <- var_lookup$Sample_group[i]

  filtered <- data %>%
    filter(Sample_Type == group) %>%
    filter(!is.na(.data[[var]])) %>%
    select(Response = .data[[var]])

  if (nrow(filtered) == 0) return(NULL)

  filtered %>%
    count(Response) %>%
    mutate(
      percent = round(n / sum(n) * 100, 1),
      `n (%)` = paste0(n, " (", percent, "%)"),
      Sample_characteristic = label,
      Sample_group = group
    ) %>%
    select(Sample_group, Sample_characteristic, Response, `n (%)`)
})

summary_table <- summary_clean %>%
  arrange(Sample_group, Sample_characteristic, Response) %>%
  flextable() %>%
  set_header_labels(
    Sample_group = "Sample Type",
    Sample_characteristic = "Household Environmental Practice",
    Response = "Response",
    `n (%)` = "n (%)"
  ) %>%
  merge_v(j = ~Sample_group + Sample_characteristic) %>%  
  align(j = 1:4, align = "left", part = "all") %>%
  bold(part = "header") %>%
  valign(j = 1:2, valign = "top") %>% 
  autofit() %>%
  fontsize(part = "all", size = 10) %>%
  theme_vanilla()
summary_table

Sample Type

Household Environmental Practice

Response

n (%)

Adult hands

Adult clean hands

No

41 (69.5%)

Yes

18 (30.5%)

Adult clean nails

No

30 (50.8%)

Yes

29 (49.2%)

Adult last washed

Less than one hour ago

28 (47.5%)

More than two hours ago

9 (15.3%)

One hour ago

8 (13.6%)

Two hours ago

14 (23.7%)

Child hands

Child clean hands

No

20 (64.5%)

Yes

11 (35.5%)

Child clean nails

No

11 (35.5%)

Yes

20 (64.5%)

Child last washed

Less than one hour ago

6 (19.4%)

More than two hours ago

7 (22.6%)

One hour ago

11 (35.5%)

Two hours ago

7 (22.6%)

Domestic water

Animals access domestic water

3 (6.2%)

No

42 (87.5%)

Yes

3 (6.2%)

Child access to domestic water

26 (54.2%)

No

14 (29.2%)

Yes

8 (16.7%)

Domestic water container type

12 (25%)

Not covered

22 (45.8%)

Poorly covered

3 (6.2%)

Well covered

11 (22.9%)

Domestic water stored

3 (6.2%)

No

9 (18.8%)

Yes

36 (75%)

Doorknob

Door location

Entrance door

53 (89.8%)

Kitchen door

3 (5.1%)

Patio exit door

3 (5.1%)

Drinking water

Drinking water container type

3 (5.5%)

Not covered

9 (16.4%)

Poorly covered

14 (25.5%)

Well covered

29 (52.7%)

Drinking water source

Bottled water

32 (58.2%)

Piped water connection

10 (18.2%)

Protected well

1 (1.8%)

Rain water

11 (20%)

Unprotected well

1 (1.8%)

Drinking water stored

No

3 (5.5%)

Yes

52 (94.5%)

Drinking water treated

Boil

3 (5.5%)

Chlorine

1 (1.8%)

Filter

2 (3.6%)

Larvicide

2 (3.6%)

None

47 (85.5%)

Floor

Floor cleaned in the past 24h

No

50 (84.7%)

Yes

9 (15.3%)

Floor type

Carpet

1 (1.7%)

Cement

22 (37.3%)

Ceramic tiles

16 (27.1%)

Other

1 (1.7%)

Vinyl/asphalt

4 (6.8%)

Wooden boards

15 (25.4%)

Food

Food container

7 (12.3%)

Not covered

21 (36.8%)

Poorly covered

15 (26.3%)

Well covered

14 (24.6%)

Food temperature

7 (12.3%)

Refrigerated

9 (15.8%)

Room temperature

41 (71.9%)

Food type

4 (7%)

Colada

3 (5.3%)

Cooked rice

47 (82.5%)

Green plantain

2 (3.5%)

Other food

1 (1.8%)

Food- prep surface

Food-prep surface last cleaned

No

39 (68.4%)

Yes

18 (31.6%)

Food-prep surface material

Cement

6 (10.5%)

Ceramic tiles

24 (42.1%)

Other

3 (5.3%)

Plastic

9 (15.8%)

Stainless steel

1 (1.8%)

Wood

14 (24.6%)

Soil

Soil moisture

Dry

16 (29.6%)

Moist

32 (59.3%)

Very wet

6 (11.1%)

Visible animal feces

No

46 (85.2%)

Yes

8 (14.8%)

Visible human feces

No

31 (57.4%)

Yes

23 (42.6%)

Toy

Toy dirty/clean

No

29 (93.5%)

Yes

2 (6.5%)

Toy material

Cotton

1 (3.2%)

Plastic

29 (93.5%)

Wood

1 (3.2%)

save_as_docx(summary_table, path = "Household_Summary_Merged.docx")