-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAcid_enumerate.R
51 lines (42 loc) · 1.87 KB
/
Acid_enumerate.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Script for plotting E. coli enumerations
#Created by Keiran Cantilina
# Based on a script by Allison Truhlar
# Clear workspace
rm(list=ls())
# Load libraries if just starting
library(reshape2)
library(plyr)
library(ggplot2)
# Set working directory
#Allison: "C:\\Users\\OWner\\Dropbox\\Cornell\\Ecoli_research\\Data\\"
#Keiran: "C://Users//Ross//Desktop//R_code//Ecoli_project//"
dir <- "C:\\Users\\OWner\\Dropbox\\Cornell\\Ecoli_research\\Data\\"
setwd(dir)
# Load enumeration data
# **Make sure spreadsheet is updated first!!!
enum_file <- "Acid Challenge Test\\Acid_enumeration_realz.csv"
all_enum_data <- read.csv(paste(dir,enum_file,sep=""))
enum_data <- na.omit(all_enum_data)
enum_data$Plate <- factor(enum_data$Plate)
# Summarise enumerations data by pot
enum.means.sem <- ddply(enum_data, c("Hour","Plate"), summarise, mean=mean(log_CFU_ml), sem=sd(log_CFU_ml)/sqrt(length(log_CFU_ml)))
enum.means.sem <- transform(enum.means.sem, lower=mean-sem, upper=mean+sem)
limits <- aes(ymax=enum.means.sem$upper, ymin=enum.means.sem$lower)
# Scatterplot
pd <- position_dodge(0.1)
enum_plot <- ggplot(enum.means.sem, aes(x=Hour,y=mean, colour=Plate, shape=Plate, group=Plate))+
geom_errorbar(limits, width = 0, colour="black",position=pd)+
geom_line(colour="black",position=pd)+
geom_point(size=4,position=pd)+
scale_shape_manual(values=c(15,15,17,17,19,19))+
scale_color_manual(values=c("#1f78b4","#a6cee3","#33a02c","#b2df8a","#e31a1c","#fb9a99"))+
scale_x_continuous(breaks=c(0,2,6))+
ylab("log(cfu/ml)")+
xlab("Hour")+
theme_bw()+
theme(axis.text=element_text(size=18), axis.title.x=element_text(size=18,face="bold",vjust=-0.4),
axis.title.y=element_text(size=18,vjust=1.2), legend.text=element_text(size=14),
legend.title=element_text(size=14,face="bold"))
enum_plot
graph_file <- paste(dir,"//Acid_enumerations.png",sep="")
ggsave(file=graph_file, plot=enum_plot)