-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrowthcurve_plotter.R
57 lines (52 loc) · 1.64 KB
/
Growthcurve_plotter.R
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
all_data <- fread("Growthcurves/Initial_growthcurves.tsv")
median_dose <- all_data %>%
pull(Imipenem) %>%
median()
range_summary <- function(x) {
data.frame(
ymin = min(x),
ymax = max(x)
)
}
custom_palette <- viridis(6, option = "D")[-8]
ggplot(
all_data %>%
filter(followup %like% "Moved") %>%
mutate(
Hours = Seconds / 3600,
Organism = paste0("*", Organism, "*"),
),
aes(
x = Hours, y = OD600,
group = interaction(Imipenem, Induced)
)
) +
scale_y_log10() +
stat_summary(fun = mean, geom = "line", aes(color = factor(Imipenem), linetype = factor(Induced)), linewidth = 0.75) +
stat_summary(fun.data = range_summary, geom = "ribbon", aes(fill = factor(Imipenem)), alpha = 0.6) +
labs(
x = "Time (hours)",
y = "Growth (OD<sub>600</sub>)",
color = "Imipenem",
linetype = "Induced", fill = "Imipenem"
) +
scale_linetype_manual(values = c("FALSE" = "dashed", "TRUE" = "solid")) +
scale_color_discrete(guide = guide_legend(row = ncol)) +
facet_grid(Induced ~ Organism) +
# use viridis color palette
scale_color_manual(values = custom_palette) +
scale_fill_manual(values = custom_palette) +
theme_minimal() +
theme(
legend.title = element_markdown(),
plot.title = element_markdown(),
strip.text.y = element_text(angle = 0),
strip.text = element_markdown(size = 20),
# change the size of the y-axis text
axis.text.y = element_text(size = 16),
# change the size of the x-axis text
axis.text.x = element_text(size = 16),
# element markdown in axis labels
axis.title = element_markdown(size = 20),
axis.title.y = element_markdown(size = 20)
)