Since I’m suggesting that oogonia release is affected by pH and salinity, here I am showing that other factors (such as temperature and dissovled oxygen) are not significant in this interaction. To do this I’m doing simple regressions. y-axis will be average oogonia released per unit (calculted the same as the salinity pH graph) and the x-axis will be the average temperature, dissolved oxygen or light. Currently I’m not sure what “light” data to use (loggers?) to I’m just doing temperature and dissolved oxygen. I will need to update this.
Convert to number
exp$oo_disc_1<-as.numeric(exp$oo_disc_1)
exp$oo_disc_2<-as.numeric(exp$oo_disc_2)
exp$oo_disc_3<-as.numeric(exp$oo_disc_3)
exp$oo_disc_4<-as.numeric(exp$oo_disc_4)
exp$unit_temp_hach<-as.numeric(exp$unit_temp_hach)
exp$unit_do_hach<-as.numeric(exp$unit_do_hach)
exp$treatment<-as.character(exp$treatment)
Average oogonia per thalli
exp$avg_oo_thalli<-rowMeans(exp[,c('oo_disc_1', 'oo_disc_2', 'oo_disc_3','oo_disc_4')], na.rm=TRUE)
Let’s subset the data per run
r1<-subset(exp, run=='1')
r2<-subset(exp, run=='2')
r3<-subset(exp,run=='3')
Temperature, dissolved oxygen, pH, and salinity average=average of all Hach readings of that parameter in the unit per treatment. Average of each paramter per each unit
#temperature
r1tempav<-aggregate( unit_temp_hach ~ thalli,r1, mean)
r2tempav<-aggregate( unit_temp_hach ~ thalli,r2, mean)
r3tempav<-aggregate( unit_temp_hach ~ thalli,r3, mean)
#dissolved oxygen
r1doav<-aggregate( unit_do_hach ~ thalli,r1, mean)
r2doav<-aggregate( unit_do_hach ~ thalli,r2, mean)
r3doav<-aggregate( unit_do_hach ~ thalli,r3, mean)
#salinity
r1salav<-aggregate( unit_sal_hach ~ thalli,r1, mean)
r2salav<-aggregate( unit_sal_hach ~ thalli,r2, mean)
r3salav<-aggregate( unit_sal_hach ~ thalli,r3, mean)
#pH
r1phav<-aggregate( unit_ph_c ~ thalli,r1, mean)
r2phav<-aggregate( unit_ph_c ~ thalli,r2, mean)
r3phav<-aggregate( unit_ph_c ~ thalli,r3, mean)
Remove rows with NA and make new dataframe
oo<-exp[!is.na(exp$avg_oo_thalli), ]
oo<-data.frame(oo$thalli, oo$avg_oo_thalli, oo$treatment)
Add run number back to dataframes.
r1tempav$run<-'1'
r2tempav$run<-'2'
r3tempav$run<-'3'
Combine temperature, dissolved oxygen, salinity, and pH data. Clean up data set
r1complete<-cbind(r1tempav, r1doav, r1salav, r1phav)
r2complete<-cbind(r2tempav, r2doav,r2salav, r2phav)
r3complete<-cbind(r3tempav, r3doav,r3salav, r3phav)
a<-rbind(r1complete, r2complete, r3complete)
b<-a[-c(4,6,8)]
c<-cbind(oo,a)
final<-c[-c(1,7,9,11)]
Linear equation
#temperature
lm_eqn_temp <- function(final){
m <- lm(oo.avg_oo_thalli ~ unit_temp_hach, final);
eq <- substitute(italic(oo) == a + b %.% italic(temp)*","~~italic(r)^2~"="~r2,
list(a = format(unname(coef(m)[1]), digits = 2),
b = format(unname(coef(m)[2]), digits = 2),
r2 = format(summary(m)$r.squared, digits = 3)))
as.character(as.expression(eq));
}
#dissolved oxygen
lm_eqn_do <- function(final){
m <- lm(oo.avg_oo_thalli ~ unit_do_hach, final);
eq <- substitute(italic(oo) == a + b %.% italic(DO)*","~~italic(r)^2~"="~r2,
list(a = format(unname(coef(m)[1]), digits = 2),
b = format(unname(coef(m)[2]), digits = 2),
r2 = format(summary(m)$r.squared, digits = 3)))
as.character(as.expression(eq));
}
#salinity
lm_eqn_sal <- function(final){
m <- lm(oo.avg_oo_thalli ~ unit_sal_hach, final);
eq <- substitute(italic(oo) == a + b %.% italic(sal)*","~~italic(r)^2~"="~r2,
list(a = format(unname(coef(m)[1]), digits = 2),
b = format(unname(coef(m)[2]), digits = 2),
r2 = format(summary(m)$r.squared, digits = 3)))
as.character(as.expression(eq));
}
#ph
lm_eqn_ph <- function(final){
m <- lm(oo.avg_oo_thalli ~ unit_ph_c, final);
eq <- substitute(italic(oo) == a + b %.% italic(pH)*","~~italic(r)^2~"="~r2,
list(a = format(unname(coef(m)[1]), digits = 2),
b = format(unname(coef(m)[2]), digits = 2),
r2 = format(summary(m)$r.squared, digits = 3)))
as.character(as.expression(eq));
}
Graph temperature, dissolved oxygen, salinity, or pH on the x-axis, average oogonia per unit on the y.
temp_graph<-ggplot(data = final, mapping = aes(x = unit_temp_hach, y = oo.avg_oo_thalli)) + geom_point(aes(colour = oo.treatment)) +geom_smooth(method=lm)+ geom_text(x = 15.5, y = 1500, label = lm_eqn_temp(final), parse = TRUE)+ ggtitle("Effect of temperature on oogonia release")+ theme(plot.title = element_text(size = 12, face = "plain")) +theme(axis.text=element_text(size=12),axis.title=element_text(size=12,face="plain")) + ylab("") + xlab("Average unit temperature (C)") + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"))
do_graph<-ggplot(data = final, mapping = aes(x = unit_do_hach, y = oo.avg_oo_thalli)) + geom_point(aes(colour = oo.treatment)) +geom_smooth(method=lm)+ geom_text(x = 9.9, y = 1500, label = lm_eqn_do(final), parse = TRUE)+ ggtitle("Effect of dissolved oxygen on oogonia release")+ theme(plot.title = element_text(size = 12, face = "plain")) +theme(axis.text=element_text(size=12),axis.title=element_text(size=12,face="plain")) + ylab("") + xlab("Average unit dissovled oxygen") + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"))
sal_graph<-ggplot(data = final, mapping = aes(x = unit_sal_hach, y = oo.avg_oo_thalli)) + geom_point(aes(colour = oo.treatment)) +geom_smooth(method=lm)+ geom_text(x = 28, y = 1500, label = lm_eqn_sal(final), parse = TRUE)+ ggtitle("Effect of salinity on oogonia release")+ theme(plot.title = element_text(size = 12, face = "plain")) +theme(axis.text=element_text(size=12),axis.title=element_text(size=12,face="plain")) + ylab("") + xlab("Average unit salinity") + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"))
ph_graph<-ggplot(data = final, mapping = aes(x = unit_ph_c, y = oo.avg_oo_thalli)) + geom_point(aes(colour = oo.treatment)) +geom_smooth(method=lm)+ geom_text(x = 7, y = 1500, label = lm_eqn_ph(final), parse = TRUE)+ ggtitle("Effect of pH on oogonia release")+ theme(plot.title = element_text(size = 12, face = "plain")) +theme(axis.text=element_text(size=12),axis.title=element_text(size=12,face="plain")) + ylab("") + xlab("Average unit pH") + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "black"))
graph_all<-ggarrange(temp_graph, do_graph, sal_graph, ph_graph, ncol=1, nrow=4)
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
annotate_figure(graph_all,
top = text_grob(" ", color = "black", face = "plain", size = 14), bottom=text_grob(" ", color = "black", rot = 0, size=12), left = text_grob("Average oogonia released per thalli", color = "black", rot = 90, size=12))