@@ -62,14 +62,11 @@ session will follow
6262[ a tutorial] ( https://microbiome.github.io/OMATutorials/ ) ,
6363with participants running the tutorial alongside the instructor.
6464
65- To facilitate this, Galaxy & Bioconductor provide
66- [ pre-installed virtual machines with all necessary packages] ( https://workshop.bioconductor.org/ ) .
67-
6865### _ R_ / _ Bioconductor_ packages used
6966
7067In this training session, we will cover a common methods and packages for
71- microbiome data science in ` r BiocStyle::Biocpkg("SummarizedExperiment") ` ecosystem. We will have
72- specific focus on ` r BiocStyle::Biocpkg("mia") ` ,
68+ microbiome data science in ` r BiocStyle::Biocpkg("SummarizedExperiment") `
69+ ecosystem. We will have specific focus on ` r BiocStyle::Biocpkg("mia") ` ,
7370which provides essential methods for conducting microbiome analysis.
7471
7572### Time outline
@@ -247,58 +244,50 @@ ggplot(timeline_data, aes(x = year, y = 0)) +
247244
248245#### Start your engines!
249246
250- - Go to [ workshop.bioconductor.org ] ( https://workshop.bioconductor.org/ )
247+ - Follow the instructions of instructor
251248- Or prepare your local R session
252249
253250#### Import data
254251
255- The curated metagenomic data project provides free access to a collection of
256- curated microbiome datasets, which are available through the
257- _ curatedMetagenomicData_ R package [ @Pasolli2017 ] . Currently, it contains over
258- 20,000 samples
259- from 100 studies, which can be imported directly to ` TreeSE ` format. You can
260- see the full list of available datasets from
261- [ the documentation] ( https://waldronlab.io/curatedMetagenomicData/index.html ) .
252+ Many publicly available microbiome datasets can be accessed directly from
253+ Bioconductor packages.
254+
255+ In this workshop, we use an example dataset from the
256+ ` r BiocStyle::Biocpkg("mia") ` package [ @hintikka2021 ] . The study compares mice
257+ fed either a high-fat or low-fat diet, with and without prebiotic
258+ supplementation. The dataset contains multiple data types, including:
259+
260+ - 16S rRNA amplicon sequencing, which measures microbial abundances.
261+ - Metabolomics, which measures metabolite concentrations.
262262
263- Below, we we load a dataset containing 60 samples from healthy controls and
264- patients with colorectal cancer (CRC).
263+ We first load the dataset and keep these two layers.
265264
266265``` {r}
267266#| label: import_data
268- #| eval: false
269- library(curatedMetagenomicData)
267+ library(mia)
270268
271- res <- curatedMetagenomicData(
272- pattern = "GuptaA_2019.relative_abundance",
273- dryrun = FALSE,
274- rownames = "short"
275- )
269+ data("HintikkaXOData")
270+ mae <- HintikkaXOData
271+ mae <- mae[, , c(1, 2)]
272+ mae
276273```
277274
278- Once loaded, we can see that the data includes a list of single
279- ` r BiocStyle::Biocpkg("TreeSummarizedExperiment") ` object, which
280- including taxonomy annotations. We select it from the
281- list and store it into a variable named ` tse ` .
275+ The dataset is stored as a ` r BiocStyle::Biocpkg("MultiAssayExperiment") ` , a
276+ container designed for multi-omics data. It keeps multiple datasets together
277+ while maintaining the links between samples.
282278
283- ``` {r}
284- #| label: import_data2
285- #| eval: false
286- tse <- res[[1]]
287- ```
279+ For most of this tutorial, we focus only on the microbiome data. Although
280+ keeping everything in a ` r BiocStyle::Biocpkg("MultiAssayExperiment") ` is
281+ generally recommended, extracting a single dataset makes it easier to introduc
282+ the basic analysis workflow.
288283
289- ``` {r}
290- #| label: save_data
291- #| eval: false
292- #| include: false
293- saveRDS(tse, "data/GuptaA_2019_tse.rds")
294- ```
284+ The microbiome data is stored as a
285+ ` r BiocStyle::Biocpkg("TreeSummarizedExperiment") ` .
295286
296287``` {r}
297- #| label: read_data
298- #| eval: true
299- #| include: false
300- library(TreeSummarizedExperiment)
301- tse <- readRDS("data/GuptaA_2019_tse.rds")
288+ #| label: import_data2
289+ tse <- getWithColData(mae, 1)
290+ tse
302291```
303292
304293#### Data container
@@ -323,8 +312,7 @@ Slots can be accessed with dedicated accessor functions. For instance,
323312
324313``` {r}
325314#| label: show_coldata
326- # Show only first five rows and columns
327- colData(tse)[1:5, 1:5]
315+ colData(tse) |> head()
328316```
329317
330318#### Data processing
@@ -342,8 +330,6 @@ Below, we agglomerate the data into all available taxonomy levels.
342330
343331``` {r}
344332#| label: agglomerate
345- library(mia)
346-
347333tse <- agglomerateByRanks(tse)
348334```
349335
@@ -356,7 +342,7 @@ command:
356342
357343``` {r}
358344#| label: access_phyla
359- altExp(tse, "phylum ")
345+ altExp(tse, "Phylum ")
360346```
361347
362348The data looks similar to original data; only the number of rows has changed.
@@ -365,17 +351,16 @@ to keep it in the `altExp` slot, as it maintains consistent sample mapping for
365351us. Later, we will use ` swapAltExp ` to do this.
366352
367353Another data processing step where microbiome analysis has unique approaches is
368- transformation. Below, we apply centered lo -ratio (CLR) transformation which
354+ transformation. Below, we apply centered log -ratio (CLR) transformations which
369355respect the compositional nature of microbiome data.
370356
371357``` {r}
372358#| label: transformation
373-
374359tse <- transformAssay(
375360 tse,
376- assay.type = "relative_abundance ",
377- method = "clr ",
378- pseudocount = TRUE
361+ assay.type = "counts ",
362+ method = "rclr ",
363+ altexp = altExpNames(tse)
379364)
380365```
381366
@@ -385,37 +370,34 @@ We can access the transformed data with the following command:
385370
386371``` {r}
387372#| label: access_clr
388-
389- assay(tse, "clr")[1:5, 1:5]
373+ assay(tse, "rclr") |> head()
390374```
391375
392376#### Community summaries
393377
394- While ` r BiocStyle::Biocpkg("mia") ` package include common methods for analysis, ` r BiocStyle::Biocpkg("miaViz") ` provides
395- methods for visualizing microbiome data. For instance, we can visualize
396- abundance of phyla with a bar plot. To compare controls and CRC patients, we can
397- visualize the groups separately.
378+ While ` r BiocStyle::Biocpkg("mia") ` package include common methods for analysis,
379+ ` r BiocStyle::Biocpkg("miaViz") ` provides methods for visualizing microbiome
380+ data. For instance, we can visualize abundance of phyla with a bar plot. To
381+ compare study groups, we can visualize them separately.
398382
399383``` {r}
400384#| label: plot_abundance
401385library(miaViz)
402386
403387# Get phylum-level data
404- tse <- swapAltExp(tse, name = "phylum ", withColData = FALSE)
388+ tse <- swapAltExp(tse, name = "Phylum ", withColData = FALSE, saved = "main" )
405389
406390# Create a bar plot
407391plotAbundance(
408392 tse,
409- assay.type = "relative_abundance",
410- col.var = "disease",
393+ assay.type = "counts",
394+ as.relative = TRUE,
395+ col.var = c("Fat", "XOS"),
411396 facet.cols = TRUE,
412397 scales = "free"
413398)
414399```
415400
416- From the figure, we observe that especially abundance of _ Euryarchaeota_ seems
417- to differ between the groups.
418-
419401``` {r}
420402#| label: swap_back_to_main
421403# Switch data back to old orientation
@@ -431,53 +413,116 @@ each with a different emphasis.
431413
432414``` {r}
433415#| label: calculate_alpha
434- tse <- addAlpha(tse, assay.type = "relative_abundance ")
416+ tse <- addAlpha(tse, assay.type = "counts ")
435417```
436418
437419The results are stored in ` colData ` . By default, ` addAlpha() ` returns a set of
438- indices that considers different aspects of diversity. Below, we visualize
439- Faith's diversity that assess the phylogenetic diversity of samples .
420+ indices that considers different aspects of diversity. Commonly, the results
421+ are visualized with a box plot .
440422
441423``` {r}
442424#| label: visualize_alpha
443- library(scater)
444-
445- plotColData(tse, x = "disease", y = "shannon_diversity")
425+ plotBoxplot(tse, x = "Fat", col.var = "shannon_diversity")
446426```
447427
448- From the figure, we can observe that CRC patients have more diverse microbiomes.
449- This may suggest that their gut is colonized by microbes that are not typically
450- present in a healthy gut.
451-
452428#### Beta diversity
453429
454430While alpha diversity reflects within-sample diversity, beta diversity measures
455431diversity between samples. This allows us to assess whether there are patterns
456- in microbial profiles associated with covariates &mdash ; such as diagnosis,
457- in this case.
432+ in microbial profiles associated with covariates.
458433
459- Below, we calculate perform principal coordinate analysis (PCoA) also known
460- as multidimensional scaling (MDS). We apply UniFrac dissimilarity that takes
461- into account phylogeny.
434+ Below, we calculate perform principal component analysis (PCA). The standard
435+ choice is to apply it to CLR-transformed data
462436
463437``` {r}
464- #| label: calculate_mds
465- tse <- addMDS(
438+ #| label: calculate_pca
439+ library(scater)
440+ tse <- runPCA(
466441 tse,
467- assay.type = "relative_abundance",
468- method = "bray"
442+ assay.type = "rclr"
469443)
470444```
471445
472446After calculating the results, we can visualize them with the diagnosis.
473447
474448``` {r}
475- #| label: visualize_mds
476- plotReducedDim(tse, dimred = "MDS", colour_by = "disease")
449+ #| label: visualize_pca
450+ plotOrdination(tse, dimred = "PCA", colour.by = "Fat", add.ellipse = TRUE)
451+ ```
452+
453+ ### Multi-omics
454+
455+ Integrating multiple omics layers has become increasingly common in microbiome
456+ research. While ` r BiocStyle::Biocpkg("MultiAssayExperiment") ` provides a
457+ convenient container for storing multi-omics data, until recently relatively
458+ few analysis methods worked directly with it. As a result, users often had to
459+ extract individual assays before applying downstream methods.
460+
461+ Fortunately, this is changing. An increasing number of packages now support
462+ ` r BiocStyle::Biocpkg("MultiAssayExperiment") ` directly, making it easier to
463+ build streamlined workflows for multi-omics analysis.
464+
465+ Let's return to our ` r BiocStyle::Biocpkg("MultiAssayExperiment") ` object. It
466+ stores one ` r BiocStyle::Biocpkg("SummarizedExperiment") ` for each omics layer
467+ and uses a ` sampleMap ` to match samples across assays.
468+
469+ ``` {r}
470+ #| label: show_mae
471+ # Lets put the TreeSE back to MAE
472+ tse <- swapAltExp(tse, "Family")
473+ mae[[1]] <- tse
474+ mae
477475```
478476
479- We can see clear pattern: microbial profiles of CRC patients are distinct from
480- healthy controls.
477+ One simple integration strategy is to calculate correlations between microbial
478+ taxa and metabolites. This approach is easy to interpret and can be further
479+ improved by restricting the analysis to biologically plausible feature pairs.
480+ The ` r BiocStyle::Biocpkg("anansi") ` package provides tools for this type of
481+ knowledge-guided analysis.
482+
483+ However, microbial communities often act collectively rather than as individual
484+ taxa. Consequently, pairwise correlations may miss more complex relationships.
485+
486+ An alternative is Joint Robust PCA (Joint-RPCA) [ @vargas2026 ] , which identifies
487+ variation that is shared across multiple omics datasets.
488+
489+ The method works in two stages:
490+
491+ 1 . It estimates a joint low-rank representation of the datasets, reducing noise while preserving variation shared across omics layers.
492+
493+ 2 . It performs PCA on this shared representation to visualize the dominant patterns across all datasets.
494+
495+ The following example performs Joint-RPCA using the microbiome and metabolomics
496+ data.
497+
498+ ``` {r}
499+ #| label: joint-rpca
500+
501+ # Apply CLR without imputation
502+ mae[[1]] <- transformAssay(
503+ mae[[1]],
504+ assay.type = "counts",
505+ method = "rclr",
506+ impute = FALSE,
507+ name = "rclr_non_imputed")
508+
509+ # Apply log10 for metabolomics
510+ mae[[2]] <- transformAssay(
511+ mae[[2]],
512+ assay.type = "nmr",
513+ method = "log10"
514+ )
515+
516+ # Run joint-RPCA
517+ mae <- addJointRPCA(
518+ mae,
519+ experiments = c(1, 2),
520+ assay.types = c("rclr_non_imputed", "log10")
521+ )
522+
523+ # Visualize results
524+ plotJointRPCA(mae, "JointRPCA", colour.by = "Fat", add.ellipse = TRUE, ntop = 5)
525+ ```
481526
482527### Time to try things out on your own!
483528
@@ -497,7 +542,7 @@ healthy controls.
497542#| eval: false
498543library(maaslin3)
499544
500- res <- maaslin3(tse, formula = ~ disease , output = "maaslin3_output")
545+ res <- maaslin3(tse, formula = ~ Fat , output = "maaslin3_output")
501546```
502547
503548``` {r}
0 commit comments