#load packages used library(lme4) library(lmerTest) library(vegan) options(contrasts = c("contr.sum","contr.poly")) #See Pintar-and-Resetarits_Ecology-and-Evolution_Beetle-assemblages_README.txt for more details on data data1 <- read.csv(file="Pintar-and-Resetarits_Ecology-and-Evolution_Beetle-assemblages_Data.csv", head=T) data1$Pair <- as.factor(data1$Pair) #Set pair to be a factor ############# Colonizing beetles ############# #Abundance of all beetles ba1 <- lmer(sqrt(Beetle.abundance + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(ba1) #Taxonomic richness of beetles br1 <- lmer(sqrt(Beetle.richness + 0.5) ~ sqrt(Beetle.abundance + 0.5) + Treatment + (1|Block/Pair), data=data1, REML=F) anova(br1) #Berosus infuscatus bi1 <- lmer(sqrt(Berosus.infuscatus + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(bi1) #Copelatus glyphicus cg1 <- lmer(sqrt(Copelatus.glyphicus + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(cg1) #Helophorus linearis hl1 <- lmer(sqrt(Helophorus.linearis + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(hl1) #Paracymus para1 <- lmer(sqrt(Paracymus + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(para1) #Tropisternus lateralis tl1 <- lmer(sqrt(Tropisternus.lateralis + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(tl1) #Beetle assemblage structure species <- data1[,c(6:43)] #Create community matrix of all beetle taxa trt <- data1[,c(1:5)] #treatments trt$Pair <- as.factor(trt$Pair) species2 <- sqrt(species + 0.5) #square-root transform community matrix perM1 <- adonis(species2 ~ Treatment + Block, trt, permutations=9999, method="bray") #create permanova model perM1 #assemblage structure results ############# Hyla chrysoscelis ############# hyla1 <- lmer(sqrt(Hyla.eggs + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(hyla1) ############# Culex restuans ############# #Culex before group culex.before <- lmer(sqrt(Culex.before + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(culex.before) #Culex after group culex.after <- lmer(sqrt(Culex.after + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(culex.after) ############# Taxa collected at end of experiment ############# #Copepods z1 <- lmer(sqrt(Rotifera + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(z1) #Chironomidae larvae chiro1 <- lmer(sqrt(Chironomidae.larvae + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(chiro1) #Dytiscidae larvae dyt1 <- lmer(sqrt(Dytiscidae.larvae + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(dyt1) #Ephemeroptera nymphs eph1 <- lmer(sqrt(Ephemeroptera.nymphs + 0.5) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(eph1) ############# Environmental analyses ############# #Ammonium nh4 <- lmer(log(NH4 + 1) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(nh4) #Specific conductance spc <- lmer(log(Specific.Conductance + 1) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(spc) #Dissolved oxygen do <- lmer(log(Dissolved.Oxygen + 1) ~ log(Temperature + 1) + Treatment + (1|Block/Pair), data=data1, REML=F) anova(do) #pH ph1 <- lmer(pH ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(ph1) #Temperature temp <- lmer(log(Temperature + 1) ~ Treatment + (1|Block/Pair), data=data1, REML=F) anova(temp)