-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dose response assay plots.Rmd
119 lines (94 loc) · 2.9 KB
/
Dose response assay plots.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
title: "Dose response assay plots"
author: "Emily J Tallerday"
date: "`r Sys.Date()`"
output: github_document
---
# Setup
## Load packages to be used
```{r}
packages <- c("rmarkdown", "pandoc", "formatR", "tidyverse", "gridExtra", "ggpubr", "viridis", "ggthemes", "here", "gplots", "cowplot", "ggtext", "ggsignif", "ggokabeito")
pacman::p_load(char = packages, install = T, character.only = T)
```
## Set ggplot theme
My personal preference:
```{r}
theme_set(theme_light())
```
## Define functions
This section may be empty if functions are not needed.
# Data
## Import
```{r}
BA_response <- read.csv(here(r"(Data\06292023_Eva_BA response data.csv)"))
```
NOTE that this data was provided by Eva from a magenta box BA dose response assay done in Summer 2023.
## Tidy data for easy working
```{r}
BA_response$treatment[BA_response$treatment == "veh"] <- 0
```
```{r}
BA_response$genotype <- as.factor(BA_response$genotype)
```
```{r}
BA_response$treatment <- as.numeric(BA_response$treatment)
```
```{r}
colnames(BA_response) <- c("Genotype", "Conc. BA (ng/uL)", "Shoot length (cm)", "Root length (cm)")
```
# Plot
## Linear regression
The code for the following plot was modified from [this tutorial by datanovia](https://rpkgs.datanovia.com/ggpubr/reference/stat_regline_equation.html).
```{r, echo = F, include=F, dev = "png", dpi = 300}
## This is my messy, working, version. This will not be included in the knit document! Refer to the chunk below, instead.
BA_response %>%
ggplot(aes(x = `Conc. BA (ng/uL)`, y = `Root length (cm)`, color = Genotype, fill = Genotype)) +
geom_point(shape = 21, size = 2, alpha = 0.5, color = "black") +
geom_smooth(method = "lm", se = T, alpha = 0.2) +
facet_wrap(~Genotype,
ncol = 4,
nrow = 1,
scales = "free"
) +
theme(strip.background = element_blank()) +
# stat_cor(#label.y = 8.8,
# #label.x = 10.5,
# color = "black") +
stat_regline_equation( # label.y = 8,
# label.x = 10.5,
color = "black"
) +
labs(
color = "Genotype", # in legend
fill = "Genotype" # in legend
) +
# scale_color_hue(labels = Genotype) + # color variable
# theme(legend.text = element_markdown()) +
scale_color_okabe_ito() +
scale_fill_okabe_ito() %>% # fill variable
suppressWarnings() %>%
suppressMessages()
```
```{r, echo = T, include=T, warning=F, message=F}
BA_response %>%
ggplot(aes(x = `Conc. BA (ng/uL)`, y = `Root length (cm)`, color = Genotype, fill = Genotype)) +
geom_point(shape = 21, size = 2, alpha = 0.5, color = "black") +
geom_smooth(method = "lm", se = T, alpha = 0.2) +
facet_wrap(~Genotype,
ncol = 4,
nrow = 1,
scales = "free"
) +
theme(strip.background = element_blank()) +
stat_regline_equation(color = "black") +
labs(
color = "Genotype",
fill = "Genotype"
) +
scale_color_okabe_ito() +
scale_fill_okabe_ito()
```
# Session info
```{r, include=T, echo=T}
sessionInfo()
```