Giter Site home page Giter Site logo

biomehue's Introduction

BiomeHue

Logical colour schema for bacterial microbiota (16S and metagenomic) barplots. Uses similar colours for phylogenetically similar taxa. I primarily built this for my own use to make it simpler to reuse the same colour palette across multiple datasets, however it may prove useful to others. Currently several species within the same genus/family may have the same colour assigned.

Installation

library(devtools)
install_github("feargalr/biomehue")
library(BiomeHue)

Usage

BiomeHue contains two simple functions First to return all colours in the primary BiomeHue

biomeHue_palette()

Second to provide a list of taxa

my_colors = biomeHue(taxa=c("Bifidobacterium","Akkermansia","Veillonella_atypica","Muribaculaceae"))

# Example usage with ggplot2
ggplot(data.df, aes(x = Sample, y = value, fill = Taxa)) + geom_bar(stat = "identity")+
  scale_fill_manual(values=my_colors)+theme_classic()

Example below plots with ggplot2 using test data.

library(ggplot2)
library(reshape)

library(BiomeHue)

## Melt data into long format 
counts.df = melt(BiomeHue_test.df) #BiomeHue test data included with R library
counts.df$Taxa = counts.df$variable

## Extract data frame with colours
biomeHue.df = biomeHue(taxa = counts.df$Taxa)

## Reorders taxa to group by ordered alphabetically, first by phylum and second by taxon. 
biomeHue.df = biomeHue.df[order(biomeHue.df$Phylum),]
counts.df$Taxa = factor(counts.df$Taxa,levels=biomeHue.df$Taxon) 

## plot with ggplot2
ggplot(counts.df, aes(x = Sample, y = value, fill = Taxa)) + geom_bar(width=0.7,stat = "identity")+
  ylab("Relative Abundance (%)")+
  theme_classic()+
  theme(legend.text = element_text(face = "italic"))+
  scale_fill_manual(values=biomeHue.df$Colour,name="Taxa",breaks=biomeHue.df$Taxon,
                    labels = gsub("_"," ",biomeHue.df$Taxon))

BiomeHue

biomehue's People

Contributors

feargalr avatar

Watchers

 avatar

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.