21  Multi-omics ordination

In this chapter, we continue from where we left off in the previous chapter (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, similar to principal component analysis (PCA) and principal coordinate analysis (PCoA) introduced in Chapter 13. 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:

A novel sparse compositional technique reveals microbial perturbations. Martino et al. (2019). mSystems 4:e00016–19. doi:10.1128/mSystems.00016-19.
Matrix completion from a few entries. Keshavan et al. (2010). IEEE Trans Inf Theory 56:2980–2998. doi:10.1109/TIT.2010.2046205.

21.1 Data

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

Xylo-oligosaccharides in prevention of hepatic steatosis and adipose tissue inflammation: Associating taxonomic and metabolomic patterns in fecal microbiomes with biclustering. Hintikka et al. (2021). Int J Environ Res Public Health 18:4049. doi:10.3390/ijerph18084049.
library(mia)

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

For Joint-RPCA, we agglomerate the microbiome data to genus level and filter the counts in three steps, in the same order as gemelli, the original Python implementation of Joint-RPCA: we remove genera with few reads, then genera that are present in few samples, and finally samples with few reads. Each step is computed from the data left by the previous step, so, for instance, library sizes are calculated after the rare genera are removed. 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 the "D_5__" prefix of the SILVA genus names to shorten the labels
rownames(mae[["microbiota"]]) <- sub(
    "^D_5__", "", rownames(mae[["microbiota"]])
)

# Filter the raw counts in steps
tse <- mae[["microbiota"]]
# 1. Remove genera with 10 reads or fewer in total
tse <- tse[rowSums(assay(tse, "counts")) > 10, ]
# 2. Remove genera that are present in 10% or less of the samples
tse <- tse[rowMeans(assay(tse, "counts") > 0) > 0.1, ]
# 3. Remove samples with 1000 reads or fewer
tse <- tse[, colSums(assay(tse, "counts")) > 1000]
mae[["microbiota"]] <- tse

# 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"
)
NoteNote: Filtering with mia functions

The metrics can also be calculated with getPrevalence() and addQC() from mia. If so, recalculate them after each step: metrics calculated once from the original object ignore the earlier steps, e.g., library sizes would still include the reads of the removed genera.

21.2 Joint-RPCA

Joint-RPCA (joint robust principal component analysis) (Cordazzo Vargas et al. 2026) 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 (Ramos et al. 2017).

Joint-RPCA: Domain-aware multi-omics integration for systems microbiology. Cordazzo Vargas et al. (2026). Mol Syst Biol 22:1789–1808. doi:10.1038/s44320-026-00236-3.
Software for the integration of multiomics experiments in Bioconductor. Ramos et al. (2017). Cancer Res 77:e39–e42. doi:10.1158/0008-5472.CAN-17-0344.
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.05305  0.07229 -0.54160  0.129249 -0.06731
##  C2 -0.23244 -0.02009  0.10283 -0.193564  0.11265
##  C3 -0.31100 -0.29103  0.19267  0.002118  0.03056
##  C4 -0.11127 -0.16267 -0.04174  0.392041  0.21768
##  C5 -0.17180 -0.03069  0.08345 -0.096594  0.05724
##  C6 -0.19144 -0.06475  0.02732  0.029457  0.04037

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).

library(miaViz)

plotJointRPCAExplainedVariance(mae, "JointRPCA", add.total = TRUE)
Two panels: a heatmap with the five Joint-RPCA components against the microbiota, metabolite and biomarker layers, filled by the variance explained, and a barplot with one bar per omic layer showing its share of the total variance.
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.

As in other ordination methods, the samples can be visualized in the space of the first two components (Figure 21.2).

plotJointRPCA(mae, "JointRPCA", colour.by = "Diet")
Scatter plot of samples on Joint-RPCA component 1 (x-axis) and component 2 (y-axis), with points colored by diet.
Figure 21.2: Joint-RPCA sample scores of the Hintikka et al. (2021) data on the first two components, colored 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)
Grid of horizontal bar charts, one per omic layer and component, each listing the ten microbiota genera, metabolites or biomarkers with the largest loadings on components 1 and 2 and the size and sign of each loading.
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)
Square heatmap with the top features of the microbiota, metabolite and biomarker layers on both axes, where cell color shows the correlation between each pair of features within and across layers.
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)
Network graph whose labelled nodes are features from the microbiota, metabolite and biomarker layers, joined by edges between strongly correlated features.
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 MOFA

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

Multi-omics factor analysis—a framework for unsupervised integration of multi-omics data sets. Argelaguet et al. (2018). Mol Syst Biol 14:e8124. doi:10.15252/msb.20178124.
MOFA+: A statistical framework for comprehensive integration of multi-modal single-cell data. Argelaguet et al. (2020). Genome Biol 21:111. doi:10.1186/s13059-020-02015-1.

We use the MOFA2 package (Argelaguet et al. 2020) for analysis.

library(mia)

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

# Store as mae
mae <- HintikkaXOData

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

library(MOFA2)

# Agglomerate microbiome data
mae[["microbiota"]] <- agglomerateByRank(mae[["microbiota"]], rank = "Genus")
rownames(mae[["microbiota"]]) <-
    sub("^D_5__", "", rownames(mae[["microbiota"]]))
mae[["microbiota"]] <- addPrevalence(mae[["microbiota"]])
mae[["microbiota"]] <- subsetBy(
    mae[["microbiota"]],
    rows = prevalence > 0.5, collapse = TRUE
)

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

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

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

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

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

Then, we create the MOFA model with mofa2(). Data, model and training options can be given as additional arguments; otherwise, defaults are used (see ?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 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)

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

wrap_plots(plot_list, nrow = 2)
Two stacked panels: a heatmap of MOFA factors (rows) against the omic layers (columns), filled by the variance explained, and a barplot of the total variance explained in each layer.
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")
Scatter plot of samples on MOFA factor 1 (x-axis) and factor 2 (y-axis), with points colored by diet.
Figure 21.7: MOFA sample scores of the Hintikka et al. (2021) data on factors 1 and 2, colored 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).

p1 <- plot_top_weights(
    model,
    view = "microbiota",
    factors = c(1, 2),
    nfeatures = 10
)

p2 <- plot_top_weights(
    model,
    view = "metabolites",
    factors = c(1, 2),
    nfeatures = 10
)

wrap_plots(p1 + ggtitle("Microbiota"), p2 + ggtitle("Metabolites"), ncol = 1)
Two stacked rows of panels for factors 1 and 2, showing the ten microbiota features (top) and the ten metabolites (bottom) with the largest absolute weights, each drawn as a point along the weight axis.
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.

21.4 Exercises

We use the HintikkaXOData dataset, as in this chapter.

Solve the exercises in order, as each exercise continues from the previous one. Try to solve each exercise yourself before opening the solution.

TipExercise 1: Shared components

Goal: Explain what the ordination-based integration methods estimate and how Joint-RPCA and MOFA differ.

Answer the following questions without writing any code. The beginning of this chapter will help you.

  1. How do Joint-RPCA and MOFA differ from a PCA that is run on a single table?

  2. A bacterial genus and a metabolite both have a large positive loading on the first component. What does this tell about them?

  3. How does the rclr transformation used in Joint-RPCA handle zeros? Why does this suit microbiome data?

  4. Why is the data usually transformed and standardized before running MOFA?

  1. Like PCA, they reduce the data into a small number of components or factors that capture the main patterns of variation. Unlike in single-table PCA, the components are shared across the omic layers, and each feature in each layer gets a loading or weight on them.

  2. Features with large loadings on the same component co-vary across the samples. Here, samples with a high score on the first component tend to have high values of both the genus and the metabolite.

  3. The rclr transformation treats zeros as missing values, and Joint-RPCA estimates them with matrix completion. Microbiome data is sparse and compositional, so it has many zeros that may not be true absences. The method is designed for these properties.

  4. By default, MOFA assumes normally distributed data, and it does not assume any microbiome-specific properties. The transformations make the data closer to normal, and the standardization puts all features on the same scale.

TipExercise 2: Prepare the data for Joint-RPCA

Goal: Prepare multi-omic data for Joint-RPCA.

  1. Load the HintikkaXOData dataset from the mia package and store it in a variable called mae.

  2. Check which experiments the dataset contains and which assays each experiment has.

  3. Agglomerate the microbiota data to genus level.

  4. Filter the counts assay of the microbiota data in three steps: remove the genera with 10 reads or fewer in total, then the genera that are present in 10% or less of the samples, and finally the samples with 1000 reads or fewer. How many genera and samples remain?

  5. Apply the rclr transformation to the microbiota data without imputing the zeros (impute = FALSE).

  6. Count the zeros in the counts assay and the missing values in the rclr assay of the microbiota data. Compare the two numbers.

  7. Apply the log10 transformation to the nmr assay of the metabolites, and standardize each biomarker in the signals assay.

Useful functions: data(), MultiAssayExperiment::experiments(), assayNames(), mia::agglomerateByRank(), assay(), rowSums(), rowMeans(), colSums(), dim(), mia::transformAssay(), is.na(), sum()

library(mia)

# 1. Load the data
data("HintikkaXOData", package = "mia")
mae <- HintikkaXOData

# 2. Experiments and their assays
experiments(mae)
##  ExperimentList class object of length 3:
##   [1] microbiota: TreeSummarizedExperiment with 12706 rows and 40 columns
##   [2] metabolites: TreeSummarizedExperiment with 38 rows and 40 columns
##   [3] biomarkers: TreeSummarizedExperiment with 39 rows and 40 columns
assayNames(mae[["microbiota"]])
##  [1] "counts"
assayNames(mae[["metabolites"]])
##  [1] "nmr"
assayNames(mae[["biomarkers"]])
##  [1] "signals"

# 3. Agglomerate the microbiota data to genus level
mae[["microbiota"]] <- agglomerateByRank(mae[["microbiota"]], rank = "Genus")
rownames(mae[["microbiota"]]) <-
    sub("^D_5__", "", rownames(mae[["microbiota"]]))

# 4. Filter the counts in three steps
tse <- mae[["microbiota"]]
tse <- tse[rowSums(assay(tse, "counts")) > 10, ]
tse <- tse[rowMeans(assay(tse, "counts") > 0) > 0.1, ]
tse <- tse[, colSums(assay(tse, "counts")) > 1000]
mae[["microbiota"]] <- tse
dim(mae[["microbiota"]])
##  [1] 142  40

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

# 6. Zeros in counts and missing values in rclr
sum(assay(mae[["microbiota"]], "counts") == 0)
##  [1] 1447
sum(is.na(assay(mae[["microbiota"]], "rclr")))
##  [1] 1447

# 7. Transform metabolites and biomarkers
mae[["metabolites"]] <- transformAssay(
    mae[["metabolites"]],
    assay.type = "nmr",
    method = "log10"
)
mae[["biomarkers"]] <- transformAssay(
    mae[["biomarkers"]],
    assay.type = "signals",
    method = "standardize",
    MARGIN = "rows"
)
  1. dim() shows the number of remaining genera and samples. No samples are removed by the last step.
  1. The two numbers are equal, because each zero in the counts becomes a missing value in the rclr assay. Joint-RPCA estimates these missing values itself.
TipExercise 3: Run Joint-RPCA

Goal: Run Joint-RPCA and visualize the explained variance and the samples.

  1. Set the seed to 123 and run Joint-RPCA with addJointRPCA() on all three experiments. Use the assays rclr, log10 and standardize, and three components (ncomponents = 3).

  2. Show the first sample scores, which are stored in metadata(mae).

  3. Visualize the explained variance.

  4. Plot the samples in the space of the first two components, and color them by Diet.

  5. How do you read the explained variance plot? How can you see from the sample plot whether the diet groups differ?

Useful functions: set.seed(), mia::addJointRPCA(), metadata(), head(), miaViz::plotJointRPCAExplainedVariance(), miaViz::plotJointRPCA()

library(miaViz)

# 1. Run Joint-RPCA with three components
set.seed(123)
mae <- addJointRPCA(
    mae,
    experiments = c("microbiota", "metabolites", "biomarkers"),
    assay.types = c("rclr", "log10", "standardize"),
    ncomponents = 3
)

# 2. Sample scores
metadata(mae)[["JointRPCA"]] |> head()
##          PC1      PC2      PC3
##  C1 -0.01435  0.33108  0.06889
##  C2 -0.22904 -0.05302  0.36880
##  C3 -0.12290 -0.23473 -0.04760
##  C4 -0.04515 -0.13327  0.41008
##  C5 -0.15523 -0.04142 -0.11645
##  C6 -0.24524 -0.03036 -0.04993

# 3. Explained variance
plotJointRPCAExplainedVariance(mae, "JointRPCA", add.total = TRUE)


# 4. Samples colored by diet
plotJointRPCA(mae, "JointRPCA", colour.by = "Diet")

  1. 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. A component that explains much variance in several layers captures a pattern that is shared by them. Note that the values describe the low-rank Joint-RPCA model, not the observed data. In the sample plot, each point is a sample. If the colors form separate groups along a component, that component captures differences between the diet groups.
TipExercise 4: Co-varying features in Joint-RPCA

Goal: Find features that co-vary across the omic layers.

  1. Visualize the ten features with the largest loadings on the first two components in each omic layer.

  2. Visualize the correlations between the top ten features of each layer as a heatmap (ntop = 10, correlation = TRUE).

  3. Visualize the same correlations as a network with feature labels.

  4. How do you read the heatmap and the network? Are these correlations calculated from the observed data?

Useful functions: miaViz::plotJointRPCALoadings(), miaViz::plotJointRPCACovariance(), miaViz::plotJointRPCANetwork()

# 1. Top loadings in each omic layer
plotJointRPCALoadings(mae, "JointRPCA", ncomponents = 2, n = 10)


# 2. Correlations between the top features as a heatmap
plotJointRPCACovariance(mae, "JointRPCA", ntop = 10, correlation = TRUE)


# 3. Correlations as a network
plotJointRPCANetwork(mae, "JointRPCA", show.label = TRUE)

  1. In the heatmap, each cell shows the correlation between two features, both within and across the omic layers. Positive values mean that the features increase together, and negative values that one increases when the other decreases. In the network, the nodes are features and the edges connect strongly correlated features. The correlations are not calculated from the observed data. They are derived from the Joint-RPCA model and describe how the features align in the Joint-RPCA space.
TipExercise 5: Run MOFA

Goal: Prepare the data for MOFA, train the model and visualize the results.

  1. Load HintikkaXOData again and store it in mae, so that you start from the original data.

  2. Agglomerate the microbiota data to the Genus rank. Then add the prevalence, and combine the genera with a prevalence of 0.5 or less into “Other”. Apply the CLR transformation (Fernandes et al. 2014) with a pseudocount of 0.5, and then standardize each genus. Store the standardized assay under the name "clr-z".

  3. Apply the log10 transformation to the nmr assay of the metabolites, and then standardize each metabolite. Store the standardized assay under the name "log10-z".

  4. Standardize each biomarker in the signals assay, and store the result under the name "z".

  5. Create a MOFA model with mofa2() from the three experiments and the assays clr-z, log10-z and z, with three factors (num_factors = 3). Train the model with run_mofa() and use_basilisk = TRUE.

  6. Visualize the explained variance per factor and omic layer, with the layers on the x-axis and the factors on the y-axis. Then, in a separate plot, visualize the total variance explained in each layer.

  7. Plot the samples in the space of the first two factors, and color them by Diet.

  8. Visualize the ten features with the largest weights on the first two factors for the microbiota. Then make the same plot for the metabolites.

  9. Compare the sample plot and the top features to those from Joint-RPCA in Exercises 3 and 4. Why might the two methods give different results?

Useful functions: mia::agglomerateByRank(), mia::addPrevalence(), mia::subsetBy(), mia::transformAssay(), MOFA2::mofa2(), MOFA2::run_mofa(), MOFA2::plot_variance_explained(), MOFA2::plot_factors(), MOFA2::plot_top_weights()

library(MOFA2)

# 1. Load the original data
data("HintikkaXOData", package = "mia")
mae <- HintikkaXOData

# 2. Microbiota: prevalent genera, CLR and standardization
mae[["microbiota"]] <- agglomerateByRank(
    mae[["microbiota"]],
    rank = "Genus"
)
rownames(mae[["microbiota"]]) <-
    sub("^D_5__", "", rownames(mae[["microbiota"]]))
mae[["microbiota"]] <- addPrevalence(mae[["microbiota"]])
mae[["microbiota"]] <- subsetBy(
    mae[["microbiota"]],
    rows = prevalence > 0.5,
    collapse = TRUE
)
mae[["microbiota"]] <- transformAssay(
    mae[["microbiota"]],
    method = "clr",
    pseudocount = 0.5
)
mae[["microbiota"]] <- transformAssay(
    mae[["microbiota"]],
    assay.type = "clr",
    method = "standardize",
    MARGIN = "rows",
    name = "clr-z"
)

# 3. Metabolites: log10 and standardization
mae[["metabolites"]] <- transformAssay(
    mae[["metabolites"]],
    assay.type = "nmr",
    method = "log10"
)
mae[["metabolites"]] <- transformAssay(
    mae[["metabolites"]],
    assay.type = "log10",
    method = "standardize",
    MARGIN = "rows",
    name = "log10-z"
)

# 4. Biomarkers: standardization
mae[["biomarkers"]] <- transformAssay(
    mae[["biomarkers"]],
    assay.type = "signals",
    method = "standardize",
    MARGIN = "rows",
    name = "z"
)

# 5. Create and train the MOFA model
model <- mofa2(
    mae,
    experiments = c("microbiota", "metabolites", "biomarkers"),
    assays = c("clr-z", "log10-z", "z"),
    num_factors = 3
)
model <- run_mofa(model, use_basilisk = TRUE)
# 6. Explained variance per factor and layer, and in total
plot_list <- plot_variance_explained(
    model,
    x = "view", y = "factor",
    plot_total = TRUE
)
plot_list[[1]]

plot_list[[2]]


# 7. Samples colored by diet
plot_factors(model, factors = c(1, 2), color_by = "Diet")


# 8. Top weights for the microbiota and the metabolites
plot_top_weights(model, view = "microbiota", factors = c(1, 2), nfeatures = 10)

plot_top_weights(model, view = "metabolites", factors = c(1, 2), nfeatures = 10)

  1. Compare whether the diet groups are separated along the first components or factors in both methods, and which features have the largest loadings or weights in both. Note that the sign and order of the components can differ between the methods. The methods can give different results, because they use different transformations and assumptions. Joint-RPCA uses the rclr transformation, treats zeros as missing values and is designed for sparse and compositional data. MOFA assumes normally distributed data, and the microbiota data was CLR-transformed with a pseudocount and standardized. Also the filtering of the genera differed between the methods.
Unifying the analysis of high-throughput sequencing datasets: Characterizing RNA-seq, 16S rRNA gene sequencing and selective growth experiments by compositional data analysis. Fernandes et al. (2014). Microbiome 2:15. doi:10.1186/2049-2618-2-15.
Back to top