Step 1: Load Data

#load all the packages you need
library(survival)
library(RColorBrewer)
library(ggplot2)
library(rlang)
library(agricolae)


#Bacterial Load for E. faecalis and P. sneebia 

BacterialLoad_1<-read.table("5.30EFandPS.final.csv", header=TRUE, sep=",", dec=".",na.strings=".")
BacterialLoad_2<-read.table("6.6Efae_Psnee.csv", header=TRUE, sep=",", dec=".",na.strings=".")
BacterialLoad_3<-read.table("6.8EFandPS.final.csv", header=TRUE, sep=",", dec=".",na.strings=".")
BacterialLoad_combined<-read.table("EfaeandPsneeb.combined.final.csv", header=TRUE, sep=",", dec=".",na.strings=".")


bacteria_yes<-subset(BacterialLoad_2,Bacteria=="Y")
bacteria_yes<-subset(BacterialLoad_3,Bacteria=="Y")
bacteria_yes<-subset(BacterialLoad_combined,Bacteria=="Y")

bacteria_12h_1<-subset(BacterialLoad_1,Time=="12")
bacteria_12h_2<-subset(BacterialLoad_2,Time=="12")
bacteria_12h_3<-subset(BacterialLoad_3,Time=="12")
bacteria_12h_combined<-subset(BacterialLoad_combined,Time=="12")

Step 2: E. faecalis Plots and Stats

12 hour Plot (1)

#png(file="Efae.5.30.png", width=1500, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_Ef_1<-subset(bacteria_12h_1,Species=="Efaec")

ggplot(bacteria_Ef_1, aes(x=Sex, y=log(FlyLoad), fill=FlyLine)) +
  geom_boxplot()+
  geom_dotplot(binaxis='y', stackdir='center', binwidth=0.2, position=position_dodge(0.8))+
   scale_fill_manual(values=c("#B5E8FC", "#055df5"))

12 hour stats (1)

bacteriastats_Ef_1<-lm(FlyLoad~FlyLine*Sex, data=bacteria_Ef_1)
anova(bacteriastats_Ef_1)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value Pr(>F)
## FlyLine      1 3.4359e+11 3.4359e+11  2.6824 0.1198
## Sex          1 1.7309e+09 1.7309e+09  0.0135 0.9088
## FlyLine:Sex  1 8.8104e+10 8.8104e+10  0.6878 0.4184
## Residuals   17 2.1776e+12 1.2809e+11

12 hour plot (2)

#png(file="Efae6.6.png", width=1500, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_Ef_2<-subset(bacteria_12h_2,Species=="Efaec")

ggplot(bacteria_Ef_2, aes(x=Sex, y=log(FlyLoad), fill=FlyLine)) +
  geom_boxplot()+
  geom_dotplot(binaxis='y', stackdir='center', binwidth=0.2, position=position_dodge(0.8))+
   scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing non-finite values (stat_bindot).

12 hour stats (2)

bacteriastats_Ef_2<-lm(FlyLoad~FlyLine*Sex, data=bacteria_Ef_2)
anova(bacteriastats_Ef_2)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value  Pr(>F)  
## FlyLine      1 4.9977e+10 4.9977e+10  4.6706 0.04134 *
## Sex          1 2.9035e+08 2.9035e+08  0.0271 0.87060  
## FlyLine:Sex  1 2.0504e+10 2.0504e+10  1.9162 0.17956  
## Residuals   23 2.4611e+11 1.0700e+10                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

12 hour plot(3)

#png(file="Efae.6.8.png", width=1500, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_Ef_3<-subset(bacteria_12h_3,Species=="Efaec")

ggplot(bacteria_Ef_3, aes(x=Sex, y=log(FlyLoad), fill=FlyLine)) +
  geom_boxplot()+
  geom_dotplot(binaxis='y', stackdir='center', binwidth=0.2, position=position_dodge(0.8))+
   scale_fill_manual(values=c("#B5E8FC", "#055df5"))

12 hour stats(3)

bacteriastats_Ef_3<-lm(FlyLoad~FlyLine*Sex, data=bacteria_Ef_3)
anova(bacteriastats_Ef_3)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value Pr(>F)
## FlyLine      1 2.5429e+09 2.5429e+09  0.0624 0.8055
## Sex          1 4.7301e+10 4.7301e+10  1.1600 0.2949
## FlyLine:Sex  1 2.4801e+10 2.4801e+10  0.6082 0.4451
## Residuals   19 7.7474e+11 4.0776e+10

12 hour combined graph

#png(file="Efaecombined.png", width=1500, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_Ef_combined<-subset(bacteria_12h_combined,Species=="Efaec")

ggplot(bacteria_Ef_combined, aes(x=Sex, y=log(FlyLoad), fill=FlyLine)) +
  geom_boxplot()+
  geom_dotplot(binaxis='y', stackdir='center', binwidth=0.2, position=position_dodge(0.8))+
   scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing non-finite values (stat_bindot).

12 hour combined stats

bacteriastats_Ef_combined<-lm(FlyLoad~Date+FlyLine*Sex, data=bacteria_Ef_combined)
anova(bacteriastats_Ef_combined)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value   Pr(>F)   
## Date         2 7.7950e+11 3.8975e+11  7.1911 0.001509 **
## FlyLine      1 2.3421e+11 2.3421e+11  4.3213 0.041590 * 
## Sex          1 1.6698e+10 1.6698e+10  0.3081 0.580762   
## FlyLine:Sex  1 3.4035e+09 3.4035e+09  0.0628 0.802918   
## Residuals   65 3.5229e+12 5.4199e+10                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Step 3: P.sneebia Plots and Stats

12 hour Plot (1)

#png(file="Psneeb5.30.png", width=1200, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_Ps_1<-subset(bacteria_12h_1,Species=="Psneeb")

ggplot(bacteria_Ps_1, aes(x=Sex, y=log(FlyLoad), fill=FlyLine))+
geom_boxplot()+
geom_dotplot(binaxis='y', stackdir='center',position=position_dodge(0.8))+
scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.

12 hour stats(1)

bacteriastats_Ps_1<-lm(FlyLoad~FlyLine*Sex, data=bacteria_Ps_1)
anova(bacteriastats_Ps_1)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value  Pr(>F)  
## FlyLine      1 1.1153e+11 1.1153e+11  7.5183 0.01257 *
## Sex          1 3.8562e+09 3.8562e+09  0.2600 0.61573  
## FlyLine:Sex  1 1.1323e+09 1.1323e+09  0.0763 0.78517  
## Residuals   20 2.9669e+11 1.4834e+10                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

12 hour plot(2)

#png(file="PS6.6.png", width=1200, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory 

bacteria_Ps_2<-subset(bacteria_12h_2,Species=="Psneeb") 

ggplot(bacteria_Ps_2, aes(x=Sex, y=log(FlyLoad), fill=FlyLine))+
geom_boxplot()+
geom_dotplot(binaxis='y', stackdir='center',position=position_dodge(0.8))+
scale_fill_manual(values=c("#B5E8FC", "#055df5")) 
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
## Warning: Removed 1 rows containing non-finite values (stat_bindot).

12 hour stats (2)

bacteriastats_Ps_2<-lm(FlyLoad~FlyLine*Sex, data=bacteria_Ps_2)
anova(bacteriastats_Ps_2)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value   Pr(>F)   
## FlyLine      1 1.0346e+11 1.0346e+11 12.2874 0.002106 **
## Sex          1 5.3029e+10 5.3029e+10  6.2982 0.020350 * 
## FlyLine:Sex  1 1.6489e+10 1.6489e+10  1.9583 0.176290   
## Residuals   21 1.7681e+11 8.4197e+09                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

12 hour plot(3)

#png(file="Psneeb6.8.png", width=1500, height=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_Ps_3<-subset(bacteria_12h_3,Species=="Psneeb")

ggplot(bacteria_Ps_3, aes(x=Sex, y=log(FlyLoad), fill=FlyLine))+
geom_boxplot()+
geom_dotplot(binaxis='y', stackdir='center',position=position_dodge(0.8))+
scale_fill_manual(values=c("#B5E8FC", "#055df5")) 
## Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.

12 hour stats (3)

bacteriastats_Ps_3<-lm(FlyLoad~FlyLine*Sex, data=bacteria_Ps_3) 
anova(bacteriastats_Ps_3)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value Pr(>F)  
## FlyLine      1 2.4665e+07 2.4665e+07  0.0113 0.9163  
## Sex          1 1.0834e+10 1.0834e+10  4.9724 0.0368 *
## FlyLine:Sex  1 4.6505e+06 4.6505e+06  0.0021 0.9636  
## Residuals   21 4.5757e+10 2.1789e+09                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

12 hour plot (combined)

#png(file="Psneeb6.8.png", width=1500, height=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_Ps_combined<-subset(bacteria_12h_combined,Species=="Psneeb") 

ggplot(bacteria_Ps_combined, aes(x=Sex, y=log(FlyLoad), fill=FlyLine))+
geom_boxplot()+
geom_dotplot(binaxis='y', stackdir='center',position=position_dodge(0.8))+
scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
## Warning: Removed 1 rows containing non-finite values (stat_bindot).

12 hour stats (combined)

bacteriastats_Ps_combined<-lm(FlyLoad~Date+FlyLine*Sex, data=bacteria_Ps_combined)
anova(bacteriastats_Ps_combined)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value    Pr(>F)    
## Date         2 4.2254e+10 2.1127e+10  2.1837 0.1204543    
## FlyLine      1 1.4093e+11 1.4093e+11 14.5673 0.0002947 ***
## Sex          1 1.0913e+10 1.0913e+10  1.1281 0.2919492    
## FlyLine:Sex  1 9.8903e+09 9.8903e+09  1.0223 0.3155604    
## Residuals   68 6.5788e+11 9.6747e+09                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

#Bacterial Load for S. marcescens BPL and S. marcescens DB1140

BacterialLoad_E1<-read.table("6.13SmarcBandD.final.csv", header=TRUE, sep=",", dec=".",na.strings=".")
BacterialLoad_E2<-read.table("6.20SmarcBandDload.csv", header=TRUE, sep=",", dec=".",na.strings=".")

bacteria_yes<-subset(BacterialLoad_E1,Bacteria=="Y")
bacteria_yes<-subset(BacterialLoad_E2,Bacteria=="Y")

bacteria_12h_E1<-subset(BacterialLoad_E1,Time=="12")
bacteria_12h_E2<-subset(BacterialLoad_E2,Time=="12")

Step 3: S.marcescens BPL Plots and Stats

12 hour Plot (E1)

#png(file="SMB.6.13.png", width=1500, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_SMB_E1<-subset(bacteria_12h_E1,Species=="SmarcB")

ggplot(bacteria_SMB_E1, aes(x=Sex, y=log(FlyLoad), fill=FlyLine)) +
  geom_boxplot()+
  geom_dotplot(binaxis='y', stackdir='center', binwidth=0.2, position=position_dodge(0.8))+
   scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Warning: Removed 1 rows containing non-finite values (stat_bindot).

12 hour stats (E1)

bacteriastats_SMB_E1<-lm(FlyLoad~FlyLine*Sex, data=bacteria_SMB_E1)
anova(bacteriastats_SMB_E1)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value Pr(>F)
## FlyLine      1 5.8711e+10 5.8711e+10  2.0138 0.1763
## Sex          1 3.3624e+10 3.3624e+10  1.1533 0.2998
## FlyLine:Sex  1 5.2561e+10 5.2561e+10  1.8029 0.1993
## Residuals   15 4.3731e+11 2.9154e+10

12 hour Plot (E2)

#png(file="SMB.6.20.png", width=1500, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_SMB_E2<-subset(bacteria_12h_E2,Species=="SmarcB")

ggplot(bacteria_SMB_E2, aes(x=Sex, y=log(FlyLoad), fill=FlyLine)) +
  geom_boxplot()+
  geom_dotplot(binaxis='y', stackdir='center', binwidth=0.2, position=position_dodge(0.8))+
   scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Warning: Removed 4 rows containing non-finite values (stat_boxplot).
## Warning: Removed 4 rows containing non-finite values (stat_bindot).

12 hour stats (E2)

bacteriastats_SMB_E2<-lm(FlyLoad~FlyLine*Sex, data=bacteria_SMB_E2)
anova(bacteriastats_SMB_E2)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq   Mean Sq F value Pr(>F)
## FlyLine      1 5.5705e+08 557053984  0.9949 0.3274
## Sex          1 6.2029e+08 620294948  1.1078 0.3019
## FlyLine:Sex  1 6.0132e+08 601317266  1.0739 0.3093
## Residuals   27 1.5118e+10 559931455

Step 4: S.marcescens DB1140 Plots and Stats

12 hour Plot (E1)

#png(file="SMD.6.13.png", width=1200, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_SMD_E1<-subset(bacteria_12h_E1,Species=="SmarcD")

ggplot(bacteria_SMD_E1, aes(x=Sex, y=log(FlyLoad), fill=FlyLine))+
geom_boxplot()+
geom_dotplot(binaxis='y', stackdir='center',position=position_dodge(0.8))+
scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.

12 hour stats(E1)

bacteriastats_SMD_E1<-lm(FlyLoad~FlyLine*Sex, data=bacteria_SMD_E1)
anova(bacteriastats_SMD_E1)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value Pr(>F)
## FlyLine      1 6.7408e+08 6.7408e+08  0.0116 0.9153
## Sex          1 7.0148e+10 7.0148e+10  1.2060 0.2852
## FlyLine:Sex  1 1.1157e+10 1.1157e+10  0.1918 0.6661
## Residuals   20 1.1633e+12 5.8165e+10

12 hour Plot (E2)

#png(file="SMD.6.20.png", width=1200, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_SMD_E2<-subset(bacteria_12h_E1,Species=="SmarcD")

ggplot(bacteria_SMD_E2, aes(x=Sex, y=log(FlyLoad), fill=FlyLine))+
geom_boxplot()+
geom_dotplot(binaxis='y', stackdir='center',position=position_dodge(0.8))+
scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.

12 hour stats(E1)

bacteriastats_SMD_E2<-lm(FlyLoad~FlyLine*Sex, data=bacteria_SMD_E2)
anova(bacteriastats_SMD_E2)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value Pr(>F)
## FlyLine      1 6.7408e+08 6.7408e+08  0.0116 0.9153
## Sex          1 7.0148e+10 7.0148e+10  1.2060 0.2852
## FlyLine:Sex  1 1.1157e+10 1.1157e+10  0.1918 0.6661
## Residuals   20 1.1633e+12 5.8165e+10

S.marcescens BPL 24 hour bacterial load

BacterialLoad_1<-read.table("6.15.S.marc24hour.final.csv", header=TRUE, sep=",", dec=".",na.strings=".")
bacteria_yes<-subset(BacterialLoad_1,Bacteria=="Y")
bacteria_24h_1<-subset(BacterialLoad_1,Time=="24")

24 hour plot

#png(file="6.15SMBbacterialload.png", width=1500, heigh=900, res=130) #can put the graph into a seperate PNG for you in your working directory

bacteria_SMB_1<-subset(bacteria_24h_1,Species=="SmarcB")

ggplot(bacteria_SMB_1, aes(x=Sex, y=log(FlyLoad), fill=FlyLine)) +
  geom_boxplot()+
  geom_dotplot(binaxis='y', stackdir='center', binwidth=0.2, position=position_dodge(0.8))+
   scale_fill_manual(values=c("#B5E8FC", "#055df5"))
## Warning: Removed 7 rows containing non-finite values (stat_boxplot).
## Warning: Removed 7 rows containing non-finite values (stat_bindot).

24 hour stats

bacteriastats_SMB_1<-lm(FlyLoad~FlyLine*Sex, data=bacteria_SMB_1)
anova(bacteriastats_SMB_1)
## Analysis of Variance Table
## 
## Response: FlyLoad
##             Df     Sum Sq    Mean Sq F value Pr(>F)
## FlyLine      1 8.6366e+75 8.6366e+75  0.8882 0.3609
## Sex          1 9.6527e+75 9.6527e+75  0.9926 0.3349
## FlyLine:Sex  1 8.5802e+75 8.5802e+75  0.8824 0.3624
## Residuals   15 1.4586e+77 9.7242e+75