Code Monkey home page Code Monkey logo

Comments (6)

david-barnett avatar david-barnett commented on June 14, 2024

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.

david-barnett avatar david-barnett commented on June 14, 2024

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.

estebannieto93 avatar estebannieto93 commented on June 14, 2024

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.

david-barnett avatar david-barnett commented on June 14, 2024

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.

david-barnett avatar david-barnett commented on June 14, 2024

now more info added on this topic to https://david-barnett.github.io/microViz/articles/web-only/compositions.html

from microviz.

estebannieto93 avatar estebannieto93 commented on June 14, 2024

Thanks a lot for the answer! the package is very useful

from microviz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.