Recap Lab 4

Leon Eyrich Jessen

A Few Meta Points…

Paths

  • The .Rproj-file defines your project root, i.e. everything is relative to where this file is
  • In your .Qmd-file you need to think about where files you need are
  • To load something from data, you need to specify data/my_data.csv
  • To load from _raw in data, you specify data/_raw/my_raw_data.xlsx

Qmd

  • Load libraries before calling needed functions
  • Do a Run All check (Menu above Quarto doc \(\rightarrow\) Run \(\rightarrow\) Run All)
  • When getting errors, make sure read the error message

Group work

  • Each student must have a and work in a project on the RStudio Cloud Server

  • Each student must to actively write code (no one has ever gotten good at football by watching others play \(\rightarrow\) Learning by actively doing)

  • Make sure to talk together in your groups, you will learn something by explaining

  • Group work is a Learning Objective element in this course \(\rightarrow\) Outlook to collaboratice bio data science!

Recap

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 this years submissions…