Load packages
Load phenotype data (BLUE)
phenotype <- read.csv("/Users/Leon/OneDrive - Cornell University/3_Manuscript/Manuscript8/Phenotype_2019_BLUEs.csv", header = T)
phenotype$genotype <- str_replace(phenotype$genotype,"_WW","")
phenotype$genotype <- str_replace(phenotype$genotype,"_WL","")
phenotype$index = paste0(phenotype$Group,"_",phenotype$genotype)
head(phenotype, 20)
Build groups for comparisons
#Build variables for plot stats
my_comparisons <- list(c("Wild","Commercial"), c("Commercial","Elite"), c("Wild","Elite"))
fun_length <- function(x){
return(data.frame(y=median(x),label= paste0("N=", length(x))))
}
Plot respective traits
#Plot the yield
P1 <- ggplot(data = phenotype, aes(x = Group, y = Lint_yield, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.75),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$Lint_yield + 9),max(phenotype$Lint_yield + 3),max(phenotype$Lint_yield + 6))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
#Plot the Mic
P2 <- ggplot(data = phenotype, aes(x = Group, y = Mic, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.75),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$Mic + 0.7),max(phenotype$Mic + 0.5),max(phenotype$Mic + 0.6))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
#Plot the UI
P3 <- ggplot(data = phenotype, aes(x = Group, y = UI, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.75),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$UI + 3),max(phenotype$UI + 1),max(phenotype$UI + 2))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
#Plot the UHM
P4 <- ggplot(data = phenotype, aes(x = Group, y = UHM, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.75),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$UHM + 0.2),max(phenotype$UHM + 0.1),max(phenotype$UHM + 0.15))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
#Plot the Str
P5 <- ggplot(data = phenotype, aes(x = Group, y = Str, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.75),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$Str + 2.5),max(phenotype$Str + 0.5),max(phenotype$Str + 1.5))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
#Plot the Elo
P6 <- ggplot(data = phenotype, aes(x = Group, y = Elo, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.75),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$Elo + 0.6),max(phenotype$Elo + 0.2),max(phenotype$Elo + 0.4))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
Combine figure panels together
plot_grid(P1,P2,P3,P4,P5,P6,labels = c('A', 'B', 'C', 'D', 'E', 'F'), label_size = 12)
## Warning in wilcox.test.default(c(5.83, 4.435, 5.17, 5.78, 5.155, 4.525, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(5.46, 5.99, 5.965, 5.405, 5.1, 5.375, 5.375, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(5.46, 5.99, 5.965, 5.405, 5.1, 5.375, 5.375, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(29.45, 24.75, 29.45, 29.15, 29.35, 27.8, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(29.45, 24.75, 29.45, 29.15, 29.35, 27.8, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(5.15, 5.5, 5, 5.25, 5.6, 5.3, 6.3, 5, 5.4, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(5, 5.65, 5.2, 5, 5.35, 5, 5.35, 4.85, 5.8, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(5, 5.65, 5.2, 5, 5.35, 5, 5.35, 4.85, 5.8, :
## cannot compute exact p-value with ties

Plot by environmental factors (WL and WW)
level_order <- c('WW', 'WL')
graph1 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = Lint_yield)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("Lint yield") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
graph2 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = Mic)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("Mic") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
graph3 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = UHM)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("UHM") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
graph4 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = UI)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("UI") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
graph5 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = Str)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("Str") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
graph6 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = Elo)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("Elo") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
#### Plot vegetation indicies
graph7 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = NDVI)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("NDVI") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
graph8 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = sPRI)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("sPRI") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
graph9 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = CRI)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("CRI") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
graph10 <- ggplot(data = phenotype, aes(x = factor(treatment, level = level_order), y = WI.NDVI)) +
#plot each rep
geom_boxplot(size = 1, color = "grey") + facet_wrap(~ Group, ncol=3) +
geom_point(size = 1.5, aes(group=genotype, color = Group, shape = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "green","tomato1")) +
#add lines for connection
geom_line(linetype = "dashed", aes(group=genotype, color = Group), show.legend = F) + facet_wrap(~ Group, ncol=3) +
scale_colour_manual(values = c("dodgerblue3", "#1B9E77","tomato1")) +
theme_bw() +
stat_compare_means(aes(x = factor(treatment, level = level_order)), label = "p.format", method = "t.test") +
#plot average lines
stat_summary(fun = mean, color = "darkred", position = position_dodge(1),
geom = "point", shape = 4, size = 6,
show.legend = F) +
#Add unit to the Y-axis
ylab("WI.NDVI") + xlab("")
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
plot_grid(graph1,graph2,graph3,graph4,graph5,graph6)

plot_grid(graph7,graph8,graph9,graph10)

Plot vegetation indices
######Plot indices #####
P7 <- ggplot(data = phenotype, aes(x = Group, y = NDVI, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.25),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$NDVI + 0.015),max(phenotype$NDVI + 0.005),max(phenotype$NDVI + 0.01))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
P8 <- ggplot(data = phenotype, aes(x = Group, y = sPRI, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.25),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$sPRI + 0.015),max(phenotype$sPRI + 0.005),max(phenotype$sPRI + 0.01))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
P9 <- ggplot(data = phenotype, aes(x = Group, y = CRI, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.25),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$CRI + 0.15),max(phenotype$CRI + 0.05),max(phenotype$CRI + 0.1))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
P10 <- ggplot(data = phenotype, aes(x = Group, y = WI.NDVI, outlier.size = 0.01, fill = factor(treatment))) +
geom_boxplot() + theme_classic2() +
#add jitters
geom_jitter(color="red", size=0.4, alpha=0.9) +
#add custom color
scale_fill_manual(values = c("steelblue", "tomato", "steelblue", "tomato","steelblue", "tomato"))+
#add meam summary information
stat_summary(fun = mean, color = "darkred", position = position_dodge(0.25),
geom = "point", shape = 4, size = 3,
show.legend = FALSE) +
# add comparisons among three groups
stat_compare_means(comparisons = my_comparisons,test=t.test,
label.y = c(max(phenotype$WI.NDVI + 0.015),max(phenotype$WI.NDVI + 0.005),max(phenotype$WI.NDVI + 0.01))) +
#add comparisons within each group
stat_compare_means(aes(group = treatment), method = "t.test", label = "p.format")
## [1] FALSE
Combine figure panels together
plot_grid(P7,P8,P9,P10,labels = c('A', 'B', 'C', 'D'), label_size = 12)
## Warning in wilcox.test.default(c(0.819, 0.823, 0.813, 0.811, 0.826, 0.822, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(0.83, 0.815, 0.836, 0.814, 0.822, 0.821, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(0.83, 0.815, 0.836, 0.814, 0.822, 0.821, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(0.499, 0.508, 0.51, 0.508, 0.509, 0.51, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(0.512, 0.51, 0.512, 0.505, 0.509, 0.503, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(0.512, 0.51, 0.512, 0.505, 0.509, 0.503, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(2.392, 2.419, 2.214, 2.338, 2.465, 2.469, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(2.493, 2.16, 2.564, 2.319, 2.362, 2.407, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(1.274, 1.267, 1.282, 1.281, 1.259, 1.266, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(1.256, 1.281, 1.245, 1.274, 1.27, 1.275, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(1.256, 1.281, 1.245, 1.274, 1.27, 1.275, :
## cannot compute exact p-value with ties
