set_covariates: Add covariates to a MOFA model

View source: R/mefisto.R

set_covariatesR Documentation

Add covariates to a MOFA model

Description

Function to add continuous covariate(s) to a MOFA object for training with MEFISTO

Usage

set_covariates(object, covariates)

Arguments

object

an untrained MOFA

covariates

Sample-covariates to be passed to the model. This can be either:

  • a character, specifying columns already present in the samples_metadata of the object

  • a data.frame with columns "sample", "covariate", "value". Sample names need to match those present in the data

  • a matrix with smaples in columns and covariate(s) in row(s)

Note that the covariate should be numeric and continuous.

Details

To activate the functional MEFISTO framework, specify mefisto_options when preparing the training using prepare_mofa

Value

Returns an untrained MOFA with covariates filled in the corresponding slots

Examples

#' # Simulate data
dd <- make_example_data(sample_cov = seq(0,1,length.out = 100), n_samples = 100, n_factors = 4)

# Create MOFA object
sm <- create_mofa(data = dd$data)

# Add a covariate
sm <- set_covariates(sm, covariates = dd$sample_cov)
sm

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