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:
Joint-RPCA extends robust PCA (RPCA) (Martino et al. 2019) to multiple tables. It assumes that the tables share an underlying low-rank structure that can be estimated with matrix completion. Microbiome data is transformed with the robust centered log-ratio (rclr) transformation, in which zeros are treated as missing values. This makes the method designed for sparse and compositional data. In the benchmarks of Cordazzo Vargas et al. (2026), Joint-RPCA recovered phenotype-associated structure more consistently than general-purpose multi-omics methods, including MOFA, under the sparse and compositional data conditions typical of microbiome studies.
MOFA is a probabilistic factor model that does not assume any microbiome-specific data properties. By default, it assumes normally distributed data, so the data is usually transformed and standardized beforehand. MOFA is a general-purpose method that is widely used in multi-omics studies across fields, and it is supported by a large set of tools and tutorials. When the data matches its assumptions, it can perform better than Joint-RPCA (Cordazzo Vargas et al. 2026).
21.1 Data
We use the Hintikka et al. (2021) dataset introduced in Chapter 19.
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.04298The 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).
library(miaViz)
plotJointRPCAExplainedVariance(mae, "JointRPCA")
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")
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)
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)
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)
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.
We use the MOFA2 package for analysis.
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))
)
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")
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))
More tutorials and examples of using the package are found at MOFA2 tutorials.