Skip to contents

This article focuses on visualization methods that directly consume a microbiome_dataset. These functions cover the plots that are routinely used for abundance summaries, diversity, ordination, and phylogenetic context.

library(microbiomedataset)

data("global_patterns", package = "microbiomedataset")

object <- global_patterns

Composition and abundance

plot_composition(
  object = object,
  taxonomic_rank = "Phylum",
  top_n = 8,
  x = "SampleType"
)

Stacked barplot of phylum-level composition across sample types.

plot_abundance(
  object = object,
  taxonomic_rank = "Phylum",
  x = "SampleType",
  top_n = 6
)

Faceted abundance distributions for top phyla across sample types.

Heatmap, prevalence, and sample depth

plot_heatmap(
  object = object,
  taxonomic_rank = "Phylum",
  top_n = 10,
  sample_label = "SampleType"
)

Heatmap of top phyla across samples with clustered taxa and sample labels.

plot_prevalence(
  object = object,
  taxonomic_rank = "Phylum",
  top_n = 10
)

Horizontal barplot of prevalence for dominant phyla.

plot_sample_depth(
  object = object,
  x = "SampleType"
)

Sample sequencing depth grouped by sample type.

plot_rarefaction(
  object = object,
  steps = 8,
  color_by = "SampleType"
)

Rarefaction curves showing expected richness across sequencing depth.

Diversity and ordination

alpha_result <- calculate_alpha_diversity(object, metric = "shannon")
plot_alpha_diversity(alpha_result, x = "SampleType")

Alpha diversity boxplot by sample type.

ordination_result <- run_ordination(object, method = "PCoA")
plot_ordination(ordination_result, color_by = "SampleType")

PCoA ordination colored by sample type.

Trees

tree_object <- align_tree(object, tree = "taxa_tree")
plot_tree(tree_object, tree = "taxa_tree")

Taxonomy tree for the microbiome dataset.

plot_tree_link(tree_object, tree = "taxa_tree")

Coverage plot showing explicit links between taxa and tree nodes.

The same microbiome_dataset object can now drive most of the standard microbiome figures directly, without converting into another plotting-specific container first. For interactive trees, pathway-level displays, and mixed-effect result views, see the advanced visualization article.