## `r i`. `r names(resAnchor)` {#`r resAnchor`}

### Enrichment plots {.tabset}

The results were then visualized with the `plotEnrichment()` function:

```{r childEnrich, results='asis'}
plts_verdsplit <- plotEnrichment(object, pred_POS_only = FALSE,
                                 label_POS_only = FALSE, splitby = "prediction")
resRmd <- lapply(
  names(plts_verdsplit), 
  function(db) {
    knitr::knit_child(text = c(
    '#### `r db`',
    '',
    '```{r fig.height=6, fig.width=10}',
    'plts_verdsplit[[db]]',
    '```',
    ''
  ), 
  envir = environment(),  
  quiet = TRUE)
  }
)
cat(unlist(resRmd), sep = '\n')
```

### {-}

**Note**: If < 200 peaks in user-supplied sample, `r knitr::asis_output("\u25C7")` will be missing from plots.

### Summary table

<details>
<summary>Additional Details</summary>

Annotations were derived from a variety of sources and accessed using *RLHub* (unless custom annotations were supplied by the user). Detailed explanations of each database and type can be found [here](https://bishop-laboratory.github.io/RLHub/reference/annotations.html){target="_blank"}. The [`valr`](https://cran.r-project.org/web/packages/valr/index.html){target="_blank"} R package was implemented to test the enrichment of these features within the supplied ranges for **`r object@metadata$sampleName`**. For additional detail, please refer to the `RLSeq::featureEnrich` documentation ([link](https://bishop-laboratory.github.io/RLSeq/reference/featureEnrich.html){target="_blank"}).

</details>

<br>

```{r}
featRes <- rlresult(object, resultName = "featureEnrichment")
spec_now <- paste0(
  "featureEnrichment_",
  gsub(object@metadata$sampleName, pattern = " ", replacement = "_")
)
featRes %>%
  DT::datatable(
    options = list(
          dom = "Bfrtip", 
          scrollX = TRUE,
          pageLength = 6,
          buttons = list(
            extend  = 'collection',
            buttons = list(
              list(extend='csv', filename=spec_now),
              list(extend='excel', filename=spec_now)
            ),
            text    = 'Download'
          )
      ), colnames = c(
        "Database", "Annotation", "# tested peaks", 
        "# total peaks", "# tested annotation ranges", 
        "# total annotation ranges",
        "Mean relative distance to feature", 
        "Mean relative distance to feature (shuffled)", 
        "Pval of relative distance", "Fisher Statistic", 
        "Fisher Statistic (shuffled)", "Fisher pval", 
        "Fisher pval (shuffled)"
      )
  )
```


***
