# Introduction

The data set consists of N=200 samples from a cohort of Chronic Lymphocytic Leukemia (CLL) patients where four omics were profiled from blood samples: DNA methylation (450K Illumina microarray), bulk RNA-seq, somatic mutations and drug response data from blood for N=200 patients with. The data set was introduced in detail [in this article](https://www.jci.org/articles/view/93801) and can be downloaded [here](http://bioconductor.org/packages/release/data/experiment/html/BloodCancerMultiOmics2017.html). The MOFA analysis was originally published [here](https://msb.embopress.org/cgi/doi/10.15252/msb.20178124)

# Load libraries

Make sure that you have installed the [MOFA2](https://github.com/bioFAM/MOFA2#installation) and the [MOFAdata](https://www.bioconductor.org/packages/release/data/experiment/html/MOFAdata.html) package.

```{r, message=FALSE}
library(data.table)
library(ggplot2)
library(tidyverse)
library(MOFA2)
library(MOFAdata)
library(randomForest)
library(survival)
library(survminer)
```

# Load data 

Data is stored as a list of matrices. Features are stored in the rows and samples in the columns.

```{r}
utils::data("CLL_data")       
lapply(CLL_data,dim)
```

## mRNA expression

The mRNA expression has been normalised by library size, followed by a variance stabilizing transformation using [DESeq2](https://bioconductor.org/packages/release/bioc/html/DESeq2.html):

```{r}
hist(CLL_data$mRNA)
```

## DNA methylation

DNA methylation is calculated for every CpG site using the [M-value](https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-11-587), which provides a better summary statistic for downstream analysis. For the MOFA analysis we selected the top 1% (N=4248) most variable sites.

```{r}
hist(CLL_data$Methylation)
```

## Drug response 

In this study the authors have measured the effect of multiple drugs *ex vivo* using a high-throughput platform. 
For each drug they have measured 5 different concentrations. The value reported is the viability score (0=all cells died, 1=no cells died). 

```{r}
hist(CLL_data$Drugs)
```

## Somatic mutations

Mutations are assessed using a panel of common cancer mutations and are summarised in a binary format (0=no mutation, 1=mutation):

```{r}
table(CLL_data$Mutations)
```

## Sample metadata 

Load sample metadata as a data.frame. Important columns are:  

- **Gender**: m (male), f (female)
- **Age**: age in years
- **TTT**: time (in years) which passed from taking the sample to the next treatment
- **TTD**: time (in years) which passed from taking the sample to patients' death
- **treatedAfter**: (TRUE/FALSE)
- **Died**: whether the patient died (TRUE/FALSE)

```{r}
CLL_metadata <- fread("data/sample_metadata.txt")

head(CLL_metadata)
```

# Create the MOFA object and train the model

Create the MOFA object.

```{r message=FALSE}
MOFAobject <- create_mofa(CLL_data)
MOFAobject
```

## Plot data overview

Visualise the number of views (rows) and the number of groups (columns), what are their corresponding dimensionalities, and how many missing samples they have (grey bars).

```{r}
plot_data_overview(MOFAobject)
```

## Define MOFA options

### Model options

Two important options:

- **num_factors**: number of factors
- **likelihoods**: likelihood for each view (options are "gaussian", "poisson", "bernoulli"). By default the "gaussian" distribution is used. If data are binary, as is the case for Somatic mutations, change the likelihood to "bernoulli":

```{r}
model_opts <- get_default_model_options(MOFAobject)

model_opts$likelihoods["Mutations"] <- "bernoulli"

model_opts$num_factors <- 15

model_opts
```


## Train the MOFA model

Prepare the MOFA object.

```{r, message=FALSE}
MOFAobject <- prepare_mofa(MOFAobject,
  model_options = model_opts
)
```


Train the model: this should take ~5min, but DO NOT RUN THIS. The software has evolved since the original publication and the results will not be 100% identical to the original publication. Please load the pretrained model below for reproducibility purposes.

```{r, message=FALSE, warning=FALSE, eval=FALSE}
MOFAobject <- run_mofa(MOFAobject)
```

Load precomputed model.

```{r}
MOFAobject <- readRDS("data/MOFA2_CLL.rds")
```

## Add sample metadata to the model

The sample metadata must be provided as a data.frame and it must contain a column `sample` with the sample IDs. Make sure that the samples in the metadata match the samples in the model.

```{r}
stopifnot(CLL_metadata$sample %in% samples_metadata(MOFAobject)$sample)

samples_metadata(MOFAobject) <- CLL_metadata
```

## Rename features

In this step, we load metadata from additional files and use it to replace the uninformative drug and gene IDs with descriptive names.

Keep the model with the original variable names for the [gene set enrichment analysis section](#gene-set-enrichment-analysis).

```{r}
MOFAobject.ensembl <- MOFAobject
```

```{r}
updated_features_names <- features_names(MOFAobject)

# Rename drug IDs (i.e. D_001) to drug names (i.e. navitoclax)
drug_metadata <- fread("data/drugs.txt.gz")
tmp <- drug_metadata$name; names(tmp) <- drug_metadata$drug_id
updated_features_names[["Drugs"]] <- stringr::str_replace_all(features_names(MOFAobject)[["Drugs"]], tmp)

# Rename mRNA from ENSEMBLE IDs (i.e. ENSG00000223972) to gene names (i.e. DDX11L1)
gene_metadata <- fread("data/Hsapiens_genes_BioMart.87.txt.gz")
gene_metadata[,symbol:=ifelse(symbol=="",ens_id,symbol)]
tmp <- gene_metadata$symbol; names(tmp) <- gene_metadata$ens_id

# avoid duplicated names with the Mutations view
tmp[tmp%in%features_names(MOFAobject)[["Mutations"]]] <- paste0(tmp[tmp%in%features_names(MOFAobject)[["Mutations"]]],"_mRNA")
updated_features_names[["mRNA"]] <- stringr::str_replace_all(features_names(MOFAobject)[["mRNA"]], tmp)

# Update features names in model
features_names(MOFAobject) <- updated_features_names
```


## Variance decomposition analysis

### Variance decomposition by Factor 

**The most important insight that MOFA generates is the variance decomposition analysis**. This plot shows the percentage of variance explained by each factor across each data modality.

```{r}
plot_variance_explained(MOFAobject, max_r2=10)
```

What insights from the data can we learn just from inspecting this plot?  

- **Factor 1** captures a source of variability that is present across almost all data modalities. Thus, its etiology is likely to be something very important for the disease.
- **Factor 2** captures a strong source of variation that is exclusive to the drug response data. 
- **Factor 3** captures a strong source of variation that is exclusive to the mRNA data. 
- **Factor 4** and **Factor 5** capture some co-variation between the mRNA and the drug response assay.

**(Q) Based on the MOFA output, if you were to profile just one molecular layer, which one would you choose to maximise the amount of sources of variation captured?**

# Characterisation of Factor 1

There are a few systematic strategies to characterise the molecular signal that underlies each MOFA Factor and to relate them to existent sample covariates:

- **Association analysis between the sample metadata and the Factor values**.  
- **Inspection of factor values**.  
- **Inspection of the feature weights**.  
- **Gene set enrichment analysis on the mRNA weights**.  

## Association analysis

Let's test the association between the MOFA factors versus Gender and age:

```{r}
correlate_factors_with_covariates(MOFAobject, 
  covariates = c("Gender","age","died"), 
  plot = "log_pval"
)
```

Most Factors don't have a clear association with any of the covariates. However Factor 1 and Factor 14 appear to have some association with survival outcome. We will explore association with clinical measurements later in the vignette.

## Inspection of factor values

**How do we interpret the factor values?**  
Each factor captures a different source of variability in the data. Mathematically, each Factor is defined by a linear combination of the input features. Each Factor ordinates cells along a one-dimensional axis that is centered at zero. Samples with different signs manifest opposite phenotypes along the inferred axis of variation, with higher absolute value indicating a stronger effect.  
Note that the interpretation of MOFA factors is analogous to the interpretation of the principal components in PCA.

```{r}
plot_factors(MOFAobject, 
  factors = c(1,3), 
  dot_size = 2.5
)
```

## Inspection of feature weights

**How do we interpret the feature weights?**  
The weights provide a score for each feature on each factor. Features with no association with the corresponding factor are expected to have values close to zero, whereas features with strong association with the factor are expected to have large absolute values. The sign of the weights indicates the direction of the effect: a positive weight indicates that the feature has higher levels in the cells with positive factor values, and vice-versa.  

### Plot feature weights for somatic mutations

By looking at the variance explained plot, we saw that Factor 1 captures variation in all data modalities. Out of all omics, the somatic mutation data is a good place to start, as somatic mutations are very sparse, easy to interpret and any change in the DNA is likely to have downstream consequences to all other molecular layers. Let's plot the weights:

```{r}
plot_weights(MOFAobject,
 view = "Mutations",
 factor = 1,
 nfeatures = 10,     # Top number of features to highlight
 scale = T           # Scale weights from -1 to 1
)
```

Notice that most features lie at zero, indicating that most features have no association with Factor 1. There is however one gene that clearly stands out: IGHV (immunoglobulin heavy chain variable region). [This is the main clinical marker for CLL](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6355490/).  

An alternative visualisation to the full distribution of weights is to do a line plot that displays only the top features with the corresponding weight sign on the right:

```{r}
plot_top_weights(MOFAobject,
 view = "Mutations",
 factor = 1,
 nfeatures = 10,     # Top number of features to highlight
 scale = TRUE        # Scale weights from -1 to 1
)
```

IGHV has a positve weight. This means that samples with positive Factor 1 values have the IGHV mutation whereas samples with negative Factor 1 values do not have the IGHV mutation. To confirm this, let's plot the Factor values and colour the IGHV mutation status.  

```{r}
plot_factor(MOFAobject, 
  factors = 1, 
  color_by = "IGHV",
  add_violin = TRUE,
  dodge = TRUE,
  show_missing = FALSE
)
```

We can also plot Factor values coloured by other covariates, for example `Gender`. As concluded from the association analysis above, this variable has no association with Factor 1:

```{r}
plot_factor(MOFAobject, 
  factors = 1, 
  color_by = "Gender",
  dodge = TRUE,
  add_violin = TRUE
)
```

### Plot gene weights for mRNA expression

From the variance explained plot we know that Factor 1 drives variation across all data modalities. Let's visualise the mRNA expression changes that are associated with Factor 1:

```{r}
plot_weights(MOFAobject, 
  view = "mRNA", 
  factor = 1, 
  nfeatures = 10
)
```

### Plot molecular signatures in the input data 

In this case we have a large amount of genes with high positive and high negative weights. Genes with large positive values will be more expressed in the samples with IGHV mutation, whereas genes with large negative values will be more expressed in the samples without the IGHV mutation. Let's verify this. The function `plot_data_scatter`  generates a scatterplot of Factor 1 values (x-axis) versus expression values (y-axis) for the top 4 genes with largest positive weight. Samples are coloured by IGHV status:

```{r}
plot_data_scatter(MOFAobject, 
  view = "mRNA",
  factor = 1,  
  features = 4,
  sign = "positive",
  color_by = "IGHV"
) + labs(y="RNA expression")
```

This function generates a scatterplot of Factor 1 values (x-axis) versus expression values (y-axis) for the top 4 genes with largest negative weight. Samples are coloured by IGHV status:

```{r}
plot_data_scatter(MOFAobject, 
  view = "mRNA",
  factor = 1,  
  features = 4,
  sign = "negative",
  color_by = "IGHV"
) + labs(y="RNA expression")
```

An alternative visualisation is to use a heatmap.

```{r}
plot_data_heatmap(MOFAobject, 
  view = "mRNA",
  factor = 1,  
  features = 25,
  cluster_rows = FALSE, cluster_cols = FALSE,
  show_rownames = TRUE, show_colnames = FALSE,
  scale = "row"
)
```

# Prediction of individual markers for personalised treatment based on the patient's IGHV status

**(Q) Can you suggest new RNA expression and DNA methylation markers for personalised treatment recommendations according to Factor 1 (the IGHV status)?**  
First explore the MOFA weights, then go back to the input data and do boxplots for the chosen markers (x-axis being the IGHV status and y-axis being the marker's expression or DNA methylation values). 

*Hints:*  
- The section [Customized analysis](#customized-analysis) may be helpful to extract the weights and the data in a long data.frame format
- the IGHV status for each sample can be fetched from the `CLL_metadata` object
- the [ggpubr](http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/) package provides very useful ggplot-based visualisations, including [boxplots with p-values](http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/76-add-p-values-and-significance-levels-to-ggplots/). I highly recommend it!

# Characterisation of Factor 3

**(Q) Your task is to provide a characterisation for Factor 3**.  

Try a similar pipeline as for Factor 1 and answer the following questions:  
- Which mutation underlies Factor 3?  
- Can you identify mRNA markers?  
- Do a (small) bibliographical search to check if your predictions make sense  

# Inspection of combinations of Factors

Now that we have characterised the etiology of the two main Factors, let's do a scatterplot colouring each patient by their somatic mutation profile:

```{r}
p <- plot_factors(MOFAobject, 
  factors = c(1,3), 
  color_by = "IGHV",
  shape_by = "trisomy12",
  dot_size = 2.5,
  show_missing = T
)

p <- p + 
  geom_hline(yintercept=-1, linetype="dashed") +
  geom_vline(xintercept=(-0.5), linetype="dashed")

print(p)
```

# Prediction of clinical subgroups

The scatterplot of Factor 1 vs Factor 3 reveals that a few samples are missing the somatic mutation status. In this case, the doctors were not able to classify patients into their clinical subgroups. But we can now use MOFA to exploit the molecular profiles and attempt to impute the IGHV and trisomy12 status.

```{r}
# Prepare data
df <- as.data.frame(get_factors(MOFAobject, factors=c(1,2))[[1]])

# Train the model for IGHV after removing missing observations
df$IGHV <- as.factor(samples_metadata(MOFAobject)$IGHV)
model.ighv <- randomForest(IGHV ~ ., data=df[!is.na(df$IGHV),])

# Do predictions
samples_metadata(MOFAobject)$IGHV.pred <- stats::predict(model.ighv, df)
```

```{r}
# Prepare data
df <- as.data.frame(get_factors(MOFAobject, factors=c(1,2))[[1]])

# Train the model for Trisomy12 after removing missing observations
df$trisomy12 <- as.factor(samples_metadata(MOFAobject)$trisomy12)
model.trisomy12 <- randomForest(trisomy12 ~ ., data=df[!is.na(df$trisomy12),])

samples_metadata(MOFAobject)$trisomy12.pred <- stats::predict(model.trisomy12, df)
```

Plot predictions for IGHV.

```{r}
samples_metadata(MOFAobject)$IGHV.pred_logical <- c("True","Predicted")[as.numeric(is.na(samples_metadata(MOFAobject)$IGHV))+1]

p <- plot_factors(MOFAobject, 
  factors = c(1,3), 
  color_by = "IGHV.pred",
  shape_by = "IGHV.pred_logical",
  dot_size = 2.5,
  show_missing = T
)

p <- p + 
  geom_hline(yintercept=-1, linetype="dashed") +
  geom_vline(xintercept=(-0.5), linetype="dashed")

print(p)
```

# Gene set enrichment analysis

In addition to exploring the individual weights for each factor, we can use enrichment analysis to look for signiificant associations of factors to genesets. Here, we use the Reactome genesets for illustrations, which is contained in the [MOFAdata](https://www.bioconductor.org/packages/release/data/experiment/html/MOFAdata.html) package. For more details on how the GSEA works we encourage the users to read the [GSEA vignette](https://raw.githack.com/bioFAM/MOFA2/master/MOFA2/vignettes/GSEA.html)


## Load Reactome gene set annotations

Gene set annotations are provided as a binary membership matrix. Genes are stored in the rows, pathways are stored in the columns. A value of 1 indicates that gene $j$ belongs to the pathway $i$.
```{r}
utils::data(reactomeGS)  # from MOFAdata

head(colnames(reactomeGS))
head(rownames(reactomeGS))
```


## Run enrichment analysis

These are the steps for doing [Gene Set Enrichment Analysis (GSEA) with MOFA](https://raw.githack.com/bioFAM/MOFA2/master/MOFA2/vignettes/GSEA.html):  

- **(1) Define your gene set matrix**: this can be specified as a binary matrix where rows are gene sets and columns are genes. A value of 1 indicates that gene `j` belongs to pathway `i`. A value of 0 indicates elsewise.  
- **(2) Select a gene set statistic**: the statistic used to quantify the scores at the pathway level. Must be one of the following: `mean.diff` (difference in the average weight between foreground and background genes) or `rank.sum` (difference in the sum of ranks between foreground and background genes).  
- **(3) Select a statistical test**: the statistical test used to compute the significance of the gene set statistics under a competitive null hypothesis. Must be one of the following: `parametric` (a simple and very liberal parametric t-test), `cor.adj.parametric` (parametric t-test adjusted by the correlation between features), `permutation` (unparametric, the null distribution is created by permuting the weights. This option is computationally expensive, but it preserves the correlation structure between features in the data.)  

```{r message=FALSE}
enrichment.results <- run_enrichment(
  object = MOFAobject.ensembl, 
  view = "mRNA",
  feature.sets = reactomeGS, 
  set.statistic = "mean.diff",
  statistical.test = "parametric"
)
```

The enrichment analysis returns a list of 5 elements:  

- **feature.sets**:	the feature set matrix filtered by the genes that overlap with the MOFA model.  
- **pval**:	the nominal p-values.  
- **pval.adj**:	the FDR-adjusted p-values.  
- **feature.statistics**: the feature statistics (i.e. the weights).  
- **set.statistics**: matrices with the gene set statistics.  
- **sigPathways**: list with significant pathways per factor at a specified FDR threshold  

```{r}
names(enrichment.results)
```

## Plot enrichment analysis results

Plot an overview of the number of significant pathways per factor.  
It seems that most of the Factors do not have clear gene set signatures. An exception is Factor 8, which has a very strong enrichment for genes with positive weights.

```{r}
plot_enrichment_heatmap(enrichment.results)
```

**(Q) Can you characterise Factor 8 based on the GSEA results? Which genes are driving the top enriched pathways?**  
Hint: use the function `plot_enrichment`.

**(Q) Which drugs are associated with Factor 8? What is their target pathway? Do they make biological sense?**  
Hint: use the `drug_metadata` object.

# Customized analysis

For customized exploration of weights and factors, you can directly fetch the variables from the model using `get_weights` and `get_factors`:

```{r}
weights <- get_weights(MOFAobject, 
  views = "all", 
  factors = "all", 
  as.data.frame = TRUE 
)
head(weights)
```

```{r}
factors <- get_factors(MOFAobject, 
  factors = "all", 
  as.data.frame = TRUE
)
head(factors)
```

# Building predictive models of clinical outcome

The factors inferred by MOFA can be related to clinical outcomes such as time to treatment or survival times. As this type of data is censored (not for all samples we have already observed the event) we will use [Cox models](http://www.bandolier.org.uk/painres/download/whatis/COX_MODEL.pdf) for this purpose. In a Cox proportional hazards model we model the hazard of an event occurring (e.g. death or treatment) as a function of some covariates (here the factors). If a factor has a influence on the survival time or time to treatment it will receive a high absolute coefficient in the Cox model. In particular:

- If the coefficient is positive, samples with large factor values have an increased hazard (of death or treatment) compared to samples with small factor values.
- If the coefficient is negative, samples with small factor values have an increased hazard compared to samples with a large factor values.

To fit these models we will use the `coxph` function in the `survival` package. The survival data is stored in a survival object that contains both the time a sample has been followed up and whether the event has occurred (as 0,1).

Let's take time to treatment as an example here. The sample metadata contains the follow-up times per sample in years in the column `TTT`, and the column `treatedAfter` indicated whether a treatment occurred.

### Fit Cox models

```{r}
SurvObject <- Surv(samples_metadata(MOFAobject)$TTT, samples_metadata(MOFAobject)$treatedAfter)
Z <- get_factors(MOFAobject)[[1]]
fit <- coxph(SurvObject ~ Z) 
fit
```

We can see that several factors have a significant association to time to treatment. For example, Factor 1 has a negative coefficient. Samples with low factor values have an increased hazard compared to samples with a large factor values.

### Plot Hazard ratios

**(Q) Which Factors are associated with the clinical covariate (time to next treatment)?**

Extract p-values and Cox model coefficients (i.e. hazard ratios).

```{r}
s <- summary(fit)
coef <- s[["coefficients"]]

df <- data.frame(
  factor = factor(rownames(coef), levels = rev(rownames(coef))),
  p      = coef[,"Pr(>|z|)"], 
  coef   = coef[,"exp(coef)"], 
  lower  = s[["conf.int"]][,"lower .95"], 
  higher = s[["conf.int"]][,"upper .95"]
)
```

Plot the Hazard ratio per factor, together with 95% confidence intervals.

```{r}
ggplot(df, aes(x=factor, y=coef, ymin=lower, ymax=higher, color=p<0.01)) +
  geom_pointrange() + 
  coord_flip() +
  scale_x_discrete() + 
  labs(y="Hazard Ratio", x="") + 
  geom_hline(aes(yintercept=1), linetype="dotted") +
  theme_bw()
```


# Solutions

### (Q) Based on the MOFA output, if you were to profile just one molecular layer, which one would you choose to maximise the amount of sources of variation captured?

By inspecting the variance explained plot, we can see that the RNA expression is capturing most of the sources of variation in this data set. There are only a few Factors that cannot be captured using RNA expression ( for example Factors 2 and 14). The *ex vivo* drug response assay also captures a lot of variability, but it is much harder to obtain from patient cohorts than RNA expression data. The other two data modalities are less informative: DNA methylation data is only active in Factor 1, 7, and 9, and Somatic mutations are only associated with Factor 1.  

If were were to profile just one molecular layer for a large number of patients in a cost-effective way, we would need to compare the feasibility and costs of Drug response assays and RNA sequencing. The latter is much cheaper and more standardized in the community.

### (Q) Can you suggest new RNA expression and DNA methylation markers for personalised treatment recommendations according to Factor 1 (the IGHV status)?  

We first collect the genes with the largest weights for Factor 1. Then we can do boxplots stratifying samples by IGHV status, followed by statistical testing with the null hypothesis that the average gene expression does not differ between groups (a simple t-test should work for a first exploration).  

Extract mRNA weights from the MOFA object.

```{r}

rna.weights <- get_weights(MOFAobject, 
  views = "mRNA", 
  factors = 1, 
  abs = TRUE,  # we do not distinguish between direction of effect
  as.data.frame = TRUE
)

# Extract top N genes
top.genes <- rna.weights %>%
  .[order(rna.weights$value, decreasing = T),] %>% 
  head(n=9) %>% .$feature %>% as.character
top.genes
```

Fetch mRNA data from the MOFAobject for the top genes.

```{r}
rna.data <- get_data(MOFAobject, 
  views = "mRNA", 
  as.data.frame = TRUE,
  features = list("mRNA"=top.genes)
)
head(rna.data)
```

Add IGHV status from the sample metadata.

```{r}
to.plot <- rna.data %>% 
  merge(CLL_metadata[,c("sample","IGHV")], by="sample")
colnames(to.plot)
```

(Optional) Remove samples with unknown IGHV status.

```{r}
to.plot <- to.plot[!is.na(to.plot$IGHV),]
```

Box plots with statistical comparison of means.

```{r}
ggpubr::ggboxplot(to.plot, x = "IGHV", y = "value", fill = "IGHV", facet="feature") +
  stat_compare_means() +
  labs(x="IGHV status", y="mRNA expression") +
  theme(legend.position="none")
```

### (Q) Characterise Factor 4 based on the GSEA results?

Plotting the GSEA results for Factor 4 reveals that this Factor is capturing differences in the stress response of the blood cells. We have significantly enriched pathways such as cellular response to stress or heat shock response.

```{r}
plot_enrichment(enrichment.results, factor = 4, max.pathways = 15)
```

The top genes that are driving this pathway are Heat Shock Proteins and some inflammatory markers such as TNF.

```{r}
plot_top_weights(MOFAobject, 
  view = "mRNA", 
  factor = 4, 
  nfeatures = 15
)
```

Almost all of these genes have a negative weight, with the exception of EML6, which means that they have higher levels in the samples with negative Factor 4 values:

```{r}
plot_data_scatter(MOFAobject, 
  factor = 4, 
  view = "mRNA",
  features = 6,
  add_lm = TRUE
) + labs(y="RNA expression")
```

### (Q) Which drugs are associated with Factor 4? What is their target pathway? Do they make biological sense?

```{r}
plot_top_weights(MOFAobject, 
  view = "Drugs", 
  factor = 4, 
  nfeatures = 15
)
```

```{r}
plot_data_scatter(MOFAobject, 
  view = "Drugs",
  factor = 4, 
  features = 6,
  add_lm = TRUE
) + labs(y="Viability")
```

Out of the 5 top drugs, the target category for 3 of them is Reactive Oxygen Species, which are closely related to stress response mechanisms.

```{r}
drug_metadata[grep("SD51|BAY|SD07|MIS-43|doxorubicine",drug_metadata$name),]
```

# sessionInfo

```{r}
sessionInfo()
```
