-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathanalysis of multiple beta-gal experiments.Rmd
94 lines (67 loc) · 3.09 KB
/
analysis of multiple beta-gal experiments.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
title: "R Notebook"
output:
html_document:
df_print: paged
---
This code imports, analyzes, and plots data from a multiple replcicates of beta-galactosidase assays. This analysis is for experiments examining beta-galactosidase activity as a function of RpoS level.
Before running this code, you must have followed the directions and run the code in `analysis of single beta-gal experiment.Rmd` on every file you intend analyze here.
```{r, message=FALSE}
library(readxl)
library(tidyverse)
source("betaGalAnalysisFunctions.R")
theme_set(theme_classic())
fileNames <- c("sampleData/6-6-18 LB32_LB73.xlsx","sampleData/6-6-18 LB32_LB73 fake data for testing.xlsx")
processedFiles <- map(fileNames, meanExpressionOneReplicate)
combinedData <- bind_rows(processedFiles)
```
```{r}
ggplot(combinedData) + geom_point(aes(x=RpoS, y=meanExpression)) + facet_grid(.~strain)
```
Plot mean ± SE for each RpoS level
```{r}
dayMeans <- combinedData %>%
group_by(strain, RpoS) %>%
summarise(meanAcrossDays = mean(meanExpression), sdAcrossDays = sd(meanExpression)/sqrt(length(meanExpression))) %>%
mutate(upperErrorBar = meanAcrossDays + sdAcrossDays, lowerErrorBar = meanAcrossDays - sdAcrossDays)
ggplot(dayMeans) +
geom_point(aes(x = RpoS, y = meanAcrossDays)) +
geom_errorbar(aes(x = RpoS, y = meanAcrossDays, ymax = upperErrorBar, ymin = lowerErrorBar)) +
facet_grid(.~strain)
```
##Sensitivity
This section is specific for analyzing the sensitivity of a promoter. It requires three RpoS levels.
This function expects three RpoS levels, so for this example I'll subset out some, since we have five.
```{r}
dataForSensitivity <- combinedData %>%
filter(RpoS == 0 | RpoS == 19 | RpoS == 94)
```
Calculate sensitivity of a promoter.
```{r}
sensitivities <- dataForSensitivity %>%
group_by(strain, date, experimenter) %>%
summarise(sensitivity = calculateSingleSens(RpoS, meanExpression))
```
Plot the data with a line to illustrate null expectation used to assess sensitivity.
```{r}
segmentEnds <- dayMeans %>%
filter(RpoS == 0 | RpoS == 94) %>%
group_by(strain) %>%
summarise(
RpoS_min = min(RpoS),
RpoS_max = max(RpoS),
expression_min = min(meanAcrossDays),
expression_max = max(meanAcrossDays)
)
```
If you designed your experiment with only three RpoS levels, delete the the `filter` step. Note that we have to go back a step to use use the `dayMeans` tibble.
```{r}
dayMeans %>%
filter(RpoS == 0 | RpoS == 19 | RpoS == 94) %>%
ggplot() +
geom_point(aes(x = RpoS, y = meanAcrossDays, size = 4), show.legend = FALSE) +
geom_errorbar(aes(x = RpoS, y = meanAcrossDays, ymax = upperErrorBar, ymin = lowerErrorBar)) +
facet_grid(.~strain) +
geom_segment(data = segmentEnds, mapping = aes(x = RpoS_min, xend = RpoS_max, y = expression_min, yend = expression_max)) +
labs(x = "% of wild-type RpoS", y = "LacZ expression (Miller Units)")
```