21  Ordination-based multiassay analysis

In this chapter, we continue from where we left off in the previous section (Chapter 20). Instead of testing feature pairs one by one, we now look for patterns that are shared across the omic layers. We introduce two unsupervised integration methods: Joint Robust Principal Component Analysis (Joint-RPCA) (Cordazzo Vargas et al. 2026) and Multi-Omics Factor Analysis (MOFA) (Argelaguet et al. 2018).

Both methods are based on ordination, similarly to principal component analysis (PCA) and principal coordinate analysis (PCoA) introduced in Chapter 14. They reduce the dimensionality of the data into a small number of components or factors that capture the main patterns of variation. Unlike in single-table ordination, these components are shared across the omic layers, and each feature in each layer gets a loading or weight on them. Features with large loadings on the same component co-vary across the samples.

However, the methods make different assumptions about the data:

Martino, C, J. T. Morton, C. A. Marotz, L. R. Thompson, A Tripathi, R Knight, and K Zengler. 2019. “A Novel Sparse Compositional Technique Reveals Microbial Perturbations.” mSystems 4.
Cordazzo Vargas, Bianca, Cameron Martino, Amanda Hazel Dilmore, Jessica L Metcalf, Zachary M Burcham, Leo Lahti, Aituar Bektanov, et al. 2026. “Joint-RPCA: Domain-Aware Multi-Omics Integration for Systems Microbiology.” Molecular Systems Biology 22 (11): 1789–1808. https://doi.org/10.1038/s44320-026-00236-3.

21.1 Data

We use the Hintikka et al. (2021) dataset introduced in Chapter 19.

Hintikka, Jukka, Sanna Lensu, Elina Mäkinen, Sira Karvinen, Marjaana Honkanen, Jere Lindén, Tim Garrels, Satu Pekkala, and Leo Lahti. 2021. “Xylo-Oligosaccharides in Prevention of Hepatic Steatosis and Adipose Tissue Inflammation: Associating Taxonomic and Metabolomic Patterns in Fecal Microbiomes with Biclustering.” International Journal of Environmental Research and Public Health 18 (8): 4049.
library(mia)

data("HintikkaXOData", package = "mia")
mae <- HintikkaXOData

For Joint-RPCA, we agglomerate the microbiome data to genus level and filter out rare genera with filterRPCAInput(). Filtering must be done on untransformed counts. Then, we apply the rclr transformation. We set impute = FALSE, because Joint-RPCA handles the zeros, i.e., missing values, itself through matrix completion. The metabolite concentrations are log10-transformed. The biomarker data contains zeros, so instead of a log transformation, we standardize each biomarker.

# Agglomerate microbiome data
mae[["microbiota"]] <- agglomerateByRank(mae[["microbiota"]], rank = "Genus")

# Remove genera that are present in 10% or less of the samples
mae[["microbiota"]] <- filterRPCAInput(
    mae[["microbiota"]],
    min.feature.frequency = 0.1
)

# Apply rclr transformation without imputing zeros
mae[["microbiota"]] <- transformAssay(
    mae[["microbiota"]],
    method = "rclr",
    impute = FALSE
)

# Apply log10 transformation to metabolome NMR assay
mae[["metabolites"]] <- transformAssay(
    mae[["metabolites"]],
    assay.type = "nmr",
    method = "log10"
)

# Standardize biomarker assay
mae[["biomarkers"]] <- transformAssay(
    mae[["biomarkers"]],
    assay.type = "signals",
    method = "standardize",
    MARGIN = "rows"
)

21.2 Joint Robust Principal Component Analysis

Joint-RPCA is available in mia and its results can be visualized with miaViz. We run the analysis with addJointRPCA(), which stores the results in the metadata of the MultiAssayExperiment.

set.seed(123)
mae <- addJointRPCA(
    mae,
    experiments = c("microbiota", "metabolites", "biomarkers"),
    assay.types = c("rclr", "log10", "standardize"),
    ncomponents = 5
)

# Sample scores
metadata(mae)[["JointRPCA"]] |> head()
##          PC1       PC2       PC3      PC4      PC5
##  C1 -0.03151  0.223053 -0.524752  0.03520 -0.10556
##  C2 -0.22079 -0.002226  0.118771  0.07765  0.16760
##  C3 -0.15689 -0.245952  0.061675  0.22776 -0.15101
##  C4 -0.07110 -0.154410 -0.108689 -0.03101  0.23434
##  C5 -0.42185  0.034359  0.183513 -0.12842  0.03778
##  C6 -0.16993 -0.037894  0.001937 -0.04606  0.04298

The explained variance is visualized with plotJointRPCAExplainedVariance(). The heatmap shows how the variance of each omic layer is divided across the components, and the barplot shows how the total variance is divided across the layers. Note that the values describe the low-rank Joint-RPCA model, not the proportion of variance explained in the observed data (Figure 21.1).

Figure 21.1: Variance explained by the Joint-RPCA model of the Hintikka et al. (2021) data. The heatmap shows the variance of each omic layer (microbiota, metabolites, biomarkers) explained by each of the five components, and the barplot shows the share of total variance per layer.

Similarly to MOFA, the samples can be visualized in the space of the first two components (Figure 21.2).

plotJointRPCA(mae, "JointRPCA", colour.by = "Diet")
Figure 21.2: Joint-RPCA sample scores of the Hintikka et al. (2021) data on the first two components, coloured by diet.

We can then visualize the features with the largest loadings in each omic layer for the first two components to analyze co-varying features (Figure 21.3).

plotJointRPCALoadings(mae, "JointRPCA", ncomponents = 2, n = 10)
Figure 21.3: Top 10 features with the largest Joint-RPCA loadings on the first two components in each omic layer (microbiota genera, metabolites and biomarkers) of the Hintikka et al. (2021) data.

In addition to the loadings, the co-variation can be visualized directly as correlations between features both within and across the omic layers. The correlations are calculated from the Joint-RPCA model, and they reflect how the features align in the Joint-RPCA space rather than correlations in the observed data (Figure 21.4).

plotJointRPCACovariance(mae, "JointRPCA", ntop = 10, correlation = TRUE)
Figure 21.4: Heatmap of correlations between the top features of the microbiota, metabolite and biomarker layers, derived from the Joint-RPCA model of the Hintikka et al. (2021) data.

The same information can be visualized as a network, where the edges connect strongly correlated features (Figure 21.5).

plotJointRPCANetwork(mae, "JointRPCA", show.label = TRUE)
Figure 21.5: Network of features from the microbiota, metabolite and biomarker layers based on the Joint-RPCA model of the Hintikka et al. (2021) data. Edges connect strongly correlated features.

21.3 Multi-Omics Factor Analysis

Multi-Omics Factor Analysis (MOFA) is an unsupervised method for integrating multi-omic data sets in a downstream analysis (Argelaguet et al. 2018). It could be seen as a generalization of principal component analysis. Yet, with the ability to infer a latent (low-dimensional) representation, shared among the multiple (-omics) data sets in hand.

Argelaguet, Ricard, Britta Velten, Damien Arnol, Sascha Dietrich, Thorsten Zenz, John C Marioni, Florian Buettner, Wolfgang Huber, and Oliver Stegle. 2018. “Multi-Omics Factor Analysis—a Framework for Unsupervised Integration of Multi-Omics Data Sets.” Molecular Systems Biology 14 (6): e8124. https://doi.org/10.15252/msb.20178124.

We use the MOFA2 package for analysis.

library(mia)

# Import dataset
data("HintikkaXOData", package = "mia")

# Store as mae
mae <- HintikkaXOData

The mae object could be used straight to create the MOFA model. Yet, we transform our assays since the model assumes normality per default, and Gaussian model is recommended (see MOFA2 FAQ). However, Poisson and Bernoulli distribution models are also available.

library(MOFA2)

# Agglomerate microbiome data
mae[[1]] <- agglomerateByPrevalence(mae[[1]], rank = "Genus")

# Apply CLR transformation to microbiome counts assay
mae[[1]] <- transformAssay(mae[[1]], method = "clr", pseudocount = TRUE)

# Standardize microbiome CLR assay
mae[[1]] <- transformAssay(
    mae[[1]],
    assay.type = "clr",
    method = "standardize",
    MARGIN = "rows",
    name = "clr-z"
)

# Apply log10 transformation to metabolome NMR assay
mae[[2]] <- transformAssay(mae[[2]], assay.type = "nmr", method = "log10")

# Standardize metabolome log10 assay
mae[[2]] <- transformAssay(
    mae[[2]],
    assay.type = "log10",
    method = "standardize",
    name = "log10-z"
)

# Standardize biomarker assay
mae[[3]] <- transformAssay(
    mae[[3]],
    assay.type = "signals",
    method = "standardize",
    MARGIN = "rows",
    name = "z"
)

Then, we prepare the MOFA2 model and define the data and training parameters available as additional argument, which will otherwise be set to default values. The full parameter list can be found with ?mofa2.

# Build MOFA2 model
model <- mofa2(
    mae,
    experiments = c("microbiota", "metabolites", "biomarkers"),
    assays = c("clr-z", "log10-z", "z"),
    num_factors = 5
)

# View model
model
##  Untrained MOFA model with the following characteristics: 
##   Number of views: 3 
##   Views names: microbiota metabolites biomarkers 
##   Number of features (per view): 112 38 39 
##   Number of groups: 1 
##   Groups names: group1 
##   Number of samples (per group): 40 
##  

The model is then and trained with run_mofa.

# Some systems may require the specification `use_basilisk = TRUE`
# so it has been added to the following code
model <- run_mofa(model, use_basilisk = TRUE)

The explained variance is visualized with the plot_variance_explained() function (Figure 21.6).

Show the plotting code
library(patchwork)
library(ggplot2)

plot_list <- plot_variance_explained(
    model,
    x = "view", y = "factor",
    plot_total = TRUE
)

wrap_plots(plot_list, nrow = 2) +
    plot_annotation(
        title = "Variance Explained per factor and assay",
        theme = theme(plot.title = element_text(hjust = 0.5))
    )
Figure 21.6: Variance explained by the MOFA model of the Hintikka et al. (2021) data. The heatmap shows the variance explained per factor (rows) and omic layer (columns), and the barplot shows the total variance explained per layer.

Similarly to Joint-RPCA, the samples can be visualized in the space of the first two factors (Figure 21.7).

plot_factors(model, factors = c(1, 2), color_by = "Diet")
Figure 21.7: MOFA sample scores of the Hintikka et al. (2021) data on factors 1 and 2, coloured by diet.

We can then visualize the top weights for microbiota and metabolites for the first two factors to analyze co-varying features (Figure 21.8).

plot_list <- lapply(
    c("microbiota", "metabolites"),
    plot_top_weights,
    object = model,
    factors = c(1, 2),
    nfeatures = 10
)

wrap_plots(plot_list, ncol = 1) & theme(text = element_text(size = 8))
Figure 21.8: Top 10 features with the largest absolute MOFA weights on factors 1 and 2 for the microbiota (top) and metabolite (bottom) layers of the Hintikka et al. (2021) data.

More tutorials and examples of using the package are found at MOFA2 tutorials.

Exercises

Goal: After completing these exercises, you should be able to integrate multiple omics with Joint-RPCA and MOFA, visualize the results, and compare the two methods.

Exercise 1: Joint-RPCA

  1. Load any of the example datasets in MultiAssayExperiment format mentioned in Section 4.2, for example, HintikkaXOData from mia.

  2. Check which experiments the dataset contains and what assays they have. Are the samples matched across the experiments?

  3. Agglomerate the microbiota data to genus level.

  4. Filter out rare features from the raw microbiota counts. Why must the filtering be done before the transformation?

  5. Apply the rclr transformation to the microbiota data without imputing the zeros. How many values are missing after the transformation?

  6. Transform the other omics to an appropriate scale, for example, with log10 transformation or standardization.

  7. Run Joint-RPCA with three components. Set a seed first so that the results are reproducible.

  8. Visualize the explained variance. Which omic layer contributes most to the model, and which components capture most of its variance?

  9. Plot the samples in the space of the first two components and colour them by a sample variable, such as diet or diagnosis. Is there visible separation between the groups?

  10. For each omic, visualize the features with the largest loadings on the first two components. Which features co-vary across the omic layers?

  11. Visualize the correlations between the top features both as a heatmap and as a network.

Useful functions:

utils::data(), MultiAssayExperiment::experiments(), mia::agglomerateByRank(), mia::filterRPCAInput(), mia::transformAssay(), mia::addJointRPCA(), miaViz::plotJointRPCAExplainedVariance(), miaViz::plotJointRPCA(), miaViz::plotJointRPCALoadings(), miaViz::plotJointRPCACovariance(), miaViz::plotJointRPCANetwork()

Exercise 2: MOFA

  1. Use the same dataset as in Exercise 1.

  2. Agglomerate the microbiota data to prevalent genera.

  3. Apply the CLR transformation to the microbiota data.

  4. Apply the relative and log10 transformations to the other omics.

  5. Standardize each feature within each omic so that all features have mean 0 and unit variance.

  6. Make sure that the feature names are unique.

  7. Create a MOFA2 object from the MultiAssayExperiment and train the model with five factors.

  8. Visualize the explained variance. How much variance is explained in total, and which omic accounts for the most variance?

  9. Plot the samples in the space of the first two factors and colour them by the same sample variable as in Exercise 1.

  10. For each omic, visualize the features with the largest weights. Which features co-vary across the omic layers?

Useful functions:

mia::agglomerateByPrevalence(), mia::transformAssay(), mia::getTaxonomyLabels(), MOFA2::mofa2(), MOFA2::run_mofa(), MOFA2::plot_variance_explained(), MOFA2::plot_factors(), MOFA2::plot_top_weights()

Exercise 3: Comparing the methods

  1. Compare the sample ordinations from Joint-RPCA and MOFA. Do the methods separate the samples similarly?

  2. Compare the top features. Which features are identified by both methods, and which by only one?

  3. Joint-RPCA and MOFA rely on different transformations and assumptions. Which properties of your data could explain the differences between the results?

  4. If you completed the exercises in Chapter 20, do the co-varying features also show correlation in the cross-association analysis?

Useful functions:

mia::getCrossAssociation(), ComplexHeatmap::Heatmap(), base::intersect()

Back to top