---
title: "2.C: miEEA & rbioapi"
author: "Moosa Rezwani"
description: >
 Connect to miEAA in R with rbioapi package. 
date: "`r Sys.Date()`"
output:
  rmarkdown::html_vignette:
    toc: true
    anchor_sections: true
    number_sections: true
    self_contained: true
    dev: png
    encoding: 'UTF-8'

vignette: >
  %\VignetteIndexEntry{2.C: miEEA & rbioapi}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r message=FALSE, include=FALSE, results="hide", setup, echo=FALSE}
knitr::opts_chunk$set(echo = TRUE,
                      eval = TRUE,
                      message = FALSE,
                      warning = FALSE,
                      collapse = TRUE,
                      tidy = FALSE,
                      cache = FALSE,
                      dev = "png",
                      comment = "#>")
library(rbioapi)
rba_options(timeout = 30, skip_error = TRUE)
```

------------------------------------------------------------------------

## Introduction {#introduction .heading2}

The miRNA Enrichment Analysis and Annotation Tool ([miEAA](https://ccb-compute2.cs.uni-saarland.de/mieaa2 "https://ccb-compute2.cs.uni-saarland.de/mieaa2")) is a service provided by the [Chair for Clinical Bioinformatics at Saarland University](https://www.ccb.uni-saarland.de/). Basically, miEAA is a multi-species microRNA enrichment analysis tool. For more information, see their [website](https://ccb-compute2.cs.uni-saarland.de/mieaa2 "https://ccb-compute2.cs.uni-saarland.de/mieaa2") or [published paper](https://doi.org/10.1093/nar/gkaa309 "miEAA 2.0: integrating multi-species microRNA enrichment analysis and workflow management systems").

------------------------------------------------------------------------

## First, find **enrichment categories** {.heading2}

Before Performing enrichment analysis on a miRNA set, note that based on your input **miRNA type** (either all mature or precursor, not a mixture of both!) and the **species**, there will be different [sets](https://ccb-compute2.cs.uni-saarland.de/mieaa2/downloads/ "miEEA integrated data sets") of supported **enrichment categories.**

Thus, it is recommended to retrieve a list of possible enrichment categories that you may use:

```{r rba_mieaa_cats, eval=FALSE}
## A list of available enrichment categories for:
## mature human miRNA:
rba_mieaa_cats(mirna_type = "mature", species = 9606)
## precursor human miRNA
rba_mieaa_cats(mirna_type = "precursor", species = 9606)
## precursor zebrafish miRNA
rba_mieaa_cats(mirna_type = "mature", species = "Danio rerio")
```

------------------------------------------------------------------------

## Submit Enrichment analysis request to miEAA {#submit-enrichment-analysis-request-to-mieaa .heading2}

There are two approaches to do this, we will start with the simpler one.

### Approach 1: Using the Wrapper function {#approach-1-using-the-wrapper-function .heading3}

Just fill the arguments of `rba_mieaa_enrich()` according to the function's manual; As you can see in the function's arguments, you have a lot of controls over your enrichment request, but you need to provide `test_set`, `mirna_type`, `test_type`, and `species`:

```{r rba_mieaa_enrich, message=TRUE}
## 1 We create a variable with our miRNAs' mature IDs
mirs <- c("hsa-miR-20b-5p", "hsa-miR-144-5p", "hsa-miR-17-5p", "hsa-miR-20a-5p",
         "hsa-miR-222-3p", "hsa-miR-106a-5p", "hsa-miR-93-5p", "hsa-miR-126-3p",
         "hsa-miR-363-3p", "hsa-miR-302c-3p", "hsa-miR-374b-5p", "hsa-miR-18a-5p",
         "hsa-miR-548d-3p", "hsa-miR-135a-3p", "hsa-miR-558", "hsa-miR-130b-5p",
         "hsa-miR-148a-3p")
## 2a We can perform enrichment analysis on our miRNA set without limiting the analysis to any categories
mieaa_all <- rba_mieaa_enrich(test_set = mirs,
                             mirna_type = "mature",
                             test_type = "ORA",
                             species = 9606)
## 2b Or, We can limit the enrichment to certain datasets (enrichment categories)
mieaa_kegg <- rba_mieaa_enrich(test_set = mirs,
                              mirna_type = "mature",
                              test_type = "ORA",
                              species = 9606,
                              categories = "KEGG_mature"
                             )
```

```{r mieaa_kegg_table, echo=FALSE}
if (is.data.frame(mieaa_kegg)) {
  DT::datatable(data = mieaa_kegg,
              options = list(scrollX = TRUE, 
                             paging = TRUE,
                             fixedHeader = TRUE,
                             keys = TRUE,
                             pageLength = 10))

} else {
  print("Vignette building failed. It is probably because the web service was down during the building.")
}
```

### Approach 2: Going step-by-step {#approach-2-going-step-by-step .heading3}

As stated before, `rba_mieaa_enrich()` is a wrapper function, meaning that it executes the following sequence of functions:

```{r rba_meaa_submit/status/results, eval=FALSE}
## 1 Submit enrichment request to miEAA
request <- rba_mieaa_enrich_submit(test_set = mirs,
                                  mirna_type = "mature",
                                  test_type = "ORA",
                                  species = 9606,
                                  categories = c("miRWalk_Diseases_mature",
                                                 "miRWalk_Organs_mature")
                                  )
## 2 check for job's running status
rba_mieaa_enrich_status(job_id = request$job_id)

## 3 If the job has completed, retrieve the results
results <- rba_mieaa_enrich_results(job_id = request$job_id)
```

**Please Note:** Other services supported by rbioapi also provide Over-representation analysis tools. Please see the vignette article [Do with rbioapi: Over-Representation (Enrichment) Analysis in R](rbioapi_do_enrich.html) ([link to the documentation site](https://rbioapi.moosa-r.com/articles/rbioapi_do_enrich.html)) for an in-depth review.

------------------------------------------------------------------------

## Convert miRNA accessions {#convert-mirna-accessions .heading2}

miEAA only recognizes miRBASE version 22 accessions. You can use `rba_mieaa_convert_version()` to convert miRNA accession between different miRBASE versions. Also, as stated before, miEAA differentiate between precursor and mature miRNA accessions, to convert between these 2 accession types, use `rba_mieaa_convert_type()`.

------------------------------------------------------------------------

## How to Cite? {#citations .heading2}

To cite miEAA (Please see <https://ccb-compute2.cs.uni-saarland.de/mieaa2/>):

-   Fabian Kern, Tobias Fehlmann, Jeffrey Solomon, Louisa Schwed, Nadja Grammes, Christina Backes, Kendall Van Keuren-Jensen, David Wesley Craig, Eckart Meese, Andreas Keller, miEAA 2.0: integrating multi-species microRNA enrichment analysis and workflow management systems, Nucleic Acids Research, Volume 48, Issue W1, 02 July 2020, Pages W521--W528, <https://doi.org/10.1093/nar/gkaa309>

To cite rbioapi:

-   Moosa Rezwani, Ali Akbar Pourfathollah, Farshid Noorbakhsh, rbioapi: user-friendly R interface to biologic web services' API, Bioinformatics, Volume 38, Issue 10, 15 May 2022, Pages 2952--2953, <https://doi.org/10.1093/bioinformatics/btac172>

------------------------------------------------------------------------

## Links {#links .heading2}

-   [This article in rbioapi documentation site](https://rbioapi.moosa-r.com/articles/rbioapi_mieaa.html "2.B: miEEA & rbioapi")

-   [Functions references in rbioapi documentation site](https://rbioapi.moosa-r.com/reference/index.html#section-mieaa-rba-mieaa- "rbioapi reference")

-   [rbioapi vignette index](rbioapi.html "rbioapi: User-Friendly R Interface to Biologic Web Services' API")

------------------------------------------------------------------------

## Session info {#session-info .heading2}

```{r sessionInfo, echo=FALSE}
sessionInfo()
```
