Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
tiff_exp <- paste0("community_tax_abund_heatmap_", group, "_", taxgroup, "_samples_.tiff")
ggsave(file = tiff_exp, dpi = 300, compression = "lzw", device = "tiff", plot = p, width = 20, height = 20, units = "cm")
pdf_exp <- paste0("community_tax_abund_heatmap_", group, "_", taxgroup, "_samples_.pdf")
ggsave(file = pdf_exp, device = "pdf", plot = p, width = 20, height = 20, units = "cm")

Box and whisker plots

This section contains B&W plots for each taxonomic level (class - species) for your selected variable. This is similar to the heatmaps you generated in section 6, but separates the B&W into groups per variable, thus enabling an examination of how the variable groups differ in terms of taxonomic abundance.

Again, there are a variety of attributes you can modify:

Note the tax_show = 7 attribute. This says to show the top 7 taxa (Tip: to look at specific taxa you can provide a vector of taxa names, e.g. tax_show = c("Bacteroidales", "Fibrobacterales")).

The tax_add = NULL adds an additional taxonomic group to the taxa names (e.g. changing this to tax_add = "Phylum" and plotting Genus will name the taxa as 'phylum:genus' but leaving it as tax_add = NULL will just give the genus name.

Generate the plot:

Code Block
p <- amp_boxplot(ampvisdata, tax_show = 7, tax_add = NULL, tax_aggregate = taxgroup, tax_empty = "remove", group_by = group)
p

You can change additional properties of the plot here:

Code Block
p$mapping$fill <- as.name(".Group")
p <- p + theme_bw() +
scale_color_manual(values=c("Red", "Green", "Blue")) + scale_fill_manual(values=c("Red", "Green", "Blue")) +
labs(fill = group, x = taxgroup) +
theme(text = element_text(size = 18), axis.text.x = element_text(size=18), axis.text.y = element_text(size=16)) +
guides(color = "none")
p

Export as pdf and tiff

Code Block
tiff_exp <- paste0("community_tax_abund_BW_", group, "_", taxgroup, "_samples_.tiff")
ggsave(file = tiff_exp, dpi = 300, compression = "lzw", device = "tiff", plot = p, width = 20, height = 20, units = "cm")
pdf_exp <- paste0("community_tax_abund_BW_", group, "_", taxgroup, "_samples_.pdf")
ggsave(file = pdf_exp, device = "pdf", plot = p, width = 20, height = 20, units = "cm")