Potential new function (ord_explore_top_taxa) #19
Replies: 2 comments 2 replies
-
Hi 🙂 Very nice idea Vitor, thanks for sharing, and thanks for the comprehensive explanation. I think making a standalone function for this would be a better place to start than directly adding to ord_explore. This new dominance variable could then be used for the colour or shape aesthetic in ord_explore like any other variable. If you pre-calculated multiple variables (e.g. with different thresholds and ranks) you could flip through them interactively in ord_explore, with no additions to ord_explore itself. I'm reluctant to add more buttons and boxes to the Shiny side panel until i can make everything a little more compact. I had a think about what this function could look like and wrote some code below (not tested, but probably almost works):
aggregate taxa at chosen rank for calculation get otu table with taxa as cols calculate necessary features: min threshold of dominance maximum value per sample index of most abundant taxon per sample name of most abundant taxon per sample is sample dominated? get dominant taxon or "none" use only up to top n_max number of taxa names (this bit is probably suboptimally implemented) count how many times each taxon is most abundant
Add new variable to original phyloseq and return Next steps: If you want to write this up as a new function, with examples of use, and make a pull request (or otherwise share it here again) that would amazing. |
Beta Was this translation helpful? Give feedback.
-
FYI, using this new function
|
Beta Was this translation helpful? Give feedback.
-
Hi,
My name is Vitor, I am PhD student from Brazil. First of all, thank you very much for this nice R package!
I've been recently working with microbiome ordination and one thing that is important for a research project I've been working on is to be able to observe the most important taxon for a given sample on an ordination plot. Lately, I wrote some simple code that was able to do this, but the plot was static. Thanks to the great
ord_explore()
, I was able to make this interactive. That is, usingord_explore()
implementation as backbone, I wrote a function (Shiny app) that I dubbedord_explore_top_taxa()
which shows the most important taxon (highest relative abundance) for each sample on a ordination plot:The plots are interactively customizable via the following parameters:
tax_rank
: taxonomic level of interesttop_taxa_threshold
: minimum relative abundance of a taxon for it to be considered a "top taxon" (for instance, 30%, often used to define dominance)n_top_taxa
: the number of "top taxa" to be shown in the legend. Then_top_taxa
most frequent top taxa will be shown. The less frequent top taxa will be collapsed to "Other"Other details:
@david-barnett, I am sure there is a lot of ways to make this function more efficient, so please feel free to make changes so that it can eventually end up in the microViz R package. We can also make this a new feature for
ord_explore()
instead of a whole new function. Anyway, if you think that any part of this idea is useful for microViz users, let me know how I can help.Cheers,
Vitor
Beta Was this translation helpful? Give feedback.
All reactions