Skip to content

Commit cd37a9c

Browse files
committed
Add questions to Data Processing % Plotting Growth Curves sections
1 parent 859f605 commit cd37a9c

File tree

1 file changed

+110
-18
lines changed

1 file changed

+110
-18
lines changed

inst/tutorials/growth_curve/growth_curve_analysis.Rmd

Lines changed: 110 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ output:
1212
runtime: shiny_prerendered
1313
---
1414

15-
- Add R base t.test()
16-
- Focus on Friday data
1715
- Make questions
1816

1917
```{r setup, include=FALSE}
2018
# General learnr setup
2119
library(learnr)
20+
library(gradethis)
21+
gradethis_setup()
2222
knitr::opts_chunk$set(echo = TRUE, message=FALSE, warning=FALSE)
2323
library(educer)
2424
# Helper function to set path to images to "/images" etc.
@@ -39,7 +39,6 @@ Necessary packages are first loaded into R, using the `library(<package>)` funct
3939

4040
* `tidyverse`
4141
* `"growthrates"`
42-
* `rstatix`
4342

4443
Custom function with the suffix `EDU` (`<function>_EDU()`) were designed for this tutorial and are combine functions from the package above. For educational purposes details can be found in the "Helper Function" section of this tutorial.
4544

@@ -83,17 +82,24 @@ well_data <- read_csv(system.file("resources/data", "well_information.csv", pack
8382
calc_blank_EDU <- function(dataframe, Media) {
8483
blank_OD <- dataframe %>%
8584
filter(!is.na(Time)) %>%
86-
filter(blank == TRUE, Time == min(.$Time), media == Media ) %>%
87-
summarise(blank_OD = mean(OD600))
85+
filter(blank == TRUE, media == Media ) %>%
86+
summarise(blank_OD = min(OD600))
8887
8988
output <- blank_OD[[1]]
9089
9190
return(output)
9291
}
9392
93+
growth_data <- raw_growth_data %>%
94+
pivot_longer(-c(Time, Temp), names_to = 'well', values_to = 'OD600')
95+
96+
growth_data_info <- right_join(growth_data, well_data, by = 'well') %>%
97+
filter(!is.na(student), !is.na(Time))
9498
```
9599

96-
```{r data_reformating, exercise=TRUE, exercise.setup = "data_reformating_setup"}
100+
The code below shows how the functions described above can be use to reformat `raw_growth_data` into the dataframe that will be used for future analysis.
101+
102+
```{r data_reformating1, exercise=TRUE, exercise.setup = "data_reformating_setup"}
97103
growth_data <- raw_growth_data %>%
98104
pivot_longer(-c(Time, Temp), names_to = 'well', values_to = 'OD600')
99105
@@ -115,10 +121,53 @@ growth_data_MM <- growth_data_info %>%
115121
growth_data_full <- bind_rows(growth_data_LB, growth_data_MM)
116122
```
117123

124+
Use the interactive box below to calculate (as shown above) and display the values of `blank_LB` and `blank_MM` variables.
125+
126+
```{r data_reformating2, exercise=TRUE, exercise.setup = "data_reformating_setup"}
127+
blank_LB <-
128+
print(blank_LB)
129+
130+
blank_MM <-
131+
print(blank_MM)
132+
```
133+
134+
What is the value of `blank_LB`?
135+
136+
```{r blank_LB_check, exercise=TRUE, exercise.setup = "data_reformating_setup"}
137+
138+
```
139+
140+
```{r blank_LB_check-check}
141+
grade_result(
142+
pass_if(~identical(.result, 0.085))
143+
)
144+
```
145+
146+
What is the value of `blank_MM`?
147+
148+
```{r blank_MM_check, exercise=TRUE, exercise.setup = "data_reformating_setup"}
149+
150+
```
151+
152+
```{r blank_MM_check-check}
153+
grade_result(
154+
pass_if(~identical(.result, 0.075))
155+
)
156+
```
157+
158+
```{r letter-a, echo=FALSE}
159+
question("Does the relationship between `blank_LB` and `blank_MM` values make sense?",
160+
answer("No, we would expect values to be identical"),
161+
answer("Yes, LB medium is darker coloured that Minimal medium, so we expect the OD~600~ of LB to be slightly higher", correct = TRUE),
162+
answer("No, Minimal medium is darker coloured that LB medium, so we expect the OD~600~ of MM to be slightly higher"),
163+
answer("We have no way of knowing what these values might be")
164+
)
165+
```
166+
118167
## Plotting Growth Curves
119168
_E. coli_ growth curves represent the optical density of cultures over time. The shape of these curves has been extensively characterized by the scientific community and plotting these curves can help identify irregularities or contamination.
120169

121-
We are generating these plots using the `ggplot2` package, wihich is part of the `tidyverse` library.
170+
We are generating these plots using the `ggplot2` package, which is part of the `tidyverse` library.
122171

123172
```{r plotting_growth_curves_setup}
124173
raw_growth_data <- read_csv(system.file("resources/data", "growth_data.csv", package = "educer"), col_names = TRUE, skip = 12)
@@ -127,8 +176,8 @@ well_data <- read_csv(system.file("resources/data", "well_information.csv", pack
127176
calc_blank_EDU <- function(dataframe, Media) {
128177
blank_OD <- dataframe %>%
129178
filter(!is.na(Time)) %>%
130-
filter(blank == TRUE, Time == min(.$Time), media == Media ) %>%
131-
summarise(blank_OD = mean(OD600))
179+
filter(blank == TRUE, media == Media ) %>%
180+
summarise(blank_OD = min(OD600))
132181
133182
output <- blank_OD[[1]]
134183
@@ -186,16 +235,59 @@ calc_growthrates_EDU <- function(dataframe) {
186235
}
187236
```
188237

189-
```{r plotting_growth_curves, exercise=TRUE, exercise.setup = "plotting_growth_curves_setup"}
238+
The code below generates a graph showing all measured OD~600~ values over time. Using the `filter()` function, modify the code below to show only non-blank samples.
239+
240+
```{r plotting_growth_curves1, exercise=TRUE, exercise.setup = "plotting_growth_curves_setup"}
190241
growth_data_full %>%
191-
filter(!is.na(student), blank == FALSE) %>%
192-
ggplot(aes(x=Time, y=net_OD, color = media, group = media)) +
193-
geom_point(shape=19, size=1)
242+
# filter(blank == FALSE) %>%
243+
ggplot(aes(x=Time, y=net_OD)) +
244+
geom_point() +
245+
labs(x = 'Time (h:m:s)', y = 'OD600')
246+
```
194247

248+
```{r plotting_growth_curves1-solution}
195249
growth_data_full %>%
196-
filter(!is.na(student), blank == TRUE) %>%
197-
ggplot(aes(x=Time, y=net_OD, color = media, group = media)) +
198-
geom_point(shape=19, size=1)
250+
filter(blank == FALSE) %>%
251+
ggplot(aes(x=Time, y=net_OD)) +
252+
geom_point() +
253+
labs(x = 'Time (h:m:s)', y = 'OD600')
254+
```
255+
256+
Now copy the code above into the box below and define the `colour` aesthetic as `media`, in order to differentiate between LB and MM.
257+
258+
```{r plotting_growth_curves2, exercise=TRUE, exercise.setup = "plotting_growth_curves_setup"}
259+
260+
```
261+
262+
```{r plotting_growth_curves2-solution}
263+
growth_data_full %>%
264+
filter(blank == FALSE) %>%
265+
ggplot(aes(x=Time, y=net_OD, colour = media)) +
266+
geom_point() +
267+
labs(x = 'Time (h:m:s)', y = 'OD600')
268+
```
269+
270+
Try modifying the code to show only blank samples and use the `colour` aesthetic as `media`, in order to differentiate between LB and MM.
271+
272+
```{r plotting_growth_curves3, exercise=TRUE, exercise.setup = "plotting_growth_curves_setup"}
273+
274+
```
275+
276+
```{r plotting_growth_curves3-solution}
277+
growth_data_full %>%
278+
filter(blank == TRUE) %>%
279+
ggplot(aes(x=Time, y=net_OD, colour = media)) +
280+
geom_point() +
281+
labs(x = 'Time (h:m:s)', y = 'OD600')
282+
```
283+
284+
```{r growth_data_question, echo=FALSE}
285+
question("Are there any irregularities in the graphs above? (select ALL that apply)",
286+
answer("Only two blank LB wells grew, we would expect to see more"),
287+
answer("The first measurement seems to have given erroneous values", correct = TRUE),
288+
answer("We don't expect to see any growth in the blank wells, but a number seem to have been contaminated", correct = TRUE),
289+
answer("LB and MM growth curves should look the same, as both are E. coli"),
290+
answer("The data looks as expected"))
199291
```
200292

201293
## Calculating Growth Rates
@@ -231,8 +323,8 @@ well_data <- read_csv(system.file("resources/data", "well_information.csv", pack
231323
calc_blank_EDU <- function(dataframe, Media) {
232324
blank_OD <- dataframe %>%
233325
filter(!is.na(Time)) %>%
234-
filter(blank == TRUE, Time == min(.$Time), media == Media ) %>%
235-
summarise(blank_OD = mean(OD600))
326+
filter(blank == TRUE, media == Media ) %>%
327+
summarise(blank_OD = min(OD600))
236328
237329
output <- blank_OD[[1]]
238330

0 commit comments

Comments
 (0)