# Get all libraries and sources required to run the script
library(dplyr)
library(plyr)
library(reshape2)
library(ggplot2)
library(ggthemes)
theme_set (theme_classic() + theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"),
legend.position="none",
axis.text.x = element_text(angle = 90, vjust = 0.5),
plot.title = element_text(size=12, face="bold"),
#panel.border = element_rect(colour = "black", fill=NA, size=1)
panel.border = element_blank()
))
# 1. Import data:
# Long format Ssid YII
YII.Tall<-read.csv("Data/YII_tall.csv")
# Wide format
# YII.wide<- YII.Tall<-readRDS("Data/YII.Wide.rds")
# YII.Wide<-read.csv("Data/YII_Wide.csv")
#summary(YII.Tall)
# 2. Data clean-up an types:
# Variable types
#YII.nutrients$Time <- as.factor(YII.nutrients$Time)
YII.Tall$Time<-as.numeric(YII.Tall$Time)
YII.Tall$Date<-as.Date(YII.Tall$Date, "%Y-%m-%d")
YII.Tall$Days<-(as.numeric(YII.Tall$Date)-18486)
# Remove-unused data
Extras <- YII.Tall[which (YII.Tall$Nutrients=="Extra"), ]
YII.Tall <- droplevels(YII.Tall[!rownames(YII.Tall) %in%
rownames(Extras), ])
Error <- YII.Tall[which (YII.Tall$YII==0), ]
YII.Tall <- droplevels(YII.Tall[!rownames(YII.Tall) %in%
rownames(Error), ])
# Treatments
YII.Tall$Nutrients<-factor(YII.Tall$Nutrients,
levels= c("Ambient", "NH4"), ordered=TRUE)
YII.Tall$Disease<-factor(YII.Tall$Disease,
levels= c("Placebo", "Pathogen"), ordered=TRUE)
# Replicates
YII.Tall$Tank<-factor(YII.Tall$Tank, ordered=FALSE)
YII.Tall$Genotype<-factor(YII.Tall$Genotype, ordered=FALSE)
summary(YII.Tall)
## Time Date Genotype Fragment
## Min. :0.0000 Min. :2020-08-12 FM14 : 48 201 : 2
## 1st Qu.:0.0000 1st Qu.:2020-08-12 FM19 : 48 202 : 2
## Median :0.0000 Median :2020-08-12 FM6 : 48 204 : 2
## Mean :0.9688 Mean :2020-08-22 FM9 : 48 205 : 2
## 3rd Qu.:2.0000 3rd Qu.:2020-09-02 U44 : 47 207 : 2
## Max. :2.0000 Max. :2020-09-02 Elkhorn: 46 208 : 2
## (Other):196 (Other):469
## Tank A_Tank Nutrients Disease YII
## 1 : 55 1 : 62 Ambient:245 Placebo :229 Min. :0.4900
## 2 : 55 2 : 62 NH4 :236 Pathogen:252 1st Qu.:0.6230
## 3 : 55 6 : 62 Median :0.6650
## 6 : 54 7 : 62 Mean :0.6519
## 8 : 54 8 : 61 3rd Qu.:0.6880
## 5 : 53 5 : 60 Max. :0.7150
## (Other):155 (Other):112
## Sample Days
## 2020-08-12_201: 1 Min. : 0.00
## 2020-08-12_202: 1 1st Qu.: 0.00
## 2020-08-12_204: 1 Median : 0.00
## 2020-08-12_205: 1 Mean :10.17
## 2020-08-12_207: 1 3rd Qu.:21.00
## 2020-08-12_208: 1 Max. :21.00
## (Other) :475
# Genotype
YII_Genet<- ggplot(YII.Tall, aes (Genotype, YII, colour=factor(Time))) +
stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
stat_summary(fun.y=mean, geom="line") +
geom_jitter(alpha=0.5)+
scale_y_continuous(limits = c(0, .73),
breaks = seq(0, 0.7,0.2),
expand = c(0.01, 0.01),
name=("YII (Fv/Fm)"))
YII_Genet
YII_Genet+ facet_wrap(~Nutrients)
YII_Genet+ facet_wrap(~Disease)
YII_Genet+ facet_wrap(Nutrients~Disease)
YII_Tank<- ggplot(YII.Tall, aes (Tank, YII)) +
stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
stat_summary(fun.y=mean, geom="line") +
scale_y_continuous(limits = c(0.4, .73),
breaks = seq(0, 0.7,0.2),
expand = c(0, 0),
name=("YII (Fv/Fm)"))+
geom_jitter(aes(colour=Genotype), alpha=0.3)+
facet_wrap(~Time) +
theme(legend.position = "bottom")
YII_Tank
YII_Tank+ facet_wrap(Time~Nutrients)
YII_Tank+ facet_wrap(Time~Disease)
YII_Disease<- ggplot(YII.Tall, aes (Disease, YII)) +
stat_summary(fun.data = "mean_cl_boot",geom = "errorbar", width = 0.2 )+
stat_summary(fun.y=mean, geom="line") +
scale_y_continuous(limits = c(0.4, .73),
breaks = seq(0, 0.7,0.2),
expand = c(0, 0),
name=("YII (Fv/Fm)"))+
geom_jitter(aes(colour=Genotype), alpha=0.3)+
facet_wrap(~Time) +
theme(legend.position = "bottom")
YII_Disease
YII_Tank+ facet_wrap(Time~Nutrients)
YII_Tank+ facet_wrap(Time~Disease)
# Creates bibliography
#knitr::write_bib(c(.packages()), "packages.bib")
R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.