gl.report.hamming: Reports pairwise Hamming distances between trimmed sequence...

View source: R/gl.report.hamming.r

gl.report.hammingR Documentation

Reports pairwise Hamming distances between trimmed sequence tags and the loci that gl.filter.hamming would remove

Description

Hamming distance is calculated as the number of base differences between two sequences. In the context of DArT trimmed sequences, which are anchored to the left by the restriction enzyme recognition sequence, sequences are compared starting immediately after the common recognition sequence, over a fixed-length substring (min.length bases), exactly as in gl.filter.hamming.

The function reports (a) the distribution of pairwise Hamming distances among comparable loci, and (b) for a range of candidate thresholds, the exact number of loci that gl.filter.hamming would remove. The counts in (b) are obtained by running the same comparison engine, with the same worst-to-best call-rate ordering, as the filter itself — they are therefore exact, not an approximation from the distance distribution.

Usage

gl.report.hamming(
  x,
  rs = 5,
  threshold = 3,
  min.length = 50,
  max.threshold = 10,
  plot.display = TRUE,
  plot.theme = theme_dartR(),
  plot.colors = NULL,
  plot.dir = NULL,
  plot.file = NULL,
  tag.length = NULL,
  probar = NULL,
  verbose = NULL
)

Arguments

x

Name of the genlight object containing the SNP or SilicoDArT data [required].

rs

Number of bases to skip from the start of the TrimmedSequence before extracting the comparison substring (i.e. restriction site length) [default 5].

threshold

Candidate maximum Hamming distance (number of mismatching bases) to highlight in the plots and summary, matching the threshold of gl.filter.hamming; a whole number >= 0 and smaller than min.length [default 3].

min.length

Length of the substring used for Hamming comparisons. Longer sequences are truncated to it; only loci producing a substring of exactly this length are compared, others are ignored (and would be retained by the filter) [default 50].

max.threshold

Largest threshold simulated in the loci-removed table and plot [default 10].

plot.display

Specify if plot is to be produced [default TRUE].

plot.theme

User specified theme [default theme_dartR()].

plot.colors

Vector with two color names for the borders and fill [default c("#2171B5", "#6BAED6")].

plot.dir

Directory to save the plot RDS files [default as specified by the global working directory or tempdir()]

plot.file

Filename (minus extension) for the RDS plot file [Required for plot save]

tag.length

Deprecated and ignored; distances are reported as base counts over min.length bases, not proportions [default NULL].

probar

Deprecated and ignored; the compiled engine makes a progress bar unnecessary [default NULL].

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].

Details

The function gl.filter.hamming removes one locus of a pair whose substrings are within threshold mismatches, keeping the locus with the better call rate. Because the filter is sequential (a removed locus is not used to match further loci), the number of loci removed at a given threshold cannot be derived from the pairwise distance distribution alone; this function obtains it by running the filter's own engine in simulation mode for each candidate threshold.

Pairwise distances are computed in compiled code. When the number of comparable locus pairs exceeds two million, a random sample of two million pairs is used for the distribution (the loci-removed simulation is always exact and unaffected); a note is printed when sampling occurs.

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 (once per session).

If plot.file is specified, plots are saved to the directory specified by the user, or the global default working directory set by gl.set.wd() or to the tempdir().

Examples of other themes that can be used can be consulted in

Value

Invisibly, a data frame with one row per candidate threshold (0 to max.threshold) and columns Threshold, Removed, Percent.removed, Retained and Percent.retained: the loci that gl.filter.hamming would remove at each threshold. Earlier versions returned the genlight object unchanged.

Author(s)

Author(s): Arthur Georges. Custodian: Arthur Georges – Post to https://groups.google.com/d/forum/dartr

See Also

gl.filter.hamming

Other matched report: gl.report.allna(), gl.report.callrate(), gl.report.contamination(), gl.report.excess.het(), gl.report.factorloadings(), gl.report.fstat(), gl.report.heterozygosity(), gl.report.hwe(), gl.report.ld(), gl.report.ld.map(), gl.report.locmetric(), gl.report.maf(), gl.report.overshoot(), gl.report.pa(), gl.report.rdepth(), gl.report.replicates(), gl.report.replicates.KING(), gl.report.reproducibility(), gl.report.secondaries(), gl.report.taglength()

Examples


if (isTRUE(getOption("dartR_fbm"))) testset.gl <- gl.gen2fbm(testset.gl)
res <- gl.report.hamming(testset.gl[,1:100])
res


dartR.base documentation built on Nov. 18, 2026, 9:06 a.m.