Learn R Programming

MOFA (version 1.3.1)

calculateVarianceExplained: Calculate variance explained by the model

Description

Method to calculate variance explained by the MOFA model for each view and latent factor. As a measure of variance explained for gaussian data we adopt the coefficient of determination (R2). For non-gaussian views the calculations are based on the normally-distributed pseudo-data (for more information on the non-gaussian model see Supplementary Methods of the MOFA paper or Seeger & Bouchard, 2012).

Usage

calculateVarianceExplained(object, views = "all", factors = "all")

Arguments

object

a trained MOFAmodel object.

views

character vector with the view names, or numeric vector with view indexes. Default is 'all'

factors

character vector with the factor names, or numeric vector with the factor indexes. Default is 'all'

Value

a list with matrices with the amount of variation explained per factor and view and the total variance explained per view.

Details

This function takes a trained MOFA model as input and calculates for each view the coefficient of determination (R2), i.e. the proportion of variance in the data explained by the MOFA factor(s) (both jointly and for each individual factor). In case of non-Gaussian data the variance explained on the Gaussian pseudo-data is calculated.

Examples

Run this code
# NOT RUN {
# Using an existing trained model on the CLL data
filepath <- system.file("extdata", "CLL_model.hdf5", package = "MOFAdata")
MOFA_CLL <- loadModel(filepath)
calculateVarianceExplained(MOFA_CLL)

# Using an existing trained model on the scMT data
filepath <- system.file("extdata", "scMT_model.hdf5", package = "MOFAdata")
MOFA_scMT <- loadModel(filepath)
calculateVarianceExplained(MOFA_scMT)
# }

Run the code above in your browser using DataLab