Generated on 2020-11-19

Introduction

We’re going to look at some plant CO2 data from Echinochola crus-galli

The factors in this design are:

  • Plant: The physical plant from which measures were made
  • Type: The geographic location from which they were taken
  • Treatment: Chilled or not

What we’re going to measure is:

  1. The atmospheric concentration of CO2
  2. The amount of carbon uptake

We’re aiming to see if the plants CO2 response is similarly affected by cold in the two locations from which they were sampled.

First we’ll load the tidyverse packages.

library(tidyverse)

Data Preparation

Read the data

The data is in standard CSV format

Data file is plant_co2.csv

read_csv(params$datafile) -> plant

head(plant,n=20)

I’m going to modify the treatment variable here to be a factor since I want control over the ordering of the levels. I want the nonchilled to appear first.

plant %>%
  mutate(
    Treatment = factor(Treatment, levels=c("nonchilled","chilled"))
  ) -> plant

head(plant)

Visualisation

Now we’re going to draw a graph. Initially I want to plot every piece of data. I’m going to do a scatterplot, but joining the points from the same physical plant. The points will be coloured based on their treatment condition and the shapes will reflect where they came from.

plant %>%
  ggplot(
    aes(
      x=conc, 
      y=uptake, 
      colour=Treatment, 
      shape=Type, 
      group=Plant
    )
  ) +
  geom_point(size=3) +
  geom_line(size=1) +
  scale_colour_brewer(palette = "Set1")

The Mississippi chilled plants obviously look different to the rest, but the other patterns aren’t so clear. We can also see that the shift in uptake is stabilised once we hit a concentration of 250, so we’ll just use that data for later plots.

Let’s separate out the different factors to focus on the chilling response.

First we can create a dataset with just the data for conc >= 250.

plant %>%
  filter(conc >= 250) -> plant250

head(plant250)

Now we can plot a stripchart of the response in the two locations, but with the mean values superimposed.

plant250 %>%
  ggplot(aes(x=Treatment, y=uptake)) +
  geom_jitter(height=0, width=0.2) +
  facet_grid(cols = vars(Type)) +
  stat_summary(
    geom="errorbar", 
    fun=mean, 
    fun.max=mean, 
    fun.min=mean
  )
Chilled response per location

Chilled response per location

Now it becomes much more obvious that the reponse to chilling is different in the two groups. In Mississippi the plants show a strong response, but in Quebec (where presumably it’s cold more of the time) their uptake is higher in both cases, and less affected by cold.

Summarisation

We can summarise the response to get a simpler view of the differences as a bargraph rather than a stripchart.

plant250 %>%
  group_by(Treatment,Type) %>%
  summarise(
    sem=sd(uptake)/sqrt(n()),
    uptake=mean(uptake)
  ) %>%
  ungroup() %>%
  ggplot(
    aes(
      x=Treatment, 
      y=uptake, 
      ymin=uptake-sem, 
      ymax=uptake+sem
    )
  ) +
  geom_col(fill="grey")+
  geom_errorbar(width=0.3, size=1) +
  facet_grid(cols=vars(Type)) +
  theme_bw()

Since we’re measuring the accuracy of our means I’ve actually calculated the SEM value. This shows that there is a response in both cases which will likely be significant (we’d need to do a t-test to confirm), but that the response is larger in magnitude in Mississippi.