Giter Site home page Giter Site logo

joey711.github.com's People

Contributors

joey711 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

joey711.github.com's Issues

Top 10 phyla with 10th categorised as 'Other' for stacked relative abundance bar plot

Hi there,

I managed to create a 100% stacked proportional bar chart representing relative abundance of phyla across 3 forest age categories using this code. However, what I want is this relative abundance figure except with only 10 phyla represented, including the 9 most abundant phyla and a 10th category merging all the remaining taxa.

Here's my code so far, where Bacteria_physeq is my phyloseq object and age.category is the variable of interest:

remove OTUs with no assigned phylum

cleaned_phyla = subset_taxa(Bacteria_physeq, Phylum!="NA" & Phylum!="")
cleaned_phyla
otu_table() OTU Table: [ 17566 taxa and 19 samples ]
sample_data() Sample Data: [ 19 samples by 6 sample variables ]
tax_table() Taxonomy Table: [ 17566 taxa by 7 taxonomic ranks ]

melt phyloseq object to use with ggplot2

Bacteriaphyseq <- psmelt(cleaned_phyla)

plot stacked bar plot for % relative abundance

barstackprop <- ggplot(Bacteriaphyseq, aes(x = age.category, y = Abundance, fill = Phylum)) +
geom_bar(position = "fill",stat = "identity") +
scale_y_continuous(labels = scales::percent_format()) +
labs(x = "Age category", y = "Relative abundance")
plot(barstackprop)

Screen Shot 2021-09-27 at 10 54 01 AM

As you can see, there are far too many colours and phyla represented.

I've tried a couple of tutorials and other forum recommendations but can't seem to get it to work for what I want to achieve here. Any help would be really useful.

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.