This work - Orchestrating Microbiome Analysis with Bioconductor(Borman et al. 2026) - contributes novel methods and educational resources for microbiome data science. It aims to teach the grammar of Bioconductor workflows in the context of microbiome data science. We show, through concrete examples, how to use the latest developments and data analytical strategies in R/Bioconductor for the manipulation, analysis, and reproducible reporting of hierarchical, heterogeneous, and multi-modal microbiome profiling data. The data science methodology is tightly integrated with the broader R/Bioconductor ecosystem. The support for modularity and interoperability is key to efficient resource sharing and collaborative development both within and across research fields.
Bioconductor is a project that focuses on the development of high-quality open research software for life sciences (Gentleman et al. 2004; Huber et al. 2015). The software packages are primarily coded in R, and they undergo continuous testing and peer review to ensure high quality.
Bioconductor: Open software development for computational biology and bioinformatics. Gentleman et al. (2004). Genome Biol 5:R80. doi:10.1186/gb-2004-5-10-r80.
Orchestrating high-throughput genomic analysis with Bioconductor. Huber et al. (2015). Nat Methods 12:115–121. doi:10.1038/nmeth.3252.
Central to the software in Bioconductor are data containers, which provide a structured presentation of data. A data container consists of slots that are dedicated to a certain type of data, for example, to the abundance table and the sample metadata. Biological data is often complex and multidimensional, making data containers particularly beneficial. There are several key advantages to using data containers:
Ease of handling: Data subsetting and bookkeeping become more straightforward.
Development efficiency: Developers can create interoperable methods, knowing the data will be in a consistent format.
User accessibility: Users can apply complex methods to their data with ease.
The most common data container in Bioconductor is SummarizedExperiment. It is further expanded to fulfill the needs of certain application fields. SummarizedExperiment and its derivatives have already been widely adopted in microbiome research, single cell sequencing, and in other fields, allowing rapid adoption and the extension of emerging data science techniques across application domains. See Section 2.1 for more details on how to handle data containers from the SummarizedExperiment family.
The Bioconductor microbiome data science framework consists of:
Data containers, designed to organize multi-assay microbiome data
R/Bioconductor packages that provide dedicated methods
Community of users and developers
These components build on each other (Figure 1.1).
Figure 1.1: Data containers are central in Bioconductor.
If you are new to R or Bioconductor, the following Carpentries lessons, contributed by Bioconductor, provide the basic background:
Whereas the term microbiota has been used to refer to microorganisms within a well-specified area, microbiome brings in the functional aspects (Marchesi and Ravel 2015). Because of the complex nature of the microbiome data, computational methods are essential in this research area. The common tasks include upstream processing of original measurement data, and downstream analysis that integrates the measurements with rich background information of the microbial organisms and their hosts.
The vocabulary of microbiome research: A proposal. Marchesi et al. (2015). Microbiome 3. doi:10.1186/s40168-015-0094-5.
phyloseq: An R package for reproducible interactive analysis and graphics of microbiome census data. McMurdie et al. (2013). PLoS One 8:e61217. doi:10.1371/journal.pone.0061217.
This book focuses on the downstream analysis, where tabular data analysis is a major data science paradigm. In microbiome research, it deals with abundance tables of taxonomic, functional, and other profiles that can be presented as feature matrices. These are then linked to further side information such as sample metadata and phylogenetic trees. The phyloseq microbiome data container has been dominant within R/Bioconductor over the past decade (McMurdie and Holmes 2013). However, it was originally developed for 16S amplicon sequencing data and no longer adequately meets the current needs. For instance, the phylogenetic resolution has substantially increased with new metagenomics technologies, and incorporating diverse multi-omics datasets has become increasingly common.
An optimal data container (Figure 1.2) should efficiently store and manage large volumes of data, including modified or transformed copies of the data tables. Furthermore, it should seamlessly integrate into the broader ecosystem of Bioconductor, minimizing duplication of effort and facilitating interoperability with other tools and packages.
Figure 1.2: Requirements for an optimal data container for microbiome data.
TreeSummarizedExperiment: A S4 class for data with hierarchical structure [version 2; peer review: 3 approved]. Huang et al. (2021). F1000Res 9:1246. doi:10.12688/f1000research.26669.2.
1.3 Open data science
Open data science emphasizes sharing code and, where feasible, data alongside results (Shetty and Lahti 2019). Utilizing Bioconductor tools facilitates the development of efficient and reproducible data science workflows. Enhanced transparency in research accelerates scientific progress. As open science is a fundamental concept in microbiome research, this book aims to educate readers about reproducible reporting practices.
A reproducible report combines the text, the code and the results of an analysis in a single document. When the data or the code change, the report is rendered again, and all numbers, figures and tables are updated automatically. This avoids errors from copying results by hand, and it shows others exactly how the results were obtained.
Quarto is an open-source system for writing such reports. A Quarto document is a text file with the extension .qmd, and it can be rendered, for example, into an HTML page, a PDF or a Word document. This book is also written with Quarto: each chapter is a Quarto document, and the code in the chapters is run every time the book is built. Quarto is included in RStudio, where you can create a new document from File > New File > Quarto Document and render it with the Render button.
A Quarto document has three main parts:
YAML header, between the two --- lines at the top of the document. It sets, for example, the title and the output format.
Text, written in Markdown. For instance, # starts a heading, - starts a list item and [text](url) creates a link.
Code chunks, which start with ```{r} and end with ```. The code is run when the document is rendered, and its output is shown below the chunk. Chunk options at the beginning of the chunk start with #|. They give the chunk a label and control, for instance, whether the code is shown (echo) and what the caption of a figure is (fig-cap). R code can also be placed inside the text, so that a number in a sentence is calculated from the data.
Below is a small Quarto document that loads example data with mia. You can copy it into a new Quarto document in RStudio and render it. If the rendering succeeds, Quarto and the mia package are working.
---title: "My first analysis"format: html---## DataWe use the `GlobalPatterns` dataset from the mia package.```{r}#| label: load-datalibrary(mia)data("GlobalPatterns", package ="mia")tse <- GlobalPatternstse```The data has `r nrow(tse)` features and`r ncol(tse)` samples.
Most of the code in this book can be copied into a Quarto document in the same way, which makes Quarto a convenient way to follow the book and to keep your own analyses reproducible. More material on Quarto is listed in Section 25.3.
Summary
Bioconductor is a large ecosystem for bioinformatics.
Quarto documents combine text, code and results into reproducible reports.
1.4 Exercises
Exercises 3-6 build a small reproducible report on the alpha diversity of the GlobalPatterns dataset, so solve them in order. Before starting them, read Section 1.3.1. You do not need to write the analysis code yourself: you copy it from this book, and focus on how the Quarto document is built and how its output is controlled. Try to solve each exercise yourself before opening the solution.
Exercise 1: Data containers
Goal: Explain what data containers are and why they are central in Bioconductor.
Answer the following questions without writing any code. Section 1.1 and Section 1.2 will help you.
What is a data container? Name two types of data that are stored in its slots.
List the three advantages of data containers that are described in this chapter.
Imagine that you store the abundance table and the sample metadata as two separate tables. You remove three samples from the abundance table but forget to remove them from the sample metadata. What problem does this cause? How does a data container help to avoid it?
Which data container is the most common in Bioconductor? Which data container is the OMA framework built around?
Why does the phyloseq data container no longer meet the needs of current microbiome research?
What are the three parts of the Bioconductor microbiome data science framework?
Solution
A data container is an object that stores data in a structured way. It consists of slots, each dedicated to a certain type of data, for example the abundance table and the sample metadata.
The advantages are ease of handling (subsetting and bookkeeping are more straightforward), development efficiency (developers can rely on a consistent data format), and user accessibility (users can easily apply complex methods to their data).
The two tables no longer describe the same samples, and the sample metadata can be matched to the wrong samples in later analyses. A data container keeps the abundance table and the sample metadata linked. When you subset the container, all its parts are subsetted at the same time, so they stay matched.
SummarizedExperiment is the most common data container in Bioconductor. The OMA framework is built around TreeSummarizedExperiment.
phyloseq was originally developed for 16S sequencing data. It does not adequately support, for example, multi-omics datasets, which have become increasingly common.
Data containers, R/Bioconductor packages that provide dedicated methods, and a community of users and developers.
Exercise 2: Bioconductor website
Goal: Navigate the Bioconductor website and find information about packages.
Open the “Packages” section and go to the list of software packages.
Use the biocViews categories to list the packages in the category “Microbiome”. Note how many packages are listed. The number grows over time, so any current number is a correct answer.
Open the page of the mia package. Which version of mia does the page describe? Is it the release or the devel version? How can you tell?
On the same page, find the installation instructions, the vignettes and the reference manual of mia.
Solution
The packages of the “Microbiome” category are listed on the biocViews page. Any current number of packages is a correct answer.
The version is shown in the “Version” field of the package page. The page tells whether it describes the release or the devel version. The address of the page also contains either release or devel.
The installation instructions are under “Installation”. The vignettes and the reference manual are listed under “Documentation”.
Exercise 3: Create a Quarto document
Goal: Create and render a Quarto document, and write text with Markdown.
Open RStudio and create a new Quarto document from File > New File > Quarto Document. Remove the example content that RStudio adds to the new document.
Copy the example document from Section 1.3.1 into your document. Save the file, for example as report.qmd, and render it with the Render button. If RStudio asks to install packages, accept. If the rendering fails, check that the mia package is installed.
Change the title in the YAML header to "Alpha diversity in GlobalPatterns" and render the document again.
At the end of the document, add a section with the heading ## Alpha diversity. Under it, write a sentence that explains that alpha diversity measures the diversity within each sample.
Under the sentence, add a link to the Alpha diversity chapter (Chapter 12) with the syntax [text](url). You can copy the address of the chapter from your browser. Render the document.
Your document should look similar to the following:
---title: "Alpha diversity in GlobalPatterns"format: html---## DataWe use the `GlobalPatterns` dataset from the mia package.```{r}#| label: load-datalibrary(mia)data("GlobalPatterns", package ="mia")tse <- GlobalPatternstse```The data has `r nrow(tse)` features and`r ncol(tse)` samples.## Alpha diversityAlpha diversity measures the diversity within each sample. The methods areexplained in the[Alpha diversity chapter](https://bioconductor.org/books/release/OMA/pages/alpha_diversity.html)of the OMA book.
In the rendered document, the headings are shown as section titles, the inline code is replaced by the numbers of features and samples, and the link is clickable.
Exercise 4: Add code from the book
Goal: Add code chunks and inline code to a Quarto document, and check that the results update automatically.
Continue with the document from Exercise 3.
Go to Section 12.2.1. Copy the whole code chunk that calculates the alpha diversity indices with addAlpha(). Paste it into a new code chunk at the end of your document. You can insert a chunk with Ctrl + Alt + I (Windows, Linux) or Cmd + Option + I (Mac). The chunk loads the data again, which does no harm.
Go to Section 12.2.2. Copy the whole code chunk that plots the observed richness by sample type (Figure 12.1) into a second code chunk, and render the document.
Under the figure, write the sentence “The median observed richness is X.”, where X is calculated with inline R code from tse$observed_richness. Render the document.
Add the argument detection = 10 to the addAlpha() call, so that only features with more than 10 counts are counted as observed. Render the document again. Which parts of the report change? Did you need to edit them by hand?
The new part of the document should look similar to the following:
```{r}# First, let's load some example data.library(mia)data("GlobalPatterns", package ="mia")tse <- GlobalPatterns# The 'index' parameter allows computing multiple diversity indices# simultaneously. Without specification, four standard indices are calculated:# dbp_dominance, faith_diversity, observed_richness, and shannon_diversity.tse <-addAlpha( tse,assay.type ="counts",detection =10)# Check some of the first values in colDatatse$observed_richness |>head()tse$shannon_diversity |>head()``````{r}library(miaViz)plotBoxplot( tse,col.var ="observed_richness",x ="SampleType") +theme(axis.text.x =element_text(angle =45, hjust =1)) +labs(x ="Sample type", y ="Observed richness")```The median observed richness is`r median(tse$observed_richness)`.
The detection threshold (0 by default) affects which features are counted as observed, so the richness values change. Both the figure and the sentence are updated automatically when the document is rendered, without any manual editing. This is the main benefit of reproducible reporting.
Exercise 5: Control the output
Goal: Control with chunk options how the code and its output are shown in the rendered document.
Continue with the document from Exercise 4. Keep the argument detection = 10 in the addAlpha() call.
Loading packages prints messages that are not needed in the report. Add the chunk option #| message: false to the chunks that load packages, and render the document. Are the messages gone?
Readers of the report may not want to see all the code. Add the chunk options #| code-fold: true and #| code-summary: "Show the code" to the chunk that calculates the alpha diversity. Render the document. How is the code shown now?
Make the figure wider by adding #| fig-width: 10 to the figure chunk. Render the document.
The figure chunk and the new part of the document should look similar to the following:
```{r}#| label: fig-richness#| fig-cap: "Observed richness by sample type."#| message: false#| fig-width: 10library(miaViz)plotBoxplot( tse,col.var ="observed_richness",x ="SampleType") +theme(axis.text.x =element_text(angle =45, hjust =1)) +labs(x ="Sample type", y ="Observed richness")``````{r}#| label: tbl-alpha#| tbl-cap: "Sample type and alpha diversity of the first five samples."#| echo: falseknitr::kable(as.data.frame(colData(tse)[1:5, c("SampleType", "observed_richness","shannon_diversity")] ))```@fig-richness shows the observed richness by sample type, and @tbl-alphalists the values of the first five samples.
In the rendered document, @fig-richness and @tbl-alpha are replaced by clickable references, such as “Figure 1” and “Table 1”.
Quarto uses the prefix of the label to recognize what the chunk produces. Only chunks whose label starts with fig- or tbl- are numbered as figures or tables, and only they can be cross-referenced. A caption is not required, but it helps the reader to understand the figure or table.