View source: R/gl.filter.hamming.r
| gl.filter.hamming | R Documentation |
Identifies loci with highly similar (near-duplicate) trimmed tag sequences and
removes redundant loci, preferentially retaining the locus with the better call
rate (fewer missing genotypes). Loci with near-identical tags are likely to be
fragments of the same genomic locus that the calling pipeline has split into
separate loci; retaining both yields pseudo-replicated, non-independent markers.
This function compares locus TrimmedSequence strings after skipping
a user-defined number of bases (the restriction site) and retaining a fixed-length
substring. Loci whose substrings are within threshold mismatches
(Hamming distance) are considered duplicates and one is dropped.
gl.filter.hamming(x, threshold = 3, rs = 5, min.length = 50, verbose = NULL)
x |
Name of the genlight object containing the SNP or SilicoDArT data [required]. |
threshold |
Maximum allowed Hamming distance (number of
mismatching bases) between two trimmed sequences for them to be treated as
duplicates; a whole number >= 0 and smaller than |
rs |
Number of bases to skip from the start of the TrimmedSequence before extracting the comparison substring (i.e. restriction site length) [default 5]. |
min.length |
Length of the substring used for Hamming comparisons. Despite the name, this is an exact length, not a minimum: longer sequences are truncated to it, and only loci producing a substring of exactly this length are compared; others are retained [default 50]. |
verbose |
Verbosity: 0, silent or fatal errors; 1, begin and end; 2, brief progress messages; 3, progress and results summary; 5, full report [default 2, unless specified using gl.set.verbosity]. |
This function finds near-duplicate TrimmedSequences by first taking the same fixed-length piece of sequence from every locus, then cutting that piece into several smaller sections. It relies on a simple fact: if two sequences differ by only a few letters (up to the threshold), then at least one of those sections must be exactly the same in both. So it uses the sections as 'signatures' to quickly shortlist only those loci that share an identical section, instead of comparing every locus to every other one. For each shortlisted pair, it then checks the two sequences letter-by-letter and stops as soon as it can tell they differ by more than the allowed number.
Before comparison, loci are ordered from most to least missing data (worst
to best call rate). When two loci are found to be within threshold
mismatches, the one with more missing genotypes is dropped, so the retained
locus of every duplicate pair is always the one with the better call rate.
Once a locus is dropped it is not used to match others.
Several SNPs called on the same tag (secondaries, sharing a
CloneID) have identical or near-identical TrimmedSequences, so this
filter also removes them, keeping the SNP with the better call rate. Run
after gl.filter.secondaries, it removes only near-duplicates
between different tags; run on its own, part of what it removes are
secondaries.
The function expects locus metrics to include TrimmedSequence in
x@other$loc.metrics.
Only loci whose TrimmedSequence is long enough to yield a substring of
exactly min.length are compared. Loci with shorter sequences are not
compared and are retained.
This function requires the package Rcpp and a working C++ compiler
toolchain (Rtools on Windows, Xcode Command Line Tools on macOS), as the
comparison engine is compiled at run time.
A genlight object with redundant loci removed.
Author(s): Arthur Georges. Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr
gl.report.hamming to explore the distribution of
sequence divergence before choosing a threshold.
Other matched filter:
gl.filter.allna(),
gl.filter.callrate(),
gl.filter.contamination(),
gl.filter.excess.het(),
gl.filter.factorloadings(),
gl.filter.heterozygosity(),
gl.filter.hwe(),
gl.filter.ld(),
gl.filter.locmetric(),
gl.filter.maf(),
gl.filter.monomorphs(),
gl.filter.overshoot(),
gl.filter.pa(),
gl.filter.rdepth(),
gl.filter.replicates(),
gl.filter.replicates.KING(),
gl.filter.reproducibility(),
gl.filter.secondaries(),
gl.filter.taglength()
# x must be a genlight with TrimmedSequence in x@other$loc.metrics
if (isTRUE(getOption("dartR_fbm"))) platypus.gl <- gl.gen2fbm(platypus.gl)
x <- platypus.gl
x2 <- gl.filter.hamming(x, threshold = 3, rs = 5, min.length = 50, verbose = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.