Comments (6)
Hi!
Firstly thanks for complement, glad you're finding microViz useful 😄
Just to check I understand what you are asking about: You would like the order of the taxa in each bar (each sample) to be dependent on the abundance of each taxon in only that sample. The fill colour of taxa should be consistent across samples, so they can share a single colour legend.
Is that right?
If so, that's quite tricky, I think. As within one ggplot, the order in which bars are stacked is consistent, as it depends on the underlying ordering of the grouping variable's values.
If you don't have that many samples, you could probably achieve this by making one plot per bar and sticking them together with patchwork or cowplot. Keep the colours consistent by specifying a fixed palette using tax_palette
from microviz.
Approximately how many samples do you have, and how variable are their compositions? would the top 10 taxa vary wildly between samples, or just their order? My suspicion is that if you have a lot of samples, allowing the bar stacking order to vary by sample might end up looking chaotic.
Interesting question though, thank you 🙂
from microviz.
Hi
I have a related question, I want to plot the all the taxa that have higher relative abundance than 3% in at least one gruop of samples,. How can I do that?
from microviz.
One way could be:
-
aggregate your phyloseq taxa to the desired level for your plot. With tax_agg (probably you need to run tax_fix first)
-
make new filtered copies of the phyloseq one per group, using ps_filter(groupvar== 'level1') etc
-
filter the taxa in each one of those new phyloseq objects, with tax_filter(min_prevalence = 0.03)
-
get the names of the taxa from each phyloseq with tax_top or taxa_names
-
get the union() of all these names
-
set a colour palette vector with tax_palette, using the union of the names
-
use your first phyloseq (all samples) to make the barplot, using the tax_palette you just created
Hope this helps, wrote it on my phone on the train so some details might not be exactly right
from microviz.
now more info added on this topic to https://david-barnett.github.io/microViz/articles/web-only/compositions.html
from microviz.
Thanks a lot for the answer! the package is very useful
from microviz.
Related Issues (20)
- comp_barplot of raw abundances HOT 2
- some GUSTAME site links have changed HOT 1
- Logical variable becomes numeric when plotting CCA HOT 2
- how can i order my samples and show their names? HOT 3
- Cannot build PCoA plot using ord_plot HOT 2
- dominant taxa in each sample HOT 2
- phylogenetic tree disappeared after tax_transform() step HOT 2
- Annotated heatmaps - error in sample_anno HOT 4
- Taxa cannot be aggregated at rank: Genus HOT 2
- cor_heatmap taxon_renamer or alternative option for labeling rows HOT 3
- comp_barplot seem to have issues with domain being unknown HOT 2
- Error in access(object, "otu_table", errorIfNULL) : otu_table slot is empty. HOT 2
- Strange behaviour when using comp_barplot with facet_grid HOT 2
- tax.fix(), and "Problematic Genus values detected in tax_table" HOT 3
- [FR] Add sankey/alluvial plots to visualize abundances HOT 2
- Tax_fix no non-unknown values HOT 1
- Labelling samples in ord_plot PCoA HOT 1
- Use of custom transofmration in linear models. HOT 1
- Can I make a correlation heatmap between taxa and categorical variable? HOT 1
- comp_barplot reduce/remove space between axes and bars HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microviz.