plot_variance_explained_by_covariates: Plot variance explained by the smooth components of the model

plot_variance_explained_by_covariatesR Documentation

Plot variance explained by the smooth components of the model

Description

This function plots the variance explained by the smooth components (Gaussian processes) underlying the factors in MEFISTO across different views and groups, as specified by the user.

Usage

plot_variance_explained_by_covariates(
  object,
  factors = "all",
  x = "view",
  y = "factor",
  split_by = NA,
  min_r2 = 0,
  max_r2 = NULL,
  compare_total = FALSE,
  legend = TRUE
)

Arguments

object

a MOFA object

factors

character vector with a factor name(s), or numeric vector with the index(es) of the factor(s). Default is "all".

x

character specifying the dimension for the x-axis ("view", "factor", or "group").

y

character specifying the dimension for the y-axis ("view", "factor", or "group").

split_by

character specifying the dimension to be faceted ("view", "factor", or "group").

min_r2

minimum variance explained for the color scheme (default is 0).

max_r2

maximum variance explained for the color scheme.

compare_total

plot corresponding variance explained in total in addition

legend

logical indicating whether to add a legend to the plot (default is TRUE).

Details

Note that this function requires the use of MEFISTO. To activate the functional MEFISTO framework, specify mefisto_options when preparing the training using prepare_mofa

Value

A list of ggplot objects (if compare_total is TRUE) or a single ggplot object. Consider using cowplot::plot_grid(plotlist = ...) to combine the multiple plots that this function generates.

Examples

# load_model
file <- system.file("extdata", "MEFISTO_model.hdf5", package = "MOFA2")
model <- load_model(file)
plot_variance_explained_by_covariates(model)

# compare to toal variance explained
plist <- plot_variance_explained_by_covariates(model, compare_total = TRUE)
cowplot::plot_grid(plotlist = plist)

bioFAM/MOFA2 documentation built on June 12, 2024, 3:57 p.m.