knitr::opts_chunk$set(echo = TRUE)
Today we will be installing an R package that will help us process and prepare raw data to be analyzed. This data is resulting from an experiment on the wetland plant Juncus effusus, looking at the response to differing doses of ammonium. The goal of this package is to help us create useful biomass and height increase information based on this raw data, and then analyze the two to see if plant height increase can predict biomass increase. First lets install the package from github using the below code.
devtools::install_github("tesseracrockett/crockett.pkg")
Before we look at each function, make sure to load the package into your local or studio version of R.
library(crockett.package)
Alone, above_ground or belowground biomass are not particularly reflective of what a given plant may have experienced during it's growth season, however root to shoot ratio, a ratio (belowground/above_ground) that includes both pieces of plant growth information, can be very informative. Having a function to compute this ratio into a new column that can then be analyzed helps prevent errors typically found in hand calculations and provides this information quickly. The expected inputs are specific to the tibble (dataframe) "ecotox" and are the above_ground and belowground columns, which is biomass weight in grams. The expected output is a new column that has calculated the root to shoot ratio for each sample, the closer to 1, the closer the plant was to having equal roots to shoots.
Now lets load in the data frame and run this function.
library(tidyverse) ecotox <- read_csv("../inst/extdata/ecotox.csv") calc_rootshoot_ratio(data = ecotox, BELOWGROUND = ecotox$BELOWGROUND, ABOVE_GROUND = ecotox$ABOVE_GROUND) ecotox <- calc_rootshoot_ratio(data = ecotox, BELOWGROUND = ecotox$BELOWGROUND, ABOVE_GROUND = ecotox$ABOVE_GROUND)
You should be seeing our tibble "ecotox" with the new column "rs_ratio".
Let's take a look at the next function in this package.
Our raw data provides us with the initial and final height of the plant, however in order to better analyze our data and compare to other information such as biomass, we need to determine the difference in plant height from initial to final height measurements taken. Running this function helps prevent errors in hand calculations or calculations by rows. The expected inputs are specific to the tibble (dataframe) "ecotox" and include the "HEIGHT_I" and "HEIGHT_F" columns, which are both reported in centimeters. Programmed in this function is a test to make sure that the data provided from the height columns are indeed numerical (no blanks or alphabetical entries). The expected output is a new column titled "fh_diff" which has calculated the difference in the initial and final height of the plant, in centimeters.
Now, let's process our second function.
summary(ecotox) calc_finalheight_diff(data = ecotox, HEIGHT_F = ecotox$HEIGHT_F, HEIGHT_I = ecotox$HEIGHT_I) ecotox <- calc_finalheight_diff(data = ecotox, HEIGHT_F = ecotox$HEIGHT_F, HEIGHT_I = ecotox$HEIGHT_I)
You should see first a summary of our tibble with our "rs_ratio" column, and secondly our tibble with our new column "fh_diff".
Next, let's take a look at our final function.
When working with plant data, it is helpful to see if there are visual cues (such as growth, leaf or shoot health, etc...) that can predict and inform us further about the plant. Here we look at plant height increase as a predictor for the root/shoot ratio, i.e. total biomass ratio, across the dose of ammonium received by samples. This analysis is a great visual for those that are unfamiliar with plant processes in general, especially in relation to nutrient dosing. Let us see if we fit the right model.
summary(ecotox) ecotox_lin_reg(data = ecotox, rs_ratio = ecotox$rs_ratio, fh_diff = ecotox$fh_diff, DOSE = ecotox$DOSE, lm = lm(rs_ratio~fh_diff, ecotox))
As we see here, the model does fit when the plant samples receive no nutrient; plant height is a predictor of root to shoot ratio. However as plant samples receive differing doses of 2, 20, and 200 ppm ammonium, it becomes clear that plant height increase is a not an accurate or reliable predictor of root to shoot ratio. This can also be seen by our R value, which tells us that only about 46% of the root to shoot ratio of a plant sample is explained by plant height increase; there is a relationship here, but it is not very strong. Further analysis of this data should include an ANOVA.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.