calculate_variance_explained: Calculate variance explained by the model

Description Usage Arguments Value Examples

View source: R/calculate_variance_explained.R

Description

This function takes a trained MOFA model as input and calculates the proportion of variance explained (i.e. the coefficient of determinations (R^2)) by the MOFA factors across the different views.

Usage

1
2
3
4
5
6
calculate_variance_explained(
  object,
  views = "all",
  groups = "all",
  factors = "all"
)

Arguments

object

a MOFA object.

views

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

groups

character vector with the group names, or numeric vector with group 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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Using an existing trained model on simulated data
file <- system.file("extdata", "model.hdf5", package = "MOFA2")
model <- load_model(file)

# Calculate variance explained (R2)
r2 <- calculate_variance_explained(model)

# Plot variance explained values (view as x-axis, and factor as y-axis)
plot_variance_explained(model, x="view", y="factor")

# Plot variance explained values (view as x-axis, and group as y-axis)
plot_variance_explained(model, x="view", y="group")

# Plot variance explained values for factors 1 to 3
plot_variance_explained(model, x="view", y="group", factors=1:3)

# Scale R2 values
plot_variance_explained(model, max_r2 = 0.25)

MOFA2 documentation built on Nov. 8, 2020, 7:28 p.m.