Newer
Older
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
library(tidyverse)
if (!dir.exists("out_R/summary/stdev")) {
dir.create("./out_R/summary/stdev")
}
if (!dir.exists("out_R/summary/std_err")) {
dir.create("./out_R/summary/std_err")
}
if (!dir.exists("out_R/individual")) {
dir.create("./out_R/individual")
}
## Read in datafile from skimage
d <- read_csv("./skimage_metrics.csv")
## Calculate relative values
rel <- d %>%
group_by(Group, Fish, Genotype) %>%
mutate(across(area:integrated_density, ~ .x/.x[Day == 0]),
Group = fct_recode(Group,
Control = "ctrl",
Cisplatin = "cddp"),
Group = fct_relevel(Group, "Control"),
Fish = as_factor(Fish))
properties <- c("area", "filled_area", "major_axis_length",
"minor_axis_length", "mean_intensity", "integrated_density",
"raw_integrated_density")
## Summary plots
for (prop in properties) {
ggplot(filter(rel, Day < 30), aes_string("Day", prop, fill = "Group")) +
stat_summary(fun = mean, geom = "line") +
stat_summary(fun = mean, geom = "point", shape = 21) +
stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.5) +
geom_hline(aes(yintercept = 1), linetype = "dashed") +
facet_wrap(~ Genotype, nrow = 2)
ggsave(paste0("./out_R/summary/std_err/", prop, ".png"), scale = 0.8)
}
## Individual plots
for (prop in properties) {
ggplot(filter(rel, Genotype == "sw58"), aes_string("Day", prop)) +
geom_line(aes(color = Fish)) +
geom_point(shape = 21, aes(fill = Fish)) +
facet_wrap(~ Group) +
coord_cartesian(ylim = c(0,2))
ggsave(paste0("./out_R/individual/sw58_",prop,".png"), scale = 0.8)
}
for (prop in properties) {
ggplot(filter(rel, Genotype == "sw70"), aes_string("Day", prop)) +
geom_line(aes(color = Fish)) +
geom_point(shape = 21, aes(fill = Fish)) +
facet_wrap(~ Group) +
coord_cartesian(ylim = c(0,2.2))
ggsave(paste0("./out_R/individual/sw70_",prop,".png"), scale = 0.8)
}
## Hypothesis testing
control_area <- rel %>%
filter(Group == "Control",
Genotype == "sw58",
Day == 28) %>%
pull(area)
cddp_area <- rel %>%
filter(Group == "Cisplatin",
Genotype == "sw58",
Day == 28) %>%
pull(area)
p_area_sw58 <- wilcox.test(control_area, cddp_area)$p.value
control_area <- rel %>%
filter(Group == "Control",
Genotype == "sw70",
Day == 28) %>%
pull(area)
cddp_area <- rel %>%
filter(Group == "Cisplatin",
Genotype == "sw70",
Day == 28) %>%
pull(area)
p_area_sw70 <- wilcox.test(control_area, cddp_area)$p.value
control_int_den <- rel %>%
filter(Group == "Control",
Genotype == "sw58",
Day == 28) %>%
pull(integrated_density)
cddp_int_den <- rel %>%
filter(Group == "Cisplatin",
Genotype == "sw58",
Day == 28) %>%
pull(integrated_density)
p_intDen_sw58 <- wilcox.test(control_int_den, cddp_int_den)$p.value
control_int_den <- rel %>%
filter(Group == "Control",
Genotype == "sw70",
Day == 28) %>%
pull(integrated_density)
cddp_int_den <- rel %>%
filter(Group == "Cisplatin",
Genotype == "sw70",
Day == 28) %>%
pull(integrated_density)
p_intDen_sw70 <- wilcox.test(control_int_den, cddp_int_den)$p.value
p_vals <- tibble(Metric = c("Area", "Integrated Density"),
sw58 = c(p_area_sw58, p_intDen_sw58),
sw70 = c(p_area_sw70, p_intDen_sw70))
write_csv(p_vals, "./out_R/p_values.csv")