gl.filter.replicates.KING: Removes duplicate samples identified by KING-robust kinship

View source: R/gl.filter.replicates.KING.r

gl.filter.replicates.KINGR Documentation

Removes duplicate samples identified by KING-robust kinship

Description

Removes the duplicate samples identified by gl.report.replicates.KING, keeping one sample of each group of duplicates.

Usage

gl.filter.replicates.KING(
  x,
  replicates.report,
  king_threshold = 0.354,
  het_threshold = 0.8,
  loc_threshold = 100,
  recalc = FALSE,
  mono.rm = FALSE,
  verbose = NULL
)

Arguments

x

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

replicates.report

Output of gl.report.replicates.KING [required].

king_threshold

KING-robust kinship above which a pair is a duplicate [default 0.354].

het_threshold

Heterozygote share above which a pair is a duplicate; used only when the report was computed from called genotypes [default 0.80].

loc_threshold

Minimum number of loci two samples must share for their pair to be assessed [default 100].

recalc

If TRUE, recalculate the locus metadata statistics [default FALSE].

mono.rm

If TRUE, remove monomorphic and all NA loci [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

The pairs are flagged again from replicates.report$table.all with the thresholds given here: a pair is a duplicate when it shares at least loc_threshold loci and its KING-robust kinship exceeds king_threshold or, when the report was computed from called genotypes (replicates.report$input), its heterozygote share exceeds het_threshold, as in the report. Because table.all holds every pair, the thresholds can be loosened as well as tightened, except loc_threshold: pairs below the report's loc_threshold have no statistics. Flagged pairs are linked into groups and, in each group, the sample with the lowest proportion of missing genotypes (replicates.report$ind.miss) is kept (ties keep the name that sorts first) and the others are removed. With the report's thresholds the filter removes exactly replicates.report$ind.list.drop.

Run gl.filter.contamination before this function. Keeping the sample with the fewest missing genotypes favours a contaminated sample, as mixed DNA gives more calls: in a ddRAD study of collared peccaries the pair CP47-CP57 keeps CP57, a mixture of about 4/5 CP47 and 1/5 CP46.

Pairs inside a group that are not flagged themselves are listed with a warning: such a group can link two animals through a sample that is a mixture of them, and removing all but one sample would then remove a different animal. See gl.report.replicates.KING.

Value

The genlight object with the duplicate samples removed, returned invisibly.

Author(s)

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

See Also

gl.report.replicates.KING, gl.filter.replicates

Other matched filter: gl.filter.allna(), gl.filter.callrate(), gl.filter.contamination(), gl.filter.excess.het(), gl.filter.factorloadings(), gl.filter.hamming(), 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.reproducibility(), gl.filter.secondaries(), gl.filter.taglength()

Examples


t1 <- platypus.gl[1:50, ]
res <- gl.report.replicates.KING(t1, plot.out = FALSE)
t2 <- gl.filter.replicates.KING(t1, replicates.report = res)



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