--- title: "QUBES" author: "Erik Kaseloo" date: "3/29/2022" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ## You will need the packages "readr" and "ggplot2" for this lesson if you do not have them installed install them using the chunk below. ```{r} install.packages("readr") install.packages("ggplot2") ``` ## Let's examine the average change in height between warmed and ambient plots to begin our analysis of Figure 2 in the paper. First we will recreate Figure 2a by uploading the average change in height in centimeters of the two temperatures. ```{r} library(readr) HeightPlot <- read.csv("HeightPlot.csv") HeightPlot ``` ## If you have ï..Temperature as a column name then run this code so that the column is renamed as just temperature. ```{r, eval=FALSE} HeightPlot$Temperature <- HeightPlot$ï..Temperature HeightPlot <- subset(HeightPlot, select = -(ï..Temperature)) HeightPlot ``` ## Now let's create the graph. ```{r} library(ggplot2) ggplot(HeightPlot, aes(x=Temperature, y= MeanHeightChange_cm, fill=Temperature)) + geom_col() + geom_errorbar(aes(ymin=MeanHeightChange_cm-SE, ymax=MeanHeightChange_cm+SE, width=.2)) + ggtitle("Mean Change in Mangrove Height in Warmed and Ambient Plots") + xlab("Temperature") + ylab("Mean Change in Height (cm)") ``` ## Question 1: Looking at this figure, does the average change in height for the two temperature types look significantly different? Judging from this figure, what impact would higher temperatures have on mangrove height? Remember to discuss the error bars in your answer. ## Now let's upload the height change data from all plots. ```{r} Height <- read.csv("Height.csv") Height ``` ## If you have ï..Temperature as a column name then run this chunk to change the column name to just Temperature. ```{r} Height$Temperature <- Height$ï..Temperature Height <- subset(Height, select = -(ï..Temperature)) Height ``` ## For this portion of our lesson we will be using a Welch Two Sample t-test to compare the means of the two groups. In order to conduct our t-test we will need to make sure our data is normally distributed using a Shapiro-Wilke Test. ```{r} shapiro.test(Height$HeightChange_cm) #If the p-value is less than .05 then the data is not normally distributed. ``` ## If the data is normally distributed we can then proceed with our t-test. ```{r} t.test(HeightChange_cm ~ Temperature, data = Height) ``` ## Question 2: Does the t-test indicate that the difference in height change between warmed and ambient plots is statistically significant? Remember to discuss the p-value in your answer. ## Now let's move on to belowground biomass. For this portion we shall recreate figure 2c from the paper. To start we will upload the average change in biomass between salt marsh and mangrove sections in the warmed and unwarmed plots. ```{r} Biomassplot <- read.csv("BiomassPlot.csv") Biomassplot ``` ## If you get ï..Type as a column name use the following chunk to change the column name to Type. ```{r} Biomassplot$Type <- Biomassplot$ï..Type Biomassplot <- subset(Biomassplot, select = -(ï..Type)) Biomassplot ``` ## Now we can make our figure. ```{r} ggplot(Biomassplot, aes(x=Type, y= Change_in_belowground_biomass, fill=Temperature)) + geom_col() + geom_errorbar(aes(ymin=Change_in_belowground_biomass-SE, ymax=Change_in_belowground_biomass+SE, width=.2)) + ggtitle("Mean Change Belowground Biomass (g/m^2)") + xlab("Type of Wetland") + ylab("Mean Change in Biomass (kg/m^2)") ``` ## Question 3: Looking at the graph which wetland types look significantly different from each other? Does warming appear to impact the growth of belowground biomass? Remember to discuss the error bars in your answer. ## Now let's conduct our statistical analysis for the change in belowground biomass across all plots. For this part we must begin by uploading our data. ```{r} Biomass <- read.csv("Biomass.csv") Biomass ``` ## If you get ï..Type as a column name run this chunk to change the column name to Type. ```{r} Biomass$Type <- Biomass$ï..Type Biomass <- subset(Biomass, select = -(ï..Type)) Biomass ``` ## In order to analyze this data we will be using ANOVA to determine which wetland classes, if any, are significantly different from each other. Like a t-test, ANOVA relies on the assumption that our data is normally distributed. In order to test this we will run another Shapiro-Wilke test. ```{r} shapiro.test(Biomass$Belowgroundbiomasschange) ``` ## If our data is normally distributed we can then run our ANOVA analysis. ```{r} summary(aov(Belowgroundbiomasschange ~ Type*Temperature, data = Biomass)) ``` ## If we get p-values less than .05 then we must perform a post-hoc test. For our lesson we shall utilize the Tukey test to determine which means are significantly different from each other. ```{r} BiomassANOVA <- aov(Belowgroundbiomasschange ~ Type*Temperature, data = Biomass) TukeyHSD(BiomassANOVA) ``` ## Question 4: Using the results of the ANOVA we just conducted, are any of the means significantly different from each other? If so which ones? Remember to look at the p-values when answering. ## Now let's continue our examination of figure 2 by examining figure 2(d), the figure examining changes in surface elevation in the different types of wetlands. For this analysis we shall once again create a figure to help us visualize the data. First we must upload the average elevation change data between plot types. ```{r} ElevationPlot <- read.csv("ElevationPlot.csv") ElevationPlot ``` ## If you get ï..Type as a column name run the chunk below to change the column name to Type. ```{r} ElevationPlot$Type <- ElevationPlot$ï..Type ElevationPlot <- subset(ElevationPlot, select = -(ï..Type)) ElevationPlot ``` ## Now let's create our figure. ```{r} ggplot(ElevationPlot, aes(x=Type, y= ElevationChangemm, fill=Treatment)) + geom_col() + geom_errorbar(aes(ymin=ElevationChangemm-SE, ymax=ElevationChangemm+SE, width=.2)) + ggtitle("Mean Change in Surface Elevation") + xlab("Type of Wetland") + ylab("Mean Change in Elevation (mm)") ``` ## Question 5: Looking at this figure, which wetland types look to be significantly different from each other? Is one group increasing elevation at a faster rate than the others and if so what potential implications could rising temperatures have on the ability of tidal wetlands to increase elevation? Remember to discuss error bars in your answer. ## Now let's move on to our statistical analysis. For this section we shall utilize ANOVA again but first we must upload our elevation data across all plots. ```{r} Elevation <- read.csv("Elevation.csv") Elevation ``` ## If you get ï..Type as a column name then run the chunk below to change the column name to Type. ```{r} Elevation$Type <- Elevation$ï..Type Elevation <- subset(Elevation, select = -(ï..Type)) Elevation ``` ## Just like in our previous example we must check for normality before conducting our ANOVA. ```{r} shapiro.test(Elevation$Change_in_elevation_mm) ``` ## If the data is normally distributed we can then perform our ANOVA. ```{r} summary(aov(Change_in_elevation_mm ~ Type*Temperature, data=Elevation)) ``` ## If we detect a statistically significant difference in the mean change in elevation between the wetland types then we must perform a post-hoc test to determine which means are significantly different from each other, if not we can move on. ```{r} ElevationANOVA <- aov(Change_in_elevation_mm ~ Type*Temperature, data = Elevation) TukeyHSD(ElevationANOVA) ``` ## Question 6: The authors state that increases in belowground biomass results are correlated with increases in surface elevation. How does our analysis of the differences in average change in belowground biomass compare with our analysis of the average change in surface elevation between the different types of wetland?