
<!-- README.md is generated from README.Rmd. Please edit that file -->

# rchime <a href="https://mothur.org/rchime/"><img src="man/figures/logo.png" align="right" height="136" alt="rchime website" /></a>

<!-- badges: start -->

[![R-CMD-check](https://github.com/mothur/rchime/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mothur/rchime/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/mothur/rchime/graph/badge.svg)](https://app.codecov.io/gh/mothur/rchime)
[![pkgdown](https://github.com/mothur/rchime/actions/workflows/pkgdown.yaml/badge.svg)](https://github.com/mothur/rchime/actions/workflows/pkgdown.yaml)
<!-- [![CRAN status](https://www.r-pkg.org/badges/version/rchime)](https://CRAN.R-project.org/package=rchime) -->
<!--[![CRAN downloads](https://cranlogs.r-pkg.org/badges/rchime)](https://CRAN.R-project.org/package=rchime) -->
[![](https://img.shields.io/badge/ORCID-Patrick%20Schloss-A6CE39.svg)](https://orcid.org/0000-0002-6935-4275)
[![](https://img.shields.io/badge/ORCID-Sarah%20Westcott-A6CE39.svg)](https://orcid.org/0009-0001-1529-8247)
<!-- badges: end -->

## Overview

The *rchime* package allows you to detect and remove chimeras from your
dataset using a de novo approach or alternatively a reference model.
This package uses code from the
[vsearch](https://github.com/torognes/vsearch) tools.

- `rchime()` detect and remove chimeras from your
  [strollur](https://mothur.org/strollur/) dataset object or data.frame

## Installation

You can install the CRAN version with:

``` r
install.packages("rchime")
```

## Development version

You can install the development version of rchime from
[GitHub](https://github.com/mothur/rchime) with:

``` r
pak::pak("mothur/rchime")
```

## Usage

The `rchime()` function accepts [strollur](https://mothur.org/strollur/)
objects or data.frames as inputs. Let’s create a
[strollur::strollur](https://mothur.org/strollur/reference/strollur.html)
object using files from [mothur’s](https://mothur.org)
[Miseq_SOP](https://mothur.org/wiki/miseq_sop/) example analysis. Then
we will use the *de novo* method in `rchime()` to detect and remove the
chimeras from the dataset.

``` r
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")
#> Added 6084 sequences.
strollur::assign(data, table = abundance_data, type = "sequence_abundance")
#> Assigned 6084 sequence abundances.

chimera_report <- rchime(data)
#> ℹ The denovo method runs with a single processor.
#> Added a chimera_report report.
#> → rchime removed `10453` chimeras from your dataset.
#> → It took `4.26320099830627` seconds to detect and remove the chimeras.

data
#> rchime de novo example:
#> 
#>             starts ends nbases ambigs polymers numns   numseqs
#> Minimum:         1  249    249      0        3     0      1.00
#> 2.5%-tile:       1  252    252      0        4     0   2955.05
#> 25%-tile:        1  252    252      0        4     0  29550.50
#> Median:          1  253    253      0        4     0  59101.00
#> 75%-tile:        1  253    253      0        5     0  88651.50
#> 97.5%-tile:      1  254    254      0        6     0 115246.95
#> Maximum:         1  256    256      0        8     0 118202.00
#> Mean:            1  252    252      0        4     0  59101.14
#> 
#> scrap_summary:
#>       type      trash_code unique total
#> 1 sequence rchime-chimeras   3588 10453
#> 
#> Number of unique seqs: 2496 
#> Total number of seqs: 118202 
#> 
#> Total number of samples: 20 
#> Total number of custom reports: 1
```

## References

Many thanks for the great work of the
*[vsearch](https://github.com/torognes/vsearch/graphs/contributors)* and
*[uchime](https://www.drive5.com/usearch/manual/chimeras.html)* teams!

- Rognes T, Flouri T, Nichols B, Quince C, Mahé F. (2016) VSEARCH: a
  versatile open source tool for metagenomics. PeerJ 4:e2584. doi:
  10.7717/peerj.2584

- Edgar,R.C., Haas,B.J., Clemente,J.C., Quince,C. and Knight,R. (2011),
  UCHIME improves sensitivity and speed of chimera detection.
  Bioinformatics 27:2194.

## Code of Conduct

Please note that the rchime project is released with a [Contributor Code
of Conduct](http://mothur.org/rchime/CODE_OF_CONDUCT.html). By
contributing to this project, you agree to abide by its terms.
