---
title: "chimera_report"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{chimera_report}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

## Overview

The `chimera_report` generated by the `rchime()` function is a data.frame with 18 columns and a row for each sequence in your dataset. Here's a brief description of the various columns.

    1. Score: a higher score means a more likely chimeric alignment.
    2. Query: query sequence name.
    3. ParentA: parent A sequence name.
    4. ParentB: parent B sequence name.
    5. Top_Parent: top parent sequence name (i.e. parent most similar to the query).
    6. QM: percentage of similarity of query (Q) and model (M) constructed as a part of parent A and a part of parent B.
    7. QA: percentage of similarity of query (Q) and parent A.
    8. QB: percentage of similarity of query (Q) and parent B.
    9. QAB: percentage of similarity of parent A and parent B.
    10. QT percentage of similarity of query (Q) and top parent (T)
    11. LY : yes votes in the left part of the model.
    12. LN: no votes in the left part of the model.
    13. LA: abstain votes in the left part of the model.
    14. RY: yes votes in the right part of the model.
    15. RN: no votes in the right part of the model.
    16. RA: abstain votes in the right part of the model.
    17. Div: divergence, defined as (QM - QT). 
    18. Chimeric_Status: query is chimeric (Y), or not (N), or is a borderline case (?).

## Example

Let's run `rchime()` with the de novo approach to generate the chimera report, and take a closer look.

```{r}
library(rchime)

fasta_data <- readRDS(rchime_example("miseq_fasta.rds"))
abundance_data <- readRDS(rchime_example("miseq_abundance.rds"))

data <- strollur::new_dataset("rchime de novo example")

strollur::add(data, table = fasta_data, type = "sequence")
strollur::assign(data, table = abundance_data, type = "sequence_abundance")

results <- rchime(data, dereplicate = TRUE)


results <- strollur::new_dataset("rchime de novo example") |>
  strollur::add(table = fasta_data, type = "sequence") |>
  strollur::assign(
    table = abundance_data,
    type = "sequence_abundance"
  ) |>
  rchime(dereplicate = TRUE)

results$chimera_report[60:70, ]
```



