plot_top_weights: Plot top weights

View source: R/plot_weights.R

plot_top_weightsR Documentation

Plot top weights

Description

Plot top weights for a given factor and view.

Usage

plot_top_weights(
  object,
  view = 1,
  factors = 1,
  nfeatures = 10,
  abs = TRUE,
  scale = TRUE,
  sign = "all"
)

Arguments

object

a trained MOFA object.

view

a string with the view name, or an integer with the index of the view.

factors

a character string with factors names, or an integer vector with factors indices.

nfeatures

number of top features to display. Default is 10

abs

logical indicating whether to use the absolute value of the weights (Default is FALSE).

scale

logical indicating whether to scale all weights from -1 to 1 (or from 0 to 1 if abs=TRUE). Default is TRUE.

sign

can be 'positive', 'negative' or 'all' to show only positive, negative or all weights, respectively. Default is 'all'.

Details

An important step to annotate factors is to visualise the corresponding feature weights.
This function displays the top features with highest loading whereas the function plot_top_weights plots all weights for a given latent factor and view.
Importantly, the weights of the features within a view have relative values and they should not be interpreted in an absolute scale. Therefore, for interpretability purposes we always recommend to scale the weights with scale=TRUE.

Value

Returns a ggplot2 object

Examples

# Using an existing trained model on simulated data
file <- system.file("extdata", "model.hdf5", package = "MOFA2")
model <- load_model(file)

# Plot top weights for Factors 1 and 2 and View 1
plot_top_weights(model, view = 1, factors = c(1,2))

# Do not take absolute value
plot_weights(model, abs = FALSE)


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