Learn R Programming

MOFA (version 1.3.1)

compareFactors: Correlation of the latent factors across different trials

Description

Different objects of MOFAmodel are compared in terms of correlation between their latent factors. The correlation is calculated only on those samples which are present in all models. Ideally, the output should look like a block diagonal matrix, suggesting that all detected factors are robust under different initializations. If not, it suggests that some factors are weak and not captured by all models.

Usage

compareFactors(models, comparison = "all", show_rownames = FALSE,
  show_colnames = FALSE, ...)

Arguments

models

a list containing MOFAmodel objects.

comparison

type of comparison, either 'pairwise', i.e. compare one model with another one at a time, or 'all', i.e. calculate correlation between factors from all model. By default, all models are compared.

show_rownames

logical indicating whether to show rownames in heatmap (see also pheatmap documentation)

show_colnames

logical indicating whether to show colnames in heatmap (see also pheatmap documentation)

...

extra arguments passed to pheatmap

Value

Plots a heatmap of correlation of Latent Factors in all models when 'comparison' is 'all'. Otherwise, for each pair of models, a seperate heatmap is produced comparing one model againt the other. The corresponding correlation matrix or list or pairwise correlation matrices is returned

Details

This function can be helpful to evaluate the robustness of factors across different random initilizations. Large block of factors from different models in the correlation matrix show consistent factors, while stand-alone factors that are only recovered in a single model instance are less reliable.

Examples

Run this code
# NOT RUN {
### Example on simulated data
# Simulate Data
data <- makeExampleData()
# Create MOFA model
MOFAobject <- createMOFAobject(data)
# Prepare MOFA model
MOFAobject <- prepareMOFA(MOFAobject)
# Train several instances of MOFA models
n_inits <- 3 
MOFAlist <- lapply(seq_len(n_inits), function(i) runMOFA(MOFAobject, outfile=tempfile()))
compareFactors(MOFAlist, comparison="all")
compareFactors(MOFAlist, comparison="pairwise")
# }

Run the code above in your browser using DataLab