distance {DNABarcodes} | R Documentation

## Calculate distance between two barcodes.

### Description

The function calculates the distance between two barcodes. The user may choose one of several distance metrics (`"hamming"`, `"seqlev"`, `"levenshtein"`, `"phaseshift"`).

### Usage

    distance(sequence1, sequence2, metric=c("hamming","seqlev","levenshtein", "phaseshift"), cost_sub=1, cost_indel=1)

### Arguments

`sequence1` | The first sequence (a string)
`sequence2` | The second sequence (a string)
`metric` | The distance metric which should be calculated.
`cost_sub` | The cost weight given to a substitution.
`cost_indel` | The cost weight given to insertions and deletions.

### Value

The distance between the two sequences.

### References

Buschmann, T. and Bystrykh, L. V. (2013) Levenshtein error-correcting barcodes for multiplexed DNA sequencing. BMC bioinformatics, 14(1), 272. Available from http://www.biomedcentral.com/1471-2105/14/272.

Levenshtein, V. I. (1966). Binary codes capable of correcting deletions, insertions and reversals. In Soviet physics doklady (Vol. 10, p. 707).

Hamming, R. W. (1950). Error detecting and error correcting codes. Bell System technical journal, 29(2), 147-160.

### Examples

    distance("AGGT", "TTCC")
    distance("AGGT", "TTCC", metric="seqlev")

[Package DNABarcodes version 1.12.0 Index]