### #This file contains R code to reconstruct Figs 1-4, S1, S3-S4, S6 and S8-S11 from Krasovec et al. 2017. #the nlme, ggplot2, ape and dplyr packages will need to be installed if not already present (e.g. using the following line without the # at the start: #install.packages(c("nlme", "ggplot2", "ape", "dplyr")) #Set the working directory by adjusting this line to indicate the folder containing the data (S1_Data.csv) and removing the # at the beginning: #setwd("/Path/to/folder") #the code may be run all together, or bit by bit from an R terminal library(nlme) library(ggplot2) library(ape) library(dplyr) ##create the Fig.1 # read in the data and re-order organisms phylogenetically d1 <-read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "1") %>% mutate(Microorganism = factor(organism, levels=c("Halobacterium salinarum","Haloferax volcanii","Sulfolobus acidocaldarius","Bacillus anthracis", "Staphylococcus aureus","Mycoplasma mycoides","Corynebacterium glutamicum","Mycobacterium smegmatis", "Mycobacterium tuberculosis","Deinococcus radiodurans","Thermus thermophilus","Helicobacter pylori","Brucella abortus","Brucella melitensis","Pseudomonas aeruginosa","Pseudomonas fluorescens","Haemophilus influenzae","Yersinia pestis","Escherichia coli","Salmonella enterica Typhimurium","Salmonella enterica Enteritidis","Saccharomyces cerevisiae","Bacteriophage phiX174","Bacteriophage Qbeta","Measles virus","Vesicular stomatitis virus"))) #create appropriate organism names l <- levels(d1$Microorganism) l[match(c("Bacteriophage phiX174","Bacteriophage Qbeta","Measles virus", "Vesicular stomatitis virus"),l)] <- c(expression(paste("Bacteriophage ", phi, "X174")), expression(paste("Bacteriophage Q", beta)), expression(paste("Measles virus")), expression(paste("Vesicular stomatitis virus"))) #choose appropriate colours Archaea <- c("#691F01","#B13E0F", "#FF6600") Bacteria <- c("#691F01","#B13E0F", "#FF6600", "#FF9955","#FFFF00","#ffff99","#A0A000","#BED661","#65D74D","#3AA655","#105952","#CBFFFA","#4997D0","#00468C","#002147","#d49dff","purple", "#4B0082") Eukaryote <- c("#FF0000") Virus <- c("#691F01","#B13E0F", "#FF6600", "#FF9955") #create the figure p1 <- ggplot(aes(x = D,y = mutation_rate, fill = Microorganism, shape = Microorganism), data=d1) graphics.off() pdf("Fig1.pdf",width=11, height=7) p1 + geom_point(alpha=0.7, size=5) + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), breaks=c(0.1,10,1000,100000), labels=c("0.1", "10", "1000", "100000")) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), breaks = 10^seq(4,10, by=2), labels=c(expression(10^4),expression(10^6),expression(10^8),expression(10^10))) + scale_shape_manual(name = "",values = c(rep(21, 3), rep(24, 18), 22, rep(23,4)), labels=l) + scale_fill_manual(name = "", values = c(Archaea,Bacteria, Eukaryote, Virus), labels=l) + theme(legend.position = c(0.25,0.27), legend.key.size = unit(0.55,"cm"), legend.title = element_text(face = "bold", size = 14), legend.title.align = 0.5, legend.text = element_text(face = "italic", size = 10), legend.key = element_rect(fill = 'white'), legend.text.align = 0, panel.background = element_rect(fill = "white"), axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.title.x = element_text(size=14), axis.title.y = element_text(size=14), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14) ) graphics.off() ##calibration model (Model S-IV) used below to convert LUM measurements to D dc <- read.csv(file = "S1_Data.csv", header = TRUE) %>% filter(organism %in% c("Escherichia coli", "Pseudomonas aeruginosa"), !is.na(LUM)) modCalib <- lme(log2(D)~I(log2(LUM)-21.816664392518216)*organism, data=dc, random=list(~I(log2(LUM)-21.816664392518216)|genotype, ~1|block, ~1|plate_ID), weights=varComb(varIdent(form=~1|block), varPower(form=~fitted(.)))) ## Fig. 2A; first create Model S-II # read in the data and create necessary composite columns d2a <-read.csv("S1_Data.csv") %>% subset(figure == "2a") %>% mutate(Cal = 2^predict(modCalib, newdata=., level=1), CalCent=log2(Cal)-mean(log2(Cal)), genotype_marker=factor(paste(genotype, marker, sep = '_')), organism=relevel(organism, ref="Escherichia coli"), genotype_marker=relevel(genotype_marker, ref="MG1655_rifampicin50"), sep_2a=factor(paste(included, marker, sep = '_')), organism=(factor(organism))) #create the model mod2a <- lme(log2(mutation_rate)~CalCent + genotype_marker + CalCent:organism, data=d2a, random=~1|researcher/block/plate_ID, weights=varPower(form = ~SD_m*C_cultures)) #use model to create values for the lines in the figure d2a$pred <- predict(mod2a,level=0) #create the figure p2a <- ggplot(aes(x = Cal,y = mutation_rate, colour = organism, shape = sep_2a), data=d2a) pdf("Fig2a.pdf",width=4, height=4.4) p2a + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), (breaks=c(0.3,2,20))) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(4e7, 1e8, 5e8))) + scale_shape_manual(values=c(2,19,17), guide=FALSE) + scale_color_manual(values=c("#000A44","#35A2AD"),guide=FALSE) + geom_line(aes(group=genotype_marker, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14) ) graphics.off() ## Fig. 2B; first create Model S-III # read in the data and create necessary composite columns d2b <- read.csv("S1_Data.csv") %>% filter(figure %in% c("2b"), !is.na(CC)) %>% mutate(l2Ccent=log2(CC)-mean(log2(CC)), genotype=factor(genotype), genotype=relevel(factor(genotype), ref="BY4742"), sep_2b=factor(paste(included, marker, sep = '_')), gen2=(factor(genotype))) levels(d2b$gen2) <- c("BY4742","S288_&_Sigma1278b","S288_&_Sigma1278b") #create model mod2b <- lme(log2(mutation_rate)~l2Ccent + genotype + gen2:l2Ccent, data=d2b, random=~1|block/plate_ID, weights=varComb(varIdent(form=~1|block), varPower(form=~culture_volume))) #use model to create values for the lines in the figure d2b$pred <- predict(mod2b,level=0) #create the figure p2b <- ggplot(aes(x = CC, y = mutation_rate, colour = genotype, shape = sep_2b, fill=genotype), data=d2b) pdf("Fig2b.pdf", width=4, height=4.4) p2b + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), (breaks=c(10, 100, 1000, 5000))) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(1e6, 1e7, 1e8))) + scale_shape_manual(values=c(5,0,23,22), guide=FALSE) + scale_color_manual(values=c("#660000","#FF0000","#FF9933"), guide=FALSE) + scale_fill_manual(values=c("#660000","#FF0000","#FF9933"), guide=FALSE) + geom_line(aes(group=genotype, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14) ) graphics.off() ## Fig. 3; first create Model S-VII # read in the data and create necessary composite columns d3 <-read.csv("S1_Data.csv", header = TRUE) %>% subset(figure == "3") %>% mutate(Cal = 2^predict(modCalib, newdata=., level=1), CalCent=log2(Cal)-mean(log2(Cal)), system=(factor(genotype)), system2=(factor(genotype)), genotype = factor(genotype), marker = factor(marker)) levels(d3$system) <- c("dam","dinB","metI","MMR","MMR","MMR","nei") levels(d3$system2) <- c("damBmetI","damBmetI","damBmetI","MMR","MMR","MMR","nei") levels(d3$genotype) <- c("mutL", "mutH", "mutS", "nei", "metI", "dinB","dam") levels(d3$marker) <- c("nalidixic_acid30", "rifampicin50") d3 <- arrange(d3, marker,genotype) #create the model mod3 <- lme(log2(mutation_rate)~CalCent + system + CalCent:system2, data=d3, random=~1|block/plate_ID, weights=varComb(varPower(form = ~fitted(.)), varPower(form = ~upper_bound))) #use model to create values for the lines in the figure d3$pred <- predict(mod3,level=0) #create the figure p3 <- ggplot(aes(x = Cal,y = mutation_rate, colour = genotype, shape = marker), data=d3) pdf("Fig3.pdf",width=4.4, height=4.4) p3 + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), (breaks=c(10,40, 100))) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(5e7, 1e8,5e8))) + scale_shape_manual(values=c(19,17), guide=FALSE) + scale_color_manual(values=c("#E69F00","#CC79A7","#0CEE0C","#0072B2","#000A44", "#4DCDFF","#075607"), guide=FALSE) + geom_line(aes(y = 2^pred), alpha=1, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14), plot.margin=unit(c(5.5, 15, 5.5, 5.5), "points")) graphics.off() ##Fig. 4A; first create Model S-VIII # read in the data and create necessary columns d4a <- read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "4a") %>% mutate(Cal = 2^predict(modCalib, newdata=., level=1), CalCent=log2(Cal)-mean(log2(Cal))) d4a$genotype=relevel(d4a$genotype, ref="mutT1") #create model mod4a <- lme(log2(mutation_rate)~1 + genotype, data=d4a, random=~1|block/plate_ID, weights=varComb(varPower(form = ~fitted(.)), varPower(form = ~upper_bound))) #use model to create values for the lines in the figure d4a$pred <- predict(mod4a,level=0) #create the figure p4a <- ggplot(aes(x = Cal,y = mutation_rate, colour = genotype, shape = marker), data=d4a) pdf("Fig4a.pdf",width=4, height=4.4) p4a + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), limits=c(5,95), breaks=c(6,30,90)) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(6e7, 3e8, 6e8))) + scale_color_manual(values=c("#246C7F","#4DCDFF"),guide=FALSE) + geom_line(aes(group=genotype, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4, shape=19) + theme_classic(base_size = 14) + theme(axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14) ) graphics.off() ##Fig. 4B; first create Model S-X # read in the data and create necessary columns d4b <- read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "4b") %>% mutate(Cal = 2^predict(modCalib, newdata=., level=1), CalCent=log2(Cal)-mean(log2(Cal)), genotype=relevel(factor(genotype), ref="mutM")) #create model mod4b <- lme(log2(mutation_rate)~CalCent+genotype, data=d4b, random=~1|block/plate_ID, weights=varPower(form=~SD_m|genotype)) #use model to create values for the lines in the figure d4b$pred <- predict(mod4b,level=0) #create the figure p4b <- ggplot(aes(x = Cal,y = mutation_rate, colour = genotype, shape = marker), data=d4b) pdf("Fig4b.pdf",width=4, height=4.4) p4b + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), limits=c(5,95), breaks=c(6,30,90)) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(8e7, 1.5e8, 3e8))) + scale_color_manual(values=c("#251DCC","#6BD693"),guide=FALSE) + geom_line(aes(group=genotype, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4, shape=17) + theme_classic(base_size = 14) + theme(axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14) ) graphics.off() #Fig. 4C; first create Model S-XII # read in the data and create necessary columns d4c <-read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "4c") %>% mutate(l2Dcent=log2(D)-mean(log2(D)), gen2=(factor(genotype))) #create model mod4c <- lme(log2(mutation_rate)~1, data=d4c, random=~1|block/plate_ID, weights=varComb(varPower(form = ~fitted(.)), varPower(form = ~upper_bound))) # use model to create values for the lines in the figure d4c$pred <- predict(mod4c,level=0) #create the figure p4c <- ggplot(aes(x = D,y = mutation_rate, colour = genotype, shape = included), data=d4c) pdf("Fig4c.pdf",width=4, height=4.4) p4c + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), breaks=c(500,3000, 12000)) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(1e6,1e7,1e8))) + scale_shape_manual(values=c(0,15), guide=FALSE) + scale_color_manual(values=c("#FF671B","#663300"),guide=FALSE) + geom_line(aes(y = 2^pred), lwd=1, colour="#FF671B", alpha=0.8) + geom_line(aes(y = 2^pred), lwd=1, colour="#663300", alpha=0.8, lty=2) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14) ) graphics.off() #Fig. 4D; first create Model S-XIV # read in the data and create necessary columns d4d <-read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "4d") %>% mutate(l2Dcent=log2(D)-mean(log2(D))) #create model mod4d <- lme(log2(mutation_rate)~l2Dcent, data=d4d, random=~1|block/plate_ID, weights=varComb(varPower(form = ~fitted(.)), varPower(form = ~lower_bound))) # use model to create values for the lines in the figure d4d$pred <- predict(mod4d,level=0) #create the figure p4d <- ggplot(aes(x = D,y = mutation_rate, colour = genotype, shape = marker), data=d4d) pdf("Fig4d.pdf",width=4, height=4.4) p4d + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), breaks=c(2,10,30)) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(1.5e8,2.5e8,4e8))) + scale_color_manual(values=c("#F2625A"),guide=FALSE) + geom_line(aes(group=genotype, y = 2^d4d$pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4, shape=18) + theme_classic(base_size = 14) + theme(axis.line.x= element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14)) graphics.off() #### S1 Fig; # read in the data dS1 <- read.tree(text = "(((((((((((Escherichia_coli:0.02123,(Salmonella_enterica_Typhimurium:0.02012,Salmonella_enterica_Enteritidis:0.00491)Node11:0.00492)Node10:0.08652,Yersinia_pestis:0.05702)Node9:0.00494,Haemophilus_influenzae:0.17514)Node8:0.19559,(Pseudomonas_fluorescens:0.06599,Pseudomonas_aeruginosa:0.05154)Node12:0.11363)Node7:0.09275,(Brucella_melitensis:0,Brucella_abortus:0)Node13:0.23462)Node6:0.02723,Helicobacter_pylori:0.34978)Node5:0.02114,(Deinococcus_radiodurans:0.23191,Thermus_thermophilus:0.1286)Node14:0.08484)Node4:0.01698,((Mycobacterium_tuberculosis:0.07389,Mycobacterium_smegmatis:0.0134)Node16:0.05793,Corynebacterium_glutamicum:0.0972)Node15:0.23763)Node3:0.00799,((Mycoplasma_mycoides:0.28176,Staphylococcus_aureus:0.08621)Node18:0.03732,Bacillus_anthracis:0.05643)Node17:0.16158)Node2:0.19854,(((Haloferax_volcanii:0.11902,Halobacterium_salinarum:0.08265)Node20:0.28483,Sulfolobus_acidocaldarius:0.21144)Node19:0.04196646,Saccharomyces_cerevisiae:0.5992681)NA:0.10979354)Node1:0.8312,(Mononegavirales:0.0069621,Bacteriophage_phi:0.0069621)NA:0,Bacteriophage_Q_beta:0.0069621)NA:0.1688;") dS1$tip.label = gsub("_", " ", dS1$tip.label) dS1$tip.label[c(24,25)] <- c(expression(paste("Bacteriophage ", phi, "X174")), expression(paste("Bacteriophage Q", beta))) pdf("S1_Fig.pdf",width=7, height=7) plot(dS1) graphics.off() #### S3 Fig; first create Model S-IV # read in the data and create necessary composite columns dS3 <- read.csv(file = "S1_Data.csv", header = TRUE) %>% filter(organism %in% c("Escherichia coli", "Pseudomonas aeruginosa"), !is.na(LUM)) #create the model modCalib <- lme(log2(D)~I(log2(LUM)-21.816664392518216)*organism, data=dS3, random=list(~I(log2(LUM)-21.816664392518216)|genotype, ~1|block, ~1|plate_ID), weights=varComb(varIdent(form=~1|block), varPower(form=~fitted(.)))) #use model to create values for the lines in the figure dS3$pred <- predict(modCalib,level=1) #create the figure pS3 <- ggplot(aes(x = LUM,y = D, colour = genotype, shape = strain), data=dS3) pdf("S3_Fig.pdf",width=11, height=7) pS3 + scale_y_log10(expression(paste("Population density (CFU)")), (breaks=c(3e7,1e8,3e8,6e8))) + scale_x_log10(expression(paste("Luminescence (AU)")), (breaks=c(1.12e6,3.2e6,1.01e7))) + scale_color_manual(values=c("#691F01","#B13E0F", "#FF9955","#FFFF00","#ffff99","#A0A000","#BED661","#65D74D", "#105952","#4997D0","#00468C","#002147","#d49dff","purple", "#4B0082")) + geom_line(aes(group=genotype, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14) ) graphics.off() #### S4A Fig; first create Model S-V # read in the data and create necessary composite columns dS4a <-read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "2a") %>% mutate(l2Dcent=log2(D)-mean(log2(D)), genotype_marker=factor(paste(genotype, marker, sep = '_')), genotype_marker=relevel(genotype_marker, ref="PAO1_rifampicin50"), sep_2a=factor(paste(included, marker, sep = '_')), gen2=(factor(genotype_marker))) levels(dS4a$gen2) <- c("PAO1","MG1655","MG1655") #create the model modS4a <- lme(log2(mutation_rate)~l2Dcent + genotype_marker + l2Dcent:gen2, data=dS4a, random=~1|researcher/block/plate_ID, weights=varComb(varPower(form=~m), varPower(form=~C_cultures))) #use model to create values for the lines in the figure dS4a$pred <- predict(modS4a,level=0) #create the figure pS4a <- ggplot(aes(x = D,y = mutation_rate, colour = organism, shape = sep_2a), data=dS4a) pdf("S4A_Fig.pdf",width=4, height=4.4) pS4a + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), (breaks=c(0.3,2,20))) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(4e7, 2e8, 6e8))) + scale_shape_manual(values=c(2,19,17), guide=FALSE) + scale_color_manual(values=c("#000A44","#35A2AD"),guide=FALSE) + geom_line(aes(group=genotype_marker, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x= element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14)) graphics.off() #### S4B Fig; first create Model S-VI # read in the data and create necessary composite columns dS4b <- read.csv("S1_Data.csv") %>% filter(figure %in% c("2b"), !is.na(D)) %>% mutate(l2Dcent=log2(D)-mean(log2(D)), genotype=factor(genotype), genotype=relevel(factor(genotype), ref="BY4742"), sep_2b=factor(paste(included, marker, sep = '_')), gen2=(factor(genotype))) levels(dS4b$gen2) <- c("BY4742","S288_&_Sigma1278b","S288_&_Sigma1278b") #create the model modS4b <- lme(log2(mutation_rate)~l2Dcent + genotype + gen2:l2Dcent, data=dS4b, random=~1|block/plate_ID, weights=varPower(form=~generation_time*culture_volume)) #use model to create values for the lines in the figure dS4b$pred <- predict(modS4b,level=0) #create the figure pS4b2 <- ggplot(aes(x = D, y = mutation_rate, colour = genotype, shape = sep_2b, fill=genotype), data=dS4b) pdf("S4B_Fig.pdf",width=4, height=4.4) pS4b2 + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), (breaks=c(10, 100, 1000, 5000))) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(1e6, 1e7, 1e8))) + scale_shape_manual(values=c(5,0,23,22), guide=FALSE) + scale_color_manual(values=c("#660000","#FF0000","#FF9933"), guide=FALSE) + scale_fill_manual(values=c("#660000","#FF0000","#FF9933"), guide=FALSE) + geom_line(aes(group=genotype, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x = element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14) ) graphics.off() #### S6 Fig; # read in the data and create necessary composite columns dS6 <- read.csv(file = "S1_Data.csv", header = TRUE) %>% filter(figure %in% c("S6")) #create the model modS6 <- gls(W~glucose_mg_per_L*genotype, data=dS6) #use model to create values for the lines in the figure dS6$pred <- predict(modS6,level=0) #create the figure pS6 <- ggplot(aes(x = factor(glucose_mg_per_L) ,y = W, colour = environment, shape=genotype), data=dS6) pdf("S6_Fig.pdf",width=4, height=4.4) pS6 + scale_y_continuous(expression(paste("fitness")), (breaks=c(0.85,0.9,0.95,1))) + scale_x_discrete(expression(paste("glucose (mg per L)"))) + scale_color_manual(values=c("#d49dff","#4B0082")) + scale_shape_manual(values=c(17,19)) + geom_boxplot(outlier.shape = NA) + facet_grid(~genotype) + geom_point(alpha=0.6, size=2) + theme(legend.position="none", panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_rect(fill = "white"), panel.border = element_blank(),axis.line.x = element_line(color = 'black', size=1), axis.line.y = element_line(color = 'black', size=1), axis.title.x = element_text(face="bold", size=14), axis.title.y = element_text(face="bold", size=14), axis.ticks=element_line(color = 'black', size=2), axis.text.x=element_text(color = 'black', size=14), axis.text.y=element_text(color = 'black', size=14) ) graphics.off() #### S8A Fig; first create Model S-IX # read in the data and create necessary composite columns dS8a <- read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "4a") %>% mutate(DCent=log2(D)-mean(log2(D))) #create the model modS8a <- lme(log2(mutation_rate)~1 + genotype, data=dS8a, random=~1|block/plate_ID, weights=varComb(varPower(form = ~fitted(.)), varPower(form = ~lower_bound))) #use model to create values for the lines in the figure dS8a$pred <- predict(modS8a,level=0) #create the figure pS8a <- ggplot(aes(x = D,y = mutation_rate, colour = genotype, shape = marker), data=dS8a) pdf("S8A_Fig.pdf",width=4, height=4.4) pS8a + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), limits=c(5,95), breaks=c(6,30,90)) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(7e7,2e8,6e8))) + scale_shape_manual(values=c(19,19), guide=FALSE) + scale_color_manual(values=c("#246C7F","#4DCDFF"),guide=FALSE) + geom_line(aes(group=genotype, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x= element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14)) graphics.off() #### S8B Fig; first create Model S-XI # read in the data and create necessary composite columns dS8b <- read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "4b") %>% mutate(DCent=log2(D)-mean(log2(D))) #create the model modS8b <- lme(log2(mutation_rate)~DCent*genotype, data=dS8b, random=~1|block/plate_ID, weights=varComb(varPower(form = ~fitted(.)), varPower(form = ~upper_bound))) #use model to create values for the lines in the figure dS8b$pred <- predict(modS8b,level=0) #create the figure pS8b <- ggplot(aes(x = D,y = mutation_rate, colour = genotype, shape = marker), data=dS8b) pdf("S8B_Fig.pdf",width=4, height=4.4) pS8b + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), limits=c(5,95), breaks=c(6,30,90)) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(8e7,1.5e8,3e8))) + scale_shape_manual(values=c(17,17), guide=FALSE) + scale_color_manual(values=c("#251DCC","#6BD693"),guide=FALSE) + geom_line(aes(group=genotype, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(plot.margin=unit(c(5.5, 15, 5.5, 5.5),"points")) + theme(axis.line.x= element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14)) graphics.off() #### S8C Fig; first create Model S-XIII # read in the data and create necessary composite columns dS8c <-read.csv(file = "S1_Data.csv", header = TRUE) %>% subset(figure == "4c") %>% mutate(CCent=log2(CC)-mean(log2(CC))) #create the model modS8c <- lme(log2(mutation_rate)~1, data=dS8c, random=~1|block/plate_ID, weights=varComb(varPower(form = ~fitted(.)), varPower(form = ~upper_bound))) #use model to create values for the lines in the figure dS8c$pred <- predict(modS8c,level=0) #create the figure pS8c <- ggplot(aes(x = CC,y = mutation_rate, colour = genotype, shape = included), data=dS8c) pdf("S8C_Fig.pdf",width=4, height=4.4) pS8c + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), breaks=c(500,3000, 12000)) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(2e6,1e7,1e8))) + scale_shape_manual(values=c(0,15), guide=FALSE) + scale_color_manual(values=c("#FF671B","#663300"),guide=FALSE) + geom_line(aes(y = 2^pred), lwd=1, colour="#FF671B", alpha=0.8) + geom_line(aes(y = 2^pred), lwd=1, colour="#663300", alpha=0.8, lty=2) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x= element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14)) graphics.off() #### S8D Fig; first create Model S-XV # read in the data and create necessary composite columns dS8d <-read.csv(file = "S1_Data.csv", header = TRUE) %>% filter(figure %in% c("4d")) %>% subset(block == "BB72") %>% mutate(CCent=log2(CC)-mean(log2(CC))) #create the model modS8d <- lme(log2(mutation_rate)~CCent, data=dS8d, random=~1|block/plate_ID, weights=varPower(form=~SD_Nt*fitted(.))) #use model to create values for the lines in the figure dS8d$pred <- predict(modS8d,level=0) #create the figure pS8d <- ggplot(aes(x = CC,y = mutation_rate, colour = genotype, shape = marker), data=dS8d) pdf("S8D_Fig.pdf",width=4, height=4.4) pS8d + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), breaks=c(4,8,12)) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(7e7,1e8,2e8))) + scale_shape_manual(values=c(18), guide=FALSE) + scale_color_manual(values=c("#F2625A"),guide=FALSE) + geom_line(aes(group=genotype, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x= element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14)) graphics.off() #### S9 Fig; first create Model S-XVI # read in the data and create necessary composite columns dS9 <- read.csv(file = "S1_Data.csv", header = TRUE) %>% filter(!is.na(Ne)) %>% mutate(genotype_marker=factor(paste(genotype, marker, sep = '_'))) dS9$DAMP <- factor(dS9$genotype) levels(dS9$DAMP) <- list("non-plastic" = c("mutT1","mutT2", "PAO1", "PCD1_by", "PCD1_sigma"), "slightly" = c("BY4742", "mutH", "mutL", "mutS", "Sigma_1278b"), "plastic" = c("dam", "dinB", "MG1655", "MLH1_sigma", "mutM", "mutY", "S288C", "nei", "metI")) #create the model modS9 <- lme(log2(mutation_rate) ~ log2(Ne)*genotype_marker, data=dS9, random=~1|block/plate_ID, weights=varComb(varIdent(form = ~1 | genotype), varPower(form = ~D))) #use model to create values for the lines in the figure dS9$pred <- predict(modS9,level=0) #create the figure pS9 <- ggplot(aes(x = Ne,y = mutation_rate, colour = genotype, shape = marker), data=dS9) pdf("S9_Fig.pdf",width=13, height=7) pS9 + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), breaks=c(0.5, 50, 500, 1000)) + scale_x_log10(expression(paste("Effective population size (Ne)")), (breaks=c(3e3, 3e4, 3e5))) + facet_grid(~DAMP) + geom_line(aes(group=genotype_marker, y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=3) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_rect(fill = "white"), panel.border = element_blank(),axis.line.x = element_line(color = 'black', size=1), axis.line.y = element_line(color = 'black', size=1), axis.title.x = element_text(face="bold", size=14), axis.title.y = element_text(face="bold", size=14), axis.ticks=element_line(color = 'black', size=2), axis.text.x=element_text(color = 'black', size=14), axis.text.y=element_text(color = 'black', size=14) ) graphics.off() #### S10 Fig; first create Model S-XVII # read in the data and create necessary composite columns dS10 <- read.csv(file = "S1_Data.csv", header = TRUE) %>% mutate(m_per_Vt2 = m/(culture_volume*generations), genotype_marker=factor(paste(genotype, marker, sep = '_'))) %>% filter(!is.na(m_per_Vt2)) dS10$DAMP <- factor(dS10$genotype) levels(dS10$DAMP) <- list("non-plastic" = c("mutT1","mutT2", "PAO1", "PCD1_by", "PCD1_sigma"), "slightly" = c("BY4742", "mutH", "mutL", "mutS", "Sigma_1278b"), "plastic" = c("dam", "dinB", "MG1655", "MLH1_sigma", "mutM", "mutY", "S288C", "nei", "metI")) #create the model modS10 <- lme(log2(m_per_Vt2)~log2(Nt)*genotype_marker, data=dS10, random=~1|block/plate_ID, weights=varPower(form=~SD_m|marker), control=lmeControl(maxIter=500)) #use model to create values for the lines in the figure dS10$pred <- predict(modS10,level=0) #create the figure pS10 <- ggplot(aes(x = Nt,y = m_per_Vt2, colour = genotype, shape = marker), data=dS10) pdf("S10_Fig.pdf",width=13, height=7) pS10 + scale_y_log10(expression(paste("Mutational events per ml per division time")), breaks=c(0.01, 0.5, 50)) + scale_x_log10(expression(paste("Population size (Nt)")), (breaks=c(3e5, 3e7, 3e9))) + facet_grid(~DAMP) + geom_line(aes(y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=3) + geom_line(colour ="black",lty=2, data=data.frame(Nt=c(3e5,3e9), m_per_Vt2=c(0.005, 50), genotype=c("dam", "dam"), marker=c("rifampicin50", "rifampicin50"))) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_rect(fill = "white"), panel.border = element_blank(),axis.line.x = element_line(color = 'black', size=1), axis.line.y = element_line(color = 'black', size=1), axis.title.x = element_text(face="bold", size=14), axis.title.y = element_text(face="bold", size=14), axis.ticks=element_line(color = 'black', size=2), axis.text.x=element_text(color = 'black', size=14), axis.text.y=element_text(color = 'black', size=14) ) graphics.off() #### S11 Fig; first create Model S-XVIII # read in the data and create necessary composite columns dS11<-read.csv(file = "S1_Data.csv", header = TRUE) %>% filter(figure %in% c("S11")) %>% mutate(DCent=log2(D)-mean(log2(D))) #create the model modS11 <- gls(log2(mutation_rate)~DCent + host + environment, data=dS11) #use model to create values for the lines in the figure dS11$pred <- predict(modS11,level=0) #create the figure pS11 <- ggplot(aes(x = D,y = mutation_rate, colour = host, shape = environment), data=dS11) pdf("S11_Fig.pdf",width=11, height=7) pS11 + scale_y_log10(expression(paste("Mutation rate (10"^-9, "generation"^-1,")")), (breaks=c(3000,15000,40000))) + scale_x_log10(expression(paste("Population density (ml"^-1,")")), (breaks=c(8e4, 3e5, 8e5))) + geom_line(aes(y = 2^pred), alpha=0.8, lwd=1) + geom_point(alpha=0.8, size=4) + theme_classic(base_size = 14) + theme(axis.line.x= element_line(size=1), axis.line.y = element_line(size=1), axis.ticks=element_line(size=2), axis.text.x=element_text(size=14), axis.text.y=element_text(size=14)) graphics.off()