#####********************************** MOA Hormonomics- Script to determine statistically significant differences in hormone levels**********************************#####
# Last modified: 2019-06-20

#####************************************************* Workspace Preparation ************************************************#####

# Working directory:
setwd("..")

# Required libraries
install.packages("agricolae")
library(agricolae)


### Step 1: Preparation and import of hormone concentration data 
#
# Hormone concentration data obtained by GC-MS are given in : MOA2013-12_1_hormonomics_GCMS_ANOVA-groups.xlsx
# Removal of second and third column from the file MOA2013-12_1_hormonomics_GCMS_ANOVA-groups.xlsx. 
# In the first column named MOA_groupID, the biological replicates are denoted with the same ID, which enables agricolae pipeline to group the samples.
# For statistical analysis, hormone concentrations of mock- and PVY-inoculated samples of cv. Desiree and NahG-Desiree, from specific data point (i.e. 3 dpi), need to be organized in columns (named GA3, JA, OPDA, IAA, SA, ABA) and samples (MOA_groupID) should be be organized in rows.
# Optionally, all samples can be analyzed with provided script, however the output can be more complex.
# Saving the prepared table as input.txt file into the working directory.
# Import of the data in R environment:

data <- read.delim("input.txt")

#####**************************************************Data analysis**********************************************************************#####

### Step 2: Statistical analysis
#
# Analysis includes the multiple comparison through the method of the minimum significant difference (Least Significant Difference; LSD). 
# Additionally, p-values are adjusted for multiple comparisons (false discovery rate (FDR) corrected),using function p.adj., alpha is set to 0.05.

#Calculation of statistically significant differences in the gibberellin 3 (GA3) levels
model<-aov(GA3~X,data)
comparison<- LSD.test(model,"X", alpha=0.05, p.adj="fdr", group=TRUE)
comparison

#Calculation of statistically significant differences in the jasmonic acid (JA) levels
model<-aov(JA~X,data)
comparison<- LSD.test(model,"X", alpha=0.05, p.adj="fdr", group=TRUE)
comparison

#Calculation of statistically significant differences in the 12-oxophytodienoic acid (OPDA) levels
model<-aov(OPDA~X,data)
comparison<- LSD.test(model,"X", alpha=0.05, p.adj="fdr", group=TRUE)
comparison

#Calculation of statistically significant differences in the Indole-3-acetic acid (IAA) levels
model<-aov(IAA~X,data)
comparison<- LSD.test(model,"X", alpha=0.05, p.adj="fdr", group=TRUE)
comparison

#Calculation of statistically significant differences in the salicylic acid (SA) levels
model<-aov(SA~X,data)
comparison<- LSD.test(model,"X", alpha=0.05, p.adj="fdr", group=TRUE)
comparison

#Calculation of statistically significant differences in the abscisic acid (ABA) levels
model<-aov(ABA~X,data)
comparison<- LSD.test(model,"X", alpha=0.05, p.adj="fdr", group=TRUE)
comparison

