yp_data <- read.csv("SDlluteus_rev.csv")
yp_data$eco <- as.factor(yp_data$eco)
yp_data$temp <-as.factor(yp_data$temp)
levels(yp_data$temp) <- c("20°C","27.5°C","35°C")
yp_data$treatment <- as.factor(yp_data$treatment)Stomatal Conductance
Stomatal conductance analysis
- Prepare data
- Visualize
Stomatal conductance mean +/- SE
library(Rmisc)Loading required package: lattice
Loading required package: plyr
library(plyr)
library(lattice)
# compute mean and standard error of the mean by subgroup
summary_stat <- summarySE(yp_data,
measurevar = "stomcond",
groupvars = c("temp", "eco")
)
library(ggplot2)
ggplot(
data = summary_stat,
aes(x = temp, y = stomcond, colour = eco)
) +
geom_errorbar(aes(ymin = stomcond - se, ymax = stomcond + se), # add error bars
width = 0.1 # width of error bars
) +
geom_line(aes(group=eco)) +
geom_point() +
labs(y = "Stom Cond")+
scale_color_manual(values=c("deepskyblue3", "darkgoldenrod"))Boxplots
library(ggplot2)
ggplot(data=yp_data, aes(x=temp,y=stomcond,fill=eco))+
geom_boxplot(outlier.shape = NA)+
geom_point(position=position_jitterdodge(),size=3,alpha=0.5)+
theme(
plot.tag = element_text(size = 16),
panel.border = element_rect(colour = "black", fill=NA, size=1),
panel.background = element_rect(fill = "white"),
axis.title.x = element_blank(),
axis.text.x = element_text(colour = "black", size=12),
axis.title.y = element_text(colour = "black", size=14),
axis.text.y = element_text(colour = "black", size=12)
)+
labs(y=expression("Stom Cond"))+
scale_fill_manual(values=c("deepskyblue3", "darkgoldenrod"))Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
“Interaction” v. “No interaction” model
no interaction: stomcond ~ temp + eco
interaction: stomcond ~ temp * eco
-> Identify best model using AIC
nointeract <- aov(stomcond ~ temp + eco, data = yp_data)
interaction <- aov(stomcond ~ temp * eco, data = yp_data)
#find best model (best listed first via aictab)
library(AICcmodavg)
model.set <- list(nointeract, interaction)
model.names <- c("no interaction", "interaction")
aictab(model.set, modnames = model.names)
Model selection based on AICc:
K AICc Delta_AICc AICcWt Cum.Wt LL
no interaction 5 -28.53 0.00 0.97 0.97 20.93
interaction 7 -21.57 6.96 0.03 1.00 21.28
-> “No interaction” model is the best fit.
- Run ANOVA model
nointeract <- aov(stomcond ~ temp + eco, data = yp_data)
summary(nointeract) Df Sum Sq Mean Sq F value Pr(>F)
temp 2 0.06152 0.03076 2.505 0.1069
eco 1 0.14661 0.14661 11.941 0.0025 **
Residuals 20 0.24555 0.01228
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
- The ecotype has a statistically significant effect on stomatal conductance (p=0.0025).