library(tidyverse)
library(viridis)
#> Loading required package: viridisLite
first <- tribble(~SampleID, ~Abundance,
"A", 0.083,
"B", 0.083,
"C", 0.083,
"D", 0.083,
"E", 0.083,
"F", 0.083,
"G", 0.083,
"H", 0.083,
"I", 0.083,
"J", 0.083,
"K", 0.083,
"L", 0.083) %>%
mutate(Class = "First")
downstream <- tribble(~SampleID, ~Abundance,
"A", 0.25,
"E", 0.25,
"I", 0.25,
"J", 0.25) %>%
mutate(Class = "Downstream")
pal <- viridis(4)
maps <- tibble(labels = LETTERS[1:12],
colors = case_when(labels == "A" ~ pal[1],
labels == "E" ~ pal[2],
labels == "I" ~ pal[3],
labels == "J" ~ pal[4],
TRUE ~ "Grey50")) %>%
mutate(order = ifelse(colors == "Grey50", 2, 1)) %>%
arrange(order, labels)
values <- set_names(maps$colors, maps$labels)
plot_data <- bind_rows(first, downstream) %>%
mutate(SampleID = factor(SampleID, maps$labels),
Class = factor(Class, c("First","Downstream"))) %>%
arrange(Class, SampleID)
ggplot(plot_data, aes(x = Class, y = Abundance, fill = SampleID, group = Class)) +
geom_col() +
scale_fill_manual("Legend", values = values, breaks = LETTERS[1:12])
Создано в 2018-11-27 с помощью пакета представительства (v0.2.1)