gl.filter.hamming {dartR.base} | R Documentation |
Filters loci based on pairwise Hamming distance between sequence tags
Description
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.
Usage
gl.filter.hamming(
x,
threshold = 0.2,
rs = 5,
tag.length = 69,
plot.display = TRUE,
plot.theme = theme_dartR(),
plot.colors = NULL,
plot.file = NULL,
plot.dir = NULL,
pb = FALSE,
verbose = NULL
)
Arguments
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]. |
tag.length |
Typical length of the sequence tags [default 69]. |
plot.display |
If TRUE, histograms are displayed in the plot window [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 c("#2171B5", "#6BAED6")]. |
plot.file |
Name for the RDS binary file to save (base name only, exclude extension) [default NULL] |
plot.dir |
Directory in which to save files [default = working directory] |
pb |
If TRUE, a progress bar will be displayed [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]. |
Details
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
Value
A genlight object filtered on Hamming distance.
Author(s)
Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr
See Also
Other matched filter:
gl.filter.callrate()
,
gl.filter.ld()
,
gl.filter.locmetric()
,
gl.filter.maf()
,
gl.filter.monomorphs()
,
gl.filter.overshoot()
,
gl.filter.pa()
,
gl.filter.secondaries()
Examples
# SNP data
test <- gl.subsample.loc(platypus.gl,n=50)
result <- gl.filter.hamming(test, threshold=0.6, verbose=3)