Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotting categorical values along with numeric values #36

Open
Valentin-Bio opened this issue Mar 8, 2023 · 0 comments
Open

plotting categorical values along with numeric values #36

Valentin-Bio opened this issue Mar 8, 2023 · 0 comments

Comments

@Valentin-Bio
Copy link

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:

image

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:

image

and the counts table pero each bacteria taxonomic rank

image

Is there a way to plot the abundance per each bacteria ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant