de_summary |>
select(12:14) |>
gather(strain, de, -changes) |>
mutate(strain = str_remove(strain, "de_")) |>
group_by(strain, de, changes) |>
summarise(n = n()) |>
mutate(group = de) |>
to_lodes_form(axes = 1:3, key = "de") |>
mutate(stratum = factor(stratum,
levels = c(names(color_strain[2:3]),
names(color_de),
names(color_changes)))) |>
ggplot(aes(x = de,
y = n,
stratum = stratum,
alluvium = alluvium,
fill = group)) +
geom_flow(width = 0.4, alpha = 0.2) +
geom_stratum(stat = "stratum",
aes(fill = after_stat(stratum),
color = "#FFFFFF",
alpha = after_stat(stratum))) +
scale_fill_manual(values = c(color_strain[2:3],
color_de,
color_changes)) +
scale_color_manual(values = "#FFFFFF") +
scale_alpha_manual("stratum", values = c(0.7, 0.7, rep(1, 14))) +
geom_text(stat = "stratum",
aes(label = after_stat(c("sZJD28",
"sZJD23",
"Up Hs",
"Up Ls",
"Ns",
"Down Ls",
"Down Hs",
"Ns sZJD23 & Up sZJD28",
"Up sZJD23 & Ns sZJD28",
"Up sZJD23 & Up sZJD28",
"Up sZJD23 & Down sZJD28",
"Ns sZJD23 & Ns sZJD28",
"Down sZJD23 & Up sZJD28",
"Down sZJD23 & Down sZJD28",
"Ns sZJD23 & Down sZJD28",
"Down sZJD23 & Ns sZJD28"))),
hjust = c(rep("center", 7), rep("left", 9)),
nudge_x = c(rep(0, 7), rep(0.2, 9)),
color = rep("#000000", 16),
size = rep(2, 16),
fontface = "bold") +
geom_text(stat = "stratum",
aes(label = after_stat(ifelse(str_detect(stratum, " & "), count/2, count))),
nudge_x = -0.2,
hjust = "right",
size = 2) +
scale_x_discrete(labels = c("strain" = "Strain",
"de" = "DE",
"changes" = "Changes"),
expand = c(0.02, 0.25, 0, 0.75)) +
labs(x = "",
fill = "",
color = "",
tag = "A.",
caption = str_glue("Ls: Low significant (0.01 > fdr \u2264 0.05)\n",
"Hs: High significant (fdr \u2264 0.01)\n",
"Ns: No significant (fdr > 0.05)")) +
theme_minimal() +
theme(legend.position = "none",
panel.grid.major.y = element_blank(),
axis.title.y = element_blank(),
axis.line.y = element_blank(),
axis.ticks.y = element_blank(),
axis.text.y = element_blank(),
plot.caption.position = "plot",
plot.caption = element_text(hjust = 0),
plot.tag = element_text(face = "bold"),
text = element_text(size = 10))