Skip to content

Instantly share code, notes, and snippets.

@gjuggler
Last active December 11, 2015 02:58
Show Gist options
  • Save gjuggler/4534173 to your computer and use it in GitHub Desktop.
Save gjuggler/4534173 to your computer and use it in GitHub Desktop.
A demonstration of functionality included in the phyloseq pull request.
library(devtools)
load_all('phyloseq', reset=T)
data(GlobalPatterns)
x <- subset_species(GlobalPatterns, Phylum == "Chlamydiae")
png(file="01_ladderize_left.png")
p <- plot_tree(x, color="SampleType", label.tips="Genus", size="abundance",
ladderize='left')
print(p)
dev.off()
png(file="02_ladderize_right.png")
p <- plot_tree(x, color="SampleType", label.tips="Genus", size="abundance",
ladderize='right')
print(p)
dev.off()
png(file="03_lots_of_space.png")
p <- plot_tree(x, color="SampleType", label.tips="Genus", size="abundance",
ladderize='right', plot.margin=1.5)
print(p)
dev.off()
library(ggplot2)
png(file="04_brewer_colors.png")
p <- plot_tree(x, color="SampleType", label.tips="Genus", size="abundance",
ladderize='right', plot.margin=1.5, color.scale = scale_colour_brewer(palette="Set1"))
print(p)
dev.off()
library(ggplot2)
# Create a manual color scale. Will throw an error if you don't provide as many
# colors as are needed by the plot!
manual.colors <- scale_colour_manual(values=c('red', 'green', 'blue', 'orange', 'purple', 'gray', 'pink', 'yellow'))
png(file="05_manual_colors.png")
p <- plot_tree(x, color="SampleType", label.tips="Genus", size="abundance",
ladderize='right', plot.margin=1.5, color.scale = manual.colors
)
print(p)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment