Loading the libraries
library(reshape2)
library(ggplot2)
Loading the table onto R
data1 <- read.csv("summary_otu_count_for_boxplot.csv")
attach(data1)
The following objects are masked from data1 (pos = 3):
gg.closed, gg.denovo, gg.open, silva.closed, silva.denovo, silva.open
The following objects are masked from data1 (pos = 4):
gg.closed, gg.denovo, gg.open, silva.closed, silva.denovo, silva.open
names(data1)
[1] "silva.closed" "gg.closed" "silva.denovo" "gg.denovo" "silva.open"
[6] "gg.open"
Here’s what the table contains:
data1
Generating a basic boxplot
ggplot(melt(data1), aes(variable, value)) + geom_boxplot()
No id variables; using all as measure variables
Adding some colour, axes labels and a legend
ggplot(melt(data1), aes(variable, value)) +
geom_boxplot(aes(color=factor(variable))) +
theme_bw() +
theme(legend.text = element_text(size = 9), legend.title = element_text(size = 9)) +
theme(axis.text = element_text(size = 9)) +
theme(axis.title = element_text(size = 9)) +
labs(x = "OTU picking method", y = "Observed OTU count",colour = "legend") +
annotation_logticks(sides = "rl") +
theme(panel.grid.minor = element_blank()) +
guides(title.hjust = 1.0) +
theme(plot.margin = unit(c(0,1,0,0),"mm"))
No id variables; using all as measure variables
Putting in a fill colour instead
ggplot(melt(data1), aes(variable, value)) +
geom_boxplot(aes(fill = variable)) +
theme_bw() +
theme(legend.text = element_text(size = 9), legend.title = element_text(size = 9)) +
theme(axis.text = element_text(size = 9)) +
theme(axis.title = element_text(size = 9)) +
labs(x = "OTU picking method", y = "Observed OTU count",colour = "legend") +
annotation_logticks(sides = "rl") +
theme(panel.grid.minor = element_blank()) +
guides(title.hjust = 1.0) +
theme(plot.margin = unit(c(0,1,0,0),"mm"))
No id variables; using all as measure variables
LS0tDQp0aXRsZTogIkRyYXdpbmcgYSBib3hwbG90IGZvciBvYnNlcnZlZCBPVFUgY291bnQgdnMgT1RVIHBpY2tpbmcgbWV0aG9kIg0Kb3V0cHV0Og0KICBodG1sX25vdGVib29rOiBudWxsDQogIGh0bWxfZG9jdW1lbnQ6DQogICAgZGZfcHJpbnQ6IHBhZ2VkDQog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