calculate_contribution_scores: Calculate contribution scores for each view in each sample

View source: R/contribution_scores.R

calculate_contribution_scoresR Documentation

Calculate contribution scores for each view in each sample

Description

This function calculates, *for each sample* how much each view contributes to its location in the latent manifold, what we call contribution scores

Usage

calculate_contribution_scores(
  object,
  views = "all",
  groups = "all",
  factors = "all",
  scale = TRUE
)

Arguments

object

a trained 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'

scale

logical indicating whether to scale the sample-wise variance explained values by the total amount of variance explained per view. This effectively normalises each view by its total variance explained. It is important when different amounts of variance is explained for each view (check with plot_variance_explained(..., plot_total=TRUE))

Details

Contribution scores are calculated in three steps:

  • Step 1calculate variance explained for each cell i and each view m (R_{im}), using all factors

  • Step 2(optional) scale values by the total variance explained for each view

  • Step 3calculate contribution score (C_{im}) for cell i and view m as:

    C_{im} = \frac{R2_{im}}{\sum_{m} R2_{im}}

Note that contribution scores can be calculated using any number of data modalities, but it is easier to interpret when you specify two.
Please note that this functionality is still experimental, contact the authors if you have questions.

Value

adds the contribution scores to the metadata slot (samples_metadata(MOFAobject)) and to the MOFAobject@cache slot

Examples

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


bioFAM/MOFA2 documentation built on Feb. 1, 2024, 6:41 a.m.