FROGS Phyloseq: Structure Visualization

Phyloseq 1.24.2

Ordination plot




Heatmap plot


R code

Loading packages & data

library(phyloseq)
source("https://raw.githubusercontent.com/mahendra-mariadassou/phyloseq-extended/master/load-extra-functions.R")
#if you want to generate interactiv plot, load plotly and use ggplotly() instead of plot()
#library(plotly)

#if in new session
#data <- path to Rdata file containing phyloseq object
#load(data)
#distance <- path to tsv file containing beta diversity distance matrix to use
# A <- read.table(file=distance, row.names=1)
# dist <- as.dist(A)

Ordianation plots

ord <- ordinate(data, method ="MDS", distance = dist)
p1 <- plot_ordination(data, ord, color = "EnvType") + theme_bw() + ggtitle("MDS")+ theme(plot.title = element_text(hjust = 0.5))
plot(p1)
p2 <- plot_samples(data, ord, color = "EnvType") + theme_bw()+ ggtitle("MDS")+ theme(plot.title = element_text(hjust = 0.5))
plot(p2)
p22 <- p2 +  stat_ellipse(aes(group = EnvType))
plot(p22)

Heatmap plot

# change heatmap color scale with color name or hexadecimal code. see http://tools.medialab.sciences-po.fr/iwanthue/ 
lowCol <- "#ffff00" # yellow
midCol <-  "#ffa500" # orange
highCol <- "#ff0000" # red
naCol <- "white" # white!
p3 <- plot_heatmap(data) + scale_fill_gradient2(low = lowCol, mid = midCol, high = highCol, na.value = naCol, trans = log_trans(4), midpoint = log(100, base = 4))+ facet_grid(~EnvType, scales = "free_x") + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Heatmap plot")
plot(p3)