Recap of Lab 3 Exercises

Recap of Lab 3 Exercises

Task 1 - Recreate the following plot

pl <- ggplot(data = SPE_ENV,
             mapping = aes(x = OTU_Count,
                           y = Taxa,
                           fill = site)) +
  geom_boxplot()

Task 2 - Recreate the following plot

pl <- ggplot(data = SPE_ENV,
             mapping = aes(x = site,
                           y = Temp)) +
  geom_boxplot()

Task 3 - Recreate the following plot

pl <- ggplot(data = SPE_ENV,
             mapping = aes(x = Temp,
                           y = pH,
                           colour = site)) +
  geom_point()

Task 4 - Recreate the following plot

pl <- ggplot(data = SPE_ENV,
             mapping = aes(x = Temp,
                           y = pH,
                           colour = site,
                           label = Samples)) +
  geom_label(size = 3)

Task 5 - Recreate the following plot

pl <- ggplot(data = SPE_ENV,
             mapping = aes(x = NH4,
                           fill = site)) +
  geom_density()

Task 5 - Recreate the following plot - OR

pl <- pl +
  scale_x_log10()

Note this syntax and think about what it means

Task 6 - Recreate the following plot

pl <- ggplot(data = SPE_ENV,
             mapping = aes(x = CODt,
                           y = CODs,
                           colour = site)) +
  geom_point() +
  geom_smooth(method = "lm")

Task 7 - Recreate the following plot

pl <- ggplot(data = SPE_ENV,
             mapping = aes(x = Taxa,
                           y = Samples,
                           fill = OTU_Count)) +
  geom_tile() +
  scale_fill_gradient2(midpoint = 10000,
                       low = "blue",
                       mid = "white",
                       high = "red") +
  theme_classic(base_size = 8) +
  theme(legend.position = "bottom",
        axis.text.x = element_text(angle = 45,
                                   hjust = 1))

Task 8 - Recreate the following plot

library("ggridges")
pl <- ggplot(data = SPE_ENV_targets,
             mapping = aes(x = OTU_Count,
                           y = Taxa,
                           fill = Taxa)) +
  geom_density_ridges(alpha = 0.5) +
  scale_fill_viridis_d() +
  labs(x = "OTU Count",
       y = "Taxa Identified",
       title = "OTU Count Distribution for 5 Taxa Stratified on Site",
       caption = "Data from doi.org/10.1111/1751-7915.12334") +
  theme_minimal(base_family = "Avenir",
                base_size = 12) +
  theme(legend.position = "bottom") +
  facet_wrap(vars(site),
             ncol = 2)

Task 9 - GROUP ASSIGNMENT

Let us take a look at a nice example…