metacoder
metacoder copied to clipboard
Show relative abundance instead of n_obs
How can I show in the relative abundances for each taxa in the phylogenetic map instead of the number of observations (n_obs)?
Hello @mhmism, sorry for the delay.
You have to use something like calc_taxon_abund
to add up the abundance per OTU for each taxon. Look at this example:
https://grunwaldlab.github.io/metacoder_documentation/example.html#getting-per-taxon-information
and also at the examples in the help of "calc_taxon_abund":
library(metacoder)
?calc_taxon_abund
Let me know if you have questions
Hello @mhmism, sorry for the delay.
You have to use something like
calc_taxon_abund
to add up the abundance per OTU for each taxon. Look at this example:https://grunwaldlab.github.io/metacoder_documentation/example.html#getting-per-taxon-information
and also at the examples in the help of "calc_taxon_abund":
library(metacoder) ?calc_taxon_abund
Let me know if you have questions
Thanks @zachary-foster for your answer,
and in that case what would I use instead of n_obs in node_size = n_obs, in order to show nodes size according to relative abundances?
That depends on how you do it. You will be using the contents of a column or the name of that column that contains per-taxon information. For example:
library(metacoder)
ex_taxmap$data$tax_count <- calc_taxon_abund(ex_taxmap, "abund", cols = c("count"))
heat_tree(ex_taxmap, node_label = taxon_names, node_size = ex_taxmap$data$tax_count$count, node_color = n_obs)
In this case, you have to use ex_taxmap$data$tax_count$count
instead of count
because there is another table with a column named count
, so the function cannot tell which you mean. However, if you give it a unique name, you can do it this way:
ex_taxmap$data$tax_count <- calc_taxon_abund(ex_taxmap, "abund", cols = c("count"), out_names = c("count2"))
heat_tree(ex_taxmap, node_label = taxon_names, node_size = count2, node_color = n_obs)