View source: R/gl.filter.hamming.r
gl.filter.hamming | R Documentation |
Hamming distance is calculated as the number of base differences between two sequences which can be expressed as a count or a proportion. Typically, it is calculated between two sequences of equal length. In the context of DArT trimmed sequences, which differ in length but which are anchored to the left by the restriction enzyme recognition sequence, it is sensible to compare the two trimmed sequences starting from immediately after the common recognition sequence and terminating at the last base of the shorter sequence.
gl.filter.hamming(
x,
threshold = 0.2,
rs = 5,
taglength = 69,
plot.out = TRUE,
plot_theme = theme_dartR(),
plot_colors = two_colors,
pb = FALSE,
save2tmp = FALSE,
verbose = NULL
)
x |
Name of the genlight object containing the SNP data [required]. |
threshold |
A threshold Hamming distance for filtering loci [default threshold 0.2]. |
rs |
Number of bases in the restriction enzyme recognition sequence [default 5]. |
taglength |
Typical length of the sequence tags [default 69]. |
plot.out |
Specify if plot is to be produced [default TRUE]. |
plot_theme |
Theme for the plot. See Details for options [default theme_dartR()]. |
plot_colors |
List of two color names for the borders and fill of the plots [default two_colors]. |
pb |
Switch to output progress bar [default FALSE]. |
save2tmp |
If TRUE, saves any ggplots and listings to the session temporary directory (tempdir) [default FALSE]. |
verbose |
Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log ; 3, progress and results summary; 5, full report [default 2, unless specified using gl.set.verbosity]. |
Hamming distance can be computed by exploiting the fact that the dot product of two binary vectors x and (1-y) counts the corresponding elements that are different between x and y. This approach can also be used for vectors that contain more than two possible values at each position (e.g. A, C, T or G).
If a pair of DNA sequences are of differing length, the longer is truncated.
The algorithm is that of Johann de Jong
https://johanndejong.wordpress.com/2015/10/02/faster-hamming-distance-in-r-2/
as implemented in utils.hamming
.
Only one of two loci are retained if their Hamming distance is less that a specified percentage. 5 base differences out of 100 bases is a 20
A genlight object filtered on Hamming distance.
Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr
# SNP data
test <- platypus.gl
test <- gl.subsample.loci(platypus.gl,n=50)
result <- gl.filter.hamming(test, threshold=0.25, verbose=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.