set_covariates {MOFA2} | R 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

[Package MOFA2 version 1.4.0 Index]