plotting categorical values along with numeric values
Valentin-Bio opened this issue · 0 comments
Hello developer! I'm working with microbial abundance data. I used ggsankey to plot the number of bacteria classified under different taxonomic ranks. I was following this tutorial: https://r-charts.com/flow/sankey-diagram-ggplot2/ . So I used as input a taxonomy table:
column name: Domain | phylum | class | order | family | genus | species|
So what I did is to convert this data frame to the required data input format by using make_long()
function over the taxonomy table:
tableforsankey <- taxa_table %>%
make_long(Domain, Phylum, Class, Order, Family, Genus, Species)
and finally made the sankey plot
bac_sankey <- ggplot(tableforsankey,
aes(x = x,
next_x = next_x,
node = node,
next_node = next_node,
fill = factor(node),
label = node)) +
geom_sankey(flow.alpha = 0.75, node.color = 1) +
geom_sankey_label(size = 2.2, color = 1, fill = "white") +
scale_fill_viridis_d() +
theme_sankey(base_size = 16) +
theme(legend.position = "none", axis.text = element_text(size = 7)) +
xlab("")
and I got a nice looking sankey plot:
This is perfect but now I would like to plot the abundance per each bacteria under different taxonomic ranks.
I have two tables:
taxonomy table:
and the counts table pero each bacteria taxonomic rank
Is there a way to plot the abundance per each bacteria ?