---
title: "Accessing preeclampsia DNAm models with eoPredData"
author:
- name: Iciar Fernandez Boyano
  affiliation: University of British Columbia
  email: iciarfernandez@outlook.com
- name: Victor Yuan
  affiliation: University of British Columbia
  email: victor.2wy@gmail.com
package: eoPredData
output:
  BiocStyle::html_document:
    self_contained: yes
    toc: true
    toc_float: true
    toc_depth: 2
    code_folding: show
abstract: |
  Access pre-trained preeclampsia models from eoPredData + ExperimentHub
date: "`r doc_date()`"
vignette: |
  %\VignetteIndexEntry{eoPredData}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r vignetteSetup, echo=FALSE, message=FALSE, warning = FALSE}
## Bib setup
library(RefManageR)
bib <- c(eoPredData = citation("eoPredData")[1])
```

# How to access eoPredData with Bioconductor

## Citing `eoPredData`

We hope that `r Biocpkg("eoPredData")` will be useful for your research. Please 
use the following information to cite the package and the overall approach. 
Thank you!

```{r "citation"}
## Citation info
citation("eoPredData")
```

# Quick start to using to `eoPredData`

Install the R packages ExperimentHub:

```{r, eval = FALSE}
if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("ExperimentHub")
BiocManager::install("mixOmics")
```

There are 2 objects associated with eoPredData:

**EHEH8090** Pre-trained model object using `mixOmics`. This model object can be used to create predictions on DNA methylation profiles collected from placental samples. Details on training and validation are described in 
`r Citep(bib[["eoPredData"]])`.

**EHEH8403** Placental DNA methylation test data (49 samples, 452 453 CpGs), used to demonstrate prediction of preeclampsia status using eoPred model. A `matrix` [cpg x sample].

```{r "start", message=FALSE, eval=FALSE}
library(ExperimentHub)
eh <- ExperimentHub()
query(eh, "eoPredData")

library(mixOmics)
# model object
eoPredModel <- eh[['EH8090']] 
# test object
x_test <- eh[['EH8403']]
dim(x_test) # 452,453 by 49
x_test <- x_test[rownames(x_test) %in% colnames(eoPredModel$X),] 
dim(x_test) # 341,281 by 49
# code to predict on x_test
predictions <- predict(eoPredModel, t(x_test), dist = "max.dist")
```

# Reproducibility

`R` session information.

```{r reproduce3, echo=FALSE}
## Session info
sessionInfo()
```

# Bibliography

```{r vignetteBiblio, results="asis", echo=FALSE, warning=FALSE, message=FALSE}
RefManageR::PrintBibliography(
    bib, .opts = list(hyperlink = "to.doc", style = "html"))
```