```
library(MOFA2)
library(tidyverse)
library(pheatmap)
```

To illustrate the MEFISTO method in MOFA2 we simulate a small example data set with 4 different views and one covariates defining a timeline using `make_example_data`

. The simulation is based on 4 factors, two of which vary smoothly along the covariate (with different lengthscales) and two are independent of the covariate.

```
set.seed(2020)
# set number of samples and time points
N <- 200
time <- seq(0,1,length.out = N)
# generate example data
dd <- make_example_data(sample_cov = time, n_samples = N,
n_factors = 4, n_features = 200, n_views = 4,
lscales = c(0.5, 0.2, 0, 0))
# input data
data <- dd$data
# covariate matrix with samples in columns
time <- dd$sample_cov
rownames(time) <- "time"
```

Letâ€™s have a look at the simulated latent temporal processes, which we want to recover:

```
df <- data.frame(dd$Z, t(time))
df <- gather(df, key = "factor", value = "value", starts_with("simulated_factor"))
ggplot(df, aes(x = time, y = value)) + geom_point() + facet_grid(~factor)
```