#Well save the header and export data
output <- paste("Indexed/",ID,".csv", sep="")
output2 <- paste("Read_counts/",ID,".csv", sep="")
output3 <- paste("Plots/",ID,".pdf", sep="")
header <- colnames(myData5)
write.table(header, "Indexed/1_header.tmp", sep=",",  col.names=FALSE, row.names =FALSE)
write.table(myData5, output, sep=",",  col.names=FALSE, row.names =FALSE)
write.table(Read_counts, output2, sep=",",  col.names=FALSE, row.names =FALSE)
#Append data to dataframe All_reads
All_reads <- rbind(All_reads, myData5)
#Okey lets also make some plots
Titel <- unique(myData5$Sample)
Fig1 <- ggplot(myData5, stats = "identity", aes(Strain, fill = allel)) +
geom_col(data=myData5, aes(Strain, Relative_abundance)) +
geom_hline(yintercept = 0.017) +
background_grid(major = "none", minor = "none") + # add thin horizontal lines
#theme_classic() +
panel_border(colour = "black", size = 1) + # and a border around each panel
labs (title = Titel) +
#coord_cartesian(ylim=c(0.0001, 0.01), expand = F) + #ylim=c(-0, 12.5)
#scale_y_discrete(limits=c(0.0001,0.001,0.01,0.1,1)) +
#scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
#labels = trans_format("log10", math_format(10^.x))) +
#coord_flip() +
theme(plot.title = element_text(vjust = -5, hjust = 0.1)) +
theme(panel.spacing = unit(0.1, "lines")) +
theme(legend.title=element_blank()) +
theme(legend.text=element_text(size=10)) +
theme(text=(element_text(size=10))) +
theme(axis.text=(element_text(size=5))) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
theme(panel.background = element_blank()) +
theme(legend.key = element_blank()) +
theme(legend.text = element_text(face = "italic")) +
theme(aspect.ratio=0.25) +
#stat_cor(aes(color = scientific_name), label.x = 3)
theme(plot.margin=unit(c(0,1,0,0.2),"cm")) +
theme(legend.position ="top",
#legend.justification = c("right", "top"),
#legend.box.just = "right",
#scale_fill_manual(breaks=c(3)),
legend.margin = margin(2, 2, 2, 2),
#guides(color = FALSE), #,color = FALSE, size = FALSE,
legend.box.background = element_rect(fill='white'),
legend.background = element_blank(),
legend.key = element_rect(fill = NA, color = NA),
legend.spacing.x=unit(0, "cm"),
legend.spacing.y=unit(0, "cm"))
#print(Fig1)
#dev.copy(pdf, output3)
#dev.off()
}
header <- read.csv("Indexed/1_header.tmp", header = F)
header <- t(header)
colnames(All_reads) <- (header)
write.table(All_reads, "Indexed/All_reads.csv", sep=",",  col.names=TRUE, row.names =FALSE)
#Count the occurrences of the wrong strain in the wrong population (False positives)
VGs <- subset.data.frame(All_reads, grepl('VG', All_reads$Strain))
VGs <- subset.data.frame(VGs, grepl('GP', VGs$Experiment))
VG_FP<- length(VGs$Population[VGs$Total_C > 0])
GPs <- subset.data.frame(All_reads, grepl('GP', All_reads$Strain))
GPs <- subset.data.frame(GPs, grepl('VG', GPs$Experiment))
GP_FP<- length(GPs$Population[GPs$Total_C > 0])
#The number of indisputable false positives is
VG_FP+GP_FP
VGs <- subset.data.frame(All_reads, grepl('VG', All_reads$Strain))
VGs <- subset.data.frame(VGs, grepl('GP', VGs$Experiment))
VG_FP<- length(VGs$Population[VGs$Total_C > 0])
GPs <- subset.data.frame(All_reads, grepl('GP', All_reads$Strain))
GPs <- subset.data.frame(GPs, grepl('VG', GPs$Experiment))
GP_FP<- length(GPs$Population[GPs$Total_C > 0])
#The number of indisputable false positives is
VG_FP+GP_FP
#Out of
TO <- length(All_reads$Population[All_reads$Total_C > 0])
TO
#FDR is reduced four fold and now at 5.9% of strains observations
#and as seen above it is mainly very low abundance observations that are affected by FP
((VG_FP+GP_FP)*2)/TO
#Houskeeping the loading packages####
#Lets clear old objects
rm(list=ls())
getwd()
#and set the work directory in case we have moved around or opened another project
setwd("~/Users/xanbjg/Documents/R/Cu_evolution/StrainPhenotyping")
dir()
#Script requires sub-directories named Input, Plots, and Results, below the work directory
# loadi
# loading packages
#packages & functions
library(drc)
library(reshape2)
library(multtest)
library(lattice)
library(devtools)
library(ggbiplot)
library(plyr)
library(scales)
library(ggplot2)
library(devtools)
library(grid)
library(tidyverse)
library(lubridate) # useful for working with dates
library(cowplot) # useul for combining multiple plots
library(ggthemes)
library(broom)
library(ggpubr)
library(gridExtra)
#library(ggpmisc)
library(gplots)
#library(staplr)
library(staplr)
library(dplyr)
# loading packages
#packages & functions
library(drc)
library(reshape2)
library(multtest)
library(lattice)
library(devtools)
library(ggbiplot)
library(plyr)
library(scales)
library(ggplot2)
library(devtools)
library(grid)
library(tidyverse)
library(lubridate) # useful for working with dates
library(cowplot) # useul for combining multiple plots
library(ggthemes)
library(broom)
library(ggpubr)
library(gridExtra)
#library(ggpmisc)
library(gplots)
#library(staplr)
library(staplr)
library(dplyr)
#first create individual .csv files based on .csv containing data of all strains
GP_Cunorm <- read.csv2("Input/GP_lowCu_norm.csv")
VG_Cunorm <- read.csv2("Input/VG_lowCu_norm.csv")#, header=FALSE
All <- rbind(GP_Cunorm, VG_Cunorm)
sapply(All, class)
All$Concentration <- as.numeric(as.character(All$Concentration))
All$Growth_rate_.day.1. <- as.numeric(as.character(All$Growth_rate_.day.1.))
All$Inhibition <- as.numeric(as.character(All$Inhibition))
#and set the work directory in case we have moved around or opened another project
setwd("~/Users/xanbjg/Documents/R/Cu_evolution/StrainPhenotyping")
setwd("~/Documents/R/Cu_evolution/StrainPhenotyping")
#first create individual .csv files based on .csv containing data of all strains
GP_Cunorm <- read.csv2("Input/GP_lowCu_norm.csv")
VG_Cunorm <- read.csv2("Input/VG_lowCu_norm.csv")#, header=FALSE
All <- rbind(GP_Cunorm, VG_Cunorm)
sapply(All, class)
All$Concentration <- as.numeric(as.character(All$Concentration))
All$Growth_rate_.day.1. <- as.numeric(as.character(All$Growth_rate_.day.1.))
All$Inhibition <- as.numeric(as.character(All$Inhibition))
#first create individual .csv files based on .csv containing data of all strains
GP_Cunorm <- read.csv2("Input/GP_lowCu_norm.csv")
VG_Cunorm <- read.csv2("Input/VG_lowCu_norm.csv")#, header=FALSE
All <- rbind(GP_Cunorm, VG_Cunorm)
GP_Cunorm <- read.csv2("Input/GP_lowCu_norm.csv")
VG_Cunorm <- read.csv2("Input/VG_lowCu_norm.csv")#, header=FALSE
All <- rbind(GP_Cunorm, VG_Cunorm)
sapply(All, class)
All$Concentration <- as.numeric(as.character(All$Concentration))
All$Growth_rate_.day.1. <- as.numeric(as.character(All$Growth_rate_.day.1.))
All$Inhibition <- as.numeric(as.character(All$Inhibition))
View(All)
All$Growth_rate_.day..1. <- as.numeric(as.character(All$Growth_rate_.day.1.))
All$Growth_rate_.day..1. <- as.numeric(as.character(All$Growth_rate_.day..1.))
GP_Cunorm <- read.csv2("Input/GP_lowCu_norm.csv")
VG_Cunorm <- read.csv2("Input/VG_lowCu_norm.csv")#, header=FALSE
All <- rbind(GP_Cunorm, VG_Cunorm)
sapply(All, class)
All$Concentration <- as.numeric(as.character(All$Concentration))
All$Growth_rate_.day..1. <- as.numeric(as.character(All$Growth_rate_.day..1.))
All$Inhibition <- as.numeric(as.character(All$Inhibition))
GP_Cunorm <- read.csv2("Input/GP_lowCu_norm.csv")
VG_Cunorm <- read.csv2("Input/VG_lowCu_norm.csv")#, header=FALSE
All <- rbind(GP_Cunorm, VG_Cunorm)
sapply(All, class)
All$Concentration <- as.numeric(as.character(All$Concentration))
All$Growth_rate <- as.numeric(as.character(All$Growth_rate))
All$Inhibition <- as.numeric(as.character(All$Inhibition))
#Transform Concentration from numerical to absolute Cu concentration based on ISP-MS measurments
plot(All$Concentration)
All$Concentration <- (ifelse(All$Concentration > 0, All$Concentration*0.7034-0.1421, All$Concentration))
plot(All$Concentration)
#i want to do the analysis seperate for the two pop. so that RO5 is included separately
GP <- subset.data.frame(All, grepl("GP", All$Local))
GPstrain<- unique(GP$strain)
VG <- subset.data.frame(All, grepl("VG", All$Local))
VGstrain<- unique(VG$strain)
#Lets make an Dataframe to save all ratios in
DRCs <- data.frame(Strain=character(),
Predict=numeric(),
Predict_low=numeric(),
Predict_high=numeric(),
EC05=numeric(),
EC05_SE=numeric(),
EC05_Low=numeric(),
EC05_high=numeric(),
EC50=numeric(),
EC50_SE=numeric(),
EC50_Low=numeric(),
EC50_high=numeric(),
EC95=numeric(),
EC95_SE=numeric(),
EC95_Low=numeric(),
EC95_high=numeric(),
stringsAsFactors=FALSE)
Header <- colnames(DRCs)
#i <- "GP2-4_26"
for (i in GPstrain) {
#Subset strain data
myData <- subset.data.frame(GP, grepl(paste("\\b",i,"\\b", sep = ""), GP$strain))
Strain <- i
#drm = dose-response model for error plots (change model as needed)
fitData= subset(myData, myData$Concentration >=0)
bestDoseresponse.WB = drm(Inhibition~Concentration, data = fitData, fct = W2.2())
bestDoseresponse.WB #give you the intercepts
a = coef(bestDoseresponse.WB)[1]
b = coef(bestDoseresponse.WB)[2]
#predict response at specific concentration dose(x) with 95% confidence
Response= PR(bestDoseresponse.WB, c(8.6504))
Response= predict(bestDoseresponse.WB, data.frame(dose=8.6504, CURVE= "1"), interval = "confidence")
#Response= PR(bestDoseresponse.WB, c(8.6504))
Response2 = t(Response)
#Compute EC values
EC05=ED(bestDoseresponse.WB, respLev = 0.05, type="absolute", interval="tfls") #to get ED help file put ? in front of ED and run.
EC50=ED(bestDoseresponse.WB, respLev = 0.5, type="absolute", interval="tfls")
EC95=ED(bestDoseresponse.WB, respLev = 0.95, type="absolute", interval="tfls")
#Add to DRCs dataframe
myData2 <- cbind(Strain, Response2, EC05, EC50, EC95)
rownames(myData2) <- NULL
colnames(myData2) <- NULL
DRCs <- rbind(DRCs, myData2)
#Lets also make a plot of data, using RO5 as a Reference point
myData3 = subset.data.frame(GP, grepl("RO5", GP$strain))
#drm = dose-response model for error plots (change model as needed)
fitData3= subset(myData3, myData3$Concentration >=0)
bestDoseresponse_RO5.WB = drm(Inhibition~Concentration, data = fitData3, fct = W2.2())
myData4=merge(myData,myData3, all= TRUE)
#Make joint analysis for plot
myData4=merge(myData,myData3, all= TRUE)
fitData= subset(myData4, myData4$Concentration >=0)
multi.m1 <- drm(Inhibition~Concentration, data = fitData, strain, fct = W2.2())
#generate RGB code for Strain
rgb(0, 128, 0, maxColorValue=255)
#generate RGB code for RO5
rgb(40, 70, 255, maxColorValue=255)
#This is where the plots ends up
output <- paste("Plots/",i,".pdf", sep="")
#This is a stupid way of plotting but DRC output files are not working well
dev.off()
dev.new(width=2.5, height=2.5)
par(mar=c(7,7,5,5))
plot(multi.m1,
type = "all",
col=c("gray14", "#008000"),
broken = TRUE, bp = 3,   #this controls where the axis is cut
bcontrol = list(factor = 1.2), #= "defult", style = "gap", width = "0.02"), #this controls how the cut is made (distance form origo)
conName = "Control",
cex =  2, cex.axis=2, lty=c(1, 2), lwd=1, #size of: symbols, axis numbers, lines type, line thickness,  stuff
xlim = c(0,13), #Changes,  must be the same in the row below
ylim =c(-0.2,1.2),
xt = c(0, 4, 5, 7, 9, 12), #Specify x numbers
yt = c(-0.2, 0.2, 0.6, 1), #Specify y number
xlab = expression("Cu concentration (" *mu ~ "M)"), line = 5, cex.lab =2,
ylab = "Inhibition of growth rate",
legend = FALSE)
legend(3, 1.45, title="",
c(Strain,"RO5"), col=c("gray14", "#008000"), lty=1:2, cex=1.75, lwd=1, pch=c(1,2), box.lty=0, x.intersp=0.25, y.intersp=0.3,
bg=NULL, seg.len=1)
#legend = TRUE, legendPos = c(15, 1.4), legendText=c(Strain, "RO5"), cex.legend = 1.5, lwd.legend = 0.25, text.width = 1) #text.width=c(0.25,0.25,0.25),
#legend = FALSE, legendPos = c(1.75, 1), legendText=c("1.5h", "3h", "5h"), cex.legend = 2, lwd.legend = 2,
#main = title(main = "T0", adj = 0.05, line = -2.5, cex.main = 2))
plot(bestDoseresponse_RO5.WB, col = "#008000", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
plot(bestDoseresponse.WB, col = "gray14", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
dev.copy(pdf, output)
dev.off()
}
#VG analysis
for (i in VGstrain) {
#Subset strain data
myData <- subset.data.frame(VG, grepl(paste("\\b",i,"\\b", sep = ""), VG$strain))
Strain <- i
#drm = dose-response model for error plots (change model as needed)
fitData= subset(myData, myData$Concentration >=0)
bestDoseresponse.WB = drm(Inhibition~Concentration, data = fitData, fct = W2.2())
bestDoseresponse.WB #give you the intercepts
a = coef(bestDoseresponse.WB)[1]
b = coef(bestDoseresponse.WB)[2]
#predict response at specific concentration dose(x) with 95% confidence
Response= PR(bestDoseresponse.WB, c(8.6504))
Response= predict(bestDoseresponse.WB, data.frame(dose=8.6504, CURVE= "1"), interval = "confidence")
#Response= PR(bestDoseresponse.WB, c(8.6504))
Response2 = t(Response)
#Compute EC values
EC05=ED(bestDoseresponse.WB, respLev = 0.05, type="absolute", interval="tfls") #to get ED help file put ? in front of ED and run.
EC50=ED(bestDoseresponse.WB, respLev = 0.5, type="absolute", interval="tfls")
EC95=ED(bestDoseresponse.WB, respLev = 0.95, type="absolute", interval="tfls")
#Add to DRCs dataframe
myData2 <- cbind(Strain, Response2, EC05, EC50, EC95)
rownames(myData2) <- NULL
colnames(myData2) <- NULL
DRCs <- rbind(DRCs, myData2)
#Lets also make a plot of data, using RO5 as a Reference point
myData3 = subset.data.frame(VG, grepl("RO5", VG$strain))
#drm = dose-response model for error plots (change model as needed)
fitData3= subset(myData3, myData3$Concentration >=0)
bestDoseresponse_RO5.WB = drm(Inhibition~Concentration, data = fitData3, fct = W2.2())
myData4=merge(myData,myData3, all= TRUE)
#Make joint analysis for plot
myData4=merge(myData,myData3, all= TRUE)
fitData= subset(myData4, myData4$Concentration >=0)
multi.m1 <- drm(Inhibition~Concentration, data = fitData, strain, fct = W2.2())
#generate RGB code for Strain
rgb(0, 128, 0, maxColorValue=255)
#generate RGB code for RO5
rgb(40, 70, 255, maxColorValue=255)
#This is where the plots ends up
output <- paste("Plots/",i,".pdf", sep="")
#This is a stupid way of plotting but DRC output files are not working well
dev.off()
dev.new(width=2.5, height=2.5)
par(mar=c(7,7,5,5))
plot(multi.m1,
type = "all",
col=c("#008000", "#B85633"),
broken = TRUE, bp = 3,   #this controls where the axis is cut
bcontrol = list(factor = 1.2), #= "defult", style = "gap", width = "0.02"), #this controls how the cut is made (distance form origo)
conName = "Control",
cex =  2, cex.axis=2, lty=c(2, 1), pch=c(2,1), lwd=1, #size of: symbols, axis numbers, lines type, line thickness,  stuff
xlim = c(0,13), #Changes,  must be the same in the row below
ylim =c(-0.2,1.2),
xt = c(0, 4, 5, 7, 9, 12), #Specify x numbers
yt = c(-0.2, 0.2, 0.6, 1), #Specify y number
xlab = expression("Cu concentration (" *mu ~ "M)"), line = 5, cex.lab =2,
ylab = "Inhibition of growth rate",
legend = FALSE)
legend(3, 1.45, title="",
c(Strain,"RO5"), col=c("#B85633", "#008000"), lty=1:2, cex=1.75, lwd=1, pch=c(1,2), box.lty=0, x.intersp=0.25, y.intersp=0.3,
bg=NULL, seg.len=1)
#legend = TRUE, legendPos = c(15, 1.4), legendText=c(Strain, "RO5"), cex.legend = 1.5, lwd.legend = 0.25, text.width = 1) #text.width=c(0.25,0.25,0.25),
#legend = FALSE, legendPos = c(1.75, 1), legendText=c("1.5h", "3h", "5h"), cex.legend = 2, lwd.legend = 2,
#main = title(main = "T0", adj = 0.05, line = -2.5, cex.main = 2))
plot(bestDoseresponse_RO5.WB, col = "#008000", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
plot(bestDoseresponse.WB, col = "#B85633", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
dev.copy(pdf, output)
dev.off()
}
colnames(DRCs) <- Header
DRCs2 <- DRCs
write.table(DRCs, file = "Results/ECvaluesStrains.txt", sep = '\t', col.names = TRUE)
#CAN START DOWNSTREAM ANALYSIS HERE
#DRCs2 <- read.table(file = "Results/ECvaluesStrains.txt", sep = '\t', header = TRUE)
DRCs2 <- DRCs2 %>% mutate_at(c(2:16), as.numeric)
sapply(DRCs2 , class)
StrainMeta <- read.delim("Strain_summary.txt", sep = '\t', header=TRUE)
DRC_Meta <- join(DRCs2, StrainMeta, by = "Strain", type = "right")
sapply(DRC_Meta , class)
#Lets make a DRC curve with the median, min and max tolerant strains per pop +RO5 for References
GP_EC <- subset.data.frame(DRC_Meta, grepl("GP", DRC_Meta$Population))
#GP_EC <- GP_EC[order(EC50),]
GP_EC[which.max(GP_EC$EC50),]
GP_EC[which.min(GP_EC$EC50),]
median(GP_EC$EC50)
DRCs2 <- DRCs2 %>% mutate_at(c(2:16), as.numeric)
sapply(DRCs2 , class)
#Graphs and modeling####
StrainMeta <- read.delim("Strain_summary.txt", sep = '\t', header=TRUE)
DRC_Meta <- join(DRCs2, StrainMeta, by = "Strain", type = "right")
sapply(DRC_Meta , class)
#Lets make a DRC curve with the median, min and max tolerant strains per pop +RO5 for References
GP_EC <- subset.data.frame(DRC_Meta, grepl("GP", DRC_Meta$Population))
#GP_EC <- GP_EC[order(EC50),]
GP_EC[which.max(GP_EC$EC50),]
GP_EC[which.min(GP_EC$EC50),]
median(GP_EC$EC50)
StrainMeta <- read.delim("Input/Strain_summary.txt", sep = '\t', header=TRUE)
DRC_Meta <- join(DRCs2, StrainMeta, by = "Strain", type = "right")
sapply(DRC_Meta , class)
#Lets make a DRC curve with the median, min and max tolerant strains per pop +RO5 for References
GP_EC <- subset.data.frame(DRC_Meta, grepl("GP", DRC_Meta$Population))
#GP_EC <- GP_EC[order(EC50),]
GP_EC[which.max(GP_EC$EC50),]
GP_EC[which.min(GP_EC$EC50),]
median(GP_EC$EC50)
#We have GP2-4_56, GP2-4_28, and the median is 7.827672= between GP2-4_51/GP2-4_69
GP_x4 <- subset.data.frame(GP, grepl(pattern = 'GP2-4_56|GP2-4_28|GP2-4_51|RO5', GP$strain))
GP_56 <- subset.data.frame(GP, grepl("GP2-4_56", GP$strain))
GP_28 <- subset.data.frame(GP, grepl("GP2-4_28", GP$strain))
GP_51 <- subset.data.frame(GP, grepl("GP2-4_51", GP$strain))
RO5_GP <- subset.data.frame(GP, grepl("RO5", GP$strain))
#fitData= subset(GP_x4, GP_x4$Concentration >=0)
multi.m1 <- drm(Inhibition~Concentration, data = GP_x4, strain, fct = W2.2())
GP_56.WB = drm(Inhibition~Concentration, data = GP_56, fct = W2.2())
GP_28.WB = drm(Inhibition~Concentration, data = GP_28, fct = W2.2())
GP_51.WB = drm(Inhibition~Concentration, data = GP_51, fct = W2.2())
RO5_GP.WB = drm(Inhibition~Concentration, data = RO5_GP, fct = W2.2())
dev.off()
dev.new(width=2.5, height=2.5)
par(mar=c(7,7,5,5))
plot(multi.m1,
type = "all",
col=c("gray14", "gray14", "gray14", "#008000"),
broken = TRUE, bp = 3,   #this controls where the axis is cut
bcontrol = list(factor = 1.2), #= "defult", style = "gap", width = "0.02"), #this controls how the cut is made (distance form origo)
conName = "Control",
cex =  2, cex.axis=2, lty=c(1, 1, 1, 2), pch=c(6, 1, 2, 4), lwd=2, #size of: symbols, axis numbers, lines type, line thickness,  stuff
xlim = c(0,13), #Changes,  must be the same in the row below
ylim =c(-0.2,1.2),
xt = c(0, 5, 6, 8, 10, 13), #Specify x numbers
yt = c(-0.2, 0.2, 0.6, 1), #Specify y number
xlab = expression("Cu concentration (" *mu ~ "M)"), line = 5, cex.lab =2,
ylab = "Inhibition of growth rate",
legend = FALSE)
box(lwd=2)
abline(v = median(GP_EC$EC50), col = "gray14", lwd = 2, lty = 1) #GPs median EC50
abline(v = 8.41, col = "#008000", lwd = 2, lty = 1) #RO5s EC50
legend(3, 1.2, title="", c("GP2-4_28","GP2-4_56", "GP2-4_61", "RO5AC"), col=c("gray14", "gray14", "gray14", "#008000"),
cex=1.75, lwd=2, pch=c(6, 1, 2, 4), box.lty=0, x.intersp=0.25, y.intersp=0.4,
bg=NULL, seg.len=1)
plot(GP_56.WB, col = "gray14", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
plot(GP_28.WB, col = "gray14", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
plot(GP_51.WB, col = "gray14", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
plot(RO5_GP.WB, col = "#008000", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
dev.copy(pdf, "Plots/Fig1A.pdf")
dev.off()
#Now for the VG strains
VG_EC <- subset.data.frame(DRC_Meta, grepl("VG", DRC_Meta$Population))
#VG_EC <- VG_EC[order(EC50),]
VG_EC[which.max(VG_EC$EC50),]
VG_EC[which.min(VG_EC$EC50),]
median(VG_EC$EC50)
#We have VG1-2_81, VG1-2_67, and the median is 7.954671= between VG1-2_88/VG1-2_86/
VG_x4 <- subset.data.frame(VG, grepl(pattern = 'VG1-2_81|VG1-2_67|VG1-2_86|RO5', VG$strain))
VG_81 <- subset.data.frame(VG, grepl("VG1-2_81", VG$strain))
VG_67 <- subset.data.frame(VG, grepl("VG1-2_67", VG$strain))
VG_86 <- subset.data.frame(VG, grepl("VG1-2_86", VG$strain))
RO5_VG <- subset.data.frame(VG, grepl("RO5", VG$strain))
#fitData= subset(VG_x4, VG_x4$Concentration >=0)
multi.m2 <- drm(Inhibition~Concentration, data = VG_x4, strain, fct = W2.2())
VG_81.WB = drm(Inhibition~Concentration, data = VG_81, fct = W2.2())
VG_67.WB = drm(Inhibition~Concentration, data = VG_67, fct = W2.2())
VG_86.WB = drm(Inhibition~Concentration, data = VG_86, fct = W2.2())
RO5_VG.WB = drm(Inhibition~Concentration, data = RO5_VG, fct = W2.2())
dev.off()
dev.new(width=2.5, height=2.5)
par(mar=c(7,7,5,5))
plot(multi.m2,
type = "all",
col=c("#B85633", "#B85633", "#B85633", "#008000"),
broken = TRUE, bp = 3,   #this controls where the axis is cut
bcontrol = list(factor = 1.2), #= "defult", style = "gap", width = "0.02"), #this controls how the cut is made (distance form origo)
conName = "Control",
cex =  2, cex.axis=2, lty=c(1, 1, 1, 2), pch=c(6, 2, 1, 4), lwd=2, #size of: symbols, axis numbers, lines type, line thickness,  stuff
xlim = c(0,13), #Changes,  must be the same in the row below
ylim =c(-0.2,1.2),
xt = c(0, 5, 6, 8, 10, 13), #Specify x numbers
yt = c(-0.2, 0.2, 0.6, 1), #Specify y number
xlab = expression("Cu concentration (" *mu ~ "M)"), line = 5, cex.lab =2,
ylab = "Inhibition of growth rate",
legend = FALSE)
box(lwd=2)
abline(v = median(VG_EC$EC50), col = "#B85633", lwd = 2, lty = 1)
abline(v = 8.33, col = "#008000", lwd = 2, lty = 1)
legend(3, 1.2, title="", c("VG1-2_67", "VG1-2_81", "VG1-2_86", "RO5AC"), col=c("#B85633", "#B85633", "#B85633", "#008000"),
cex=1.75, lwd=2, pch=c(6, 2, 1, 4), box.lty=0, x.intersp=0.25, y.intersp=0.4,
bg=NULL, seg.len=1)
plot(VG_81.WB, col = "#B85633", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
plot(VG_67.WB, col = "#B85633", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
plot(VG_86.WB, col = "#B85633", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
plot(RO5_VG.WB, col = "#008000", type = "confidence", xlim = c(5,13), lty=c(0), add = TRUE)
dev.copy(pdf, "Plots/Fig1C.pdf")
dev.off()
#Good, now i want a histogram of both populations
Fig1B <- ggplot(DRC_Meta, aes(x=EC50, fill=Population, color=Population)) +
geom_histogram(bins = 30, alpha=0.7, position="identity", color="black") + #aes(y = ..density..)
#geom_density(alpha=0.7) +
scale_color_manual(values=c("gray14", "#B85633"), labels = c("Reference inlet", "Mining inlet")) +
scale_fill_manual(values=c("gray14", "#B85633"), labels = c("Reference inlet", "Mining inlet")) +
#scale_color_manual(values=c("#999999", "#E69F00", "#56B4E9"))
coord_cartesian(xlim=c(6, 10.1), ylim=c(0,8), expand = F) + #ylim=c(-10000,+10000)
scale_x_discrete(limits=c(6,7,8,9,10)) +
labs(x=expression("EC50 (" *mu ~ "M Cu)"), y = "Number of strains", title = "A") +
background_grid(major = "none", minor = "none") + # add thin horizontal lines
panel_border(colour = "black", size = 2) + # and a border around each panel
theme(plot.title = element_text(vjust = - 8, hjust = 0.04)) +
theme(panel.spacing = unit(0.1, "lines")) +
theme(legend.title=element_blank()) +
theme(legend.text=element_text(size=30)) +
theme(text=(element_text(size=27))) +
theme(axis.text=(element_text(size=27, colour = "Black"))) +
#theme(axis.text=(element_text(colour = "Black"))) +
theme(panel.background = element_blank()) +
theme(legend.key = element_blank()) +
theme(legend.text = element_text(face = "italic")) +
theme(aspect.ratio=1) +
theme(legend.position = c(0.55, 0.9),
legend.margin = margin(10, 10, 10, 10),
legend.box.background = element_rect(fill='white'),
legend.box="horizontal",
legend.key = element_rect(fill = 'white', color = 'white'),
legend.background = element_blank(),
legend.spacing.x=unit(0, "cm"),
legend.spacing.y=unit(0, "cm"))
print(Fig1B)
dev.copy(pdf, "Plots/Fig1B.pdf")
dev.off()
