impute: Impute missing values from a fitted MOFA

View source: R/impute.R

imputeR Documentation

Impute missing values from a fitted MOFA


This function uses the latent factors and the loadings to impute missing values.


  views = "all",
  groups = "all",
  factors = "all",
  add_intercept = TRUE



a MOFA object.


character vector with the view name(s), or numeric vector with view index(es).


character vector with the group name(s), or numeric vector with group index(es).


character vector with the factor names, or numeric vector with the factor index(es).

  • response:gives mean for gaussian and poisson and probabilities for bernoulli.

  • link: gives the linear predictions.

  • inRange: rounds the fitted values from "terms" for integer-valued distributions to the next integer (default).


add feature intercepts to the imputation (default is TRUE).


MOFA generates a denoised and condensed low-dimensional representation of the data that captures the main sources of heterogeneity of the data. This representation can be used to reconstruct the data, simply using the equation Y = WX. For more details read the supplementary methods of the manuscript.
Note that with impute you can only generate the point estimates (the means of the posterior distributions). If you want to add uncertainity estimates (the variance) you need to set impute=TRUE in the training options. See get_default_training_options.


This method fills the imputed_data slot by replacing the missing values in the input data with the model predictions.


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

# Impute missing values in all data modalities
imputed_data <- impute(model, views = "all")

# Impute missing values in all data modalities using factors 1:3
imputed_data <- impute(model, views = "all", factors = 1:3)

bioFAM/MOFA2 documentation built on March 21, 2023, 5:27 p.m.