View source: R/gl.report.replicates.r
| gl.report.replicates | R Documentation |
This function scans a genlight object for pairs of individuals that share a high proportion of identical genotype calls across a minimum number of jointly observed (non-missing) loci. It is intended to help detect technical replicates, sample duplicates, and other near-identical samples, and to suggest which individual to remove based on missing-data rate.
gl.report.replicates(
x,
loc_threshold = 100,
perc_geno = 0.95,
plot.out = TRUE,
plot_theme = theme_dartR(),
plot_colors = c("#2171B5", "#6BAED6"),
bins = 100,
verbose = NULL
)
x |
Name of the genlight object containing the SNP data [required]. |
loc_threshold |
Minimum number of loci required to assess that two individuals are replicates [default 100]. |
perc_geno |
Minimum percentage of genotypes in which two individuals should be the same [default 0.95]. |
plot.out |
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")]. |
bins |
Number of bins to display in histograms [default 100]. |
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]. |
What the function computes
The input is coerced to a numeric matrix. For every pair of
individuals i,j, the function counts:
'nloc' = the number of loci where both individuals have non-missing genotype calls (pairwise complete observations).
'nsame' = the number of those 'nloc' loci where the two genotype calls are identical.
'perc' = 'nsame / nloc', the proportion of identical genotype calls for that pair.
Pairs are reported as putative replicates/duplicates when both conditions hold: 'nloc > loc_threshold' and 'perc > perc_geno'.
How the computation is implemented
The pairwise counts ('nsame' and 'nloc') are computed with a C++ routine compiled at run time. This requires the Rcpp/RcppParallel packages. The first call in a session will be slower because the C++ code must be compiled; subsequent calls are fast.
A file-backed (FBM) object is read from its backing file in blocks of loci
and the pairwise counts are added block by block (serially), so the
genotype matrix is never decoded as a whole; the results are identical to
those of the same data held in memory. The pairwise counts and results
(nInd(x)^2 values) are held in memory.
Suggested individual to drop For each flagged pair, the function calculates per-individual missingness as the proportion of 'NA' genotypes across all loci. The replicate suggested for removal ('ind_to_drop') is the member of the pair with the higher missingness, so that the retained replicate maximises usable genotype information.
How to interpret the histograms When 'plot.out = TRUE', the function draws:
A histogram of 'perc' across *all* pairwise comparisons.
A zoomed histogram restricted to 'perc > 0.8' to resolve the upper tail.
In an ideal large dataset containing a mixture of unrelated and related individuals plus several replicated individuals (e.g., capture/mark/recapture), the first histogram often shows four approximate modes ('peaks'):
Unrelated pairs (lowest 'perc').
Second-degree relatives (e.g., cousins).
First-degree relatives (e.g., parent–offspring, full siblings).
Replicated/duplicate samples (highest 'perc', near 1).
To confidently separate true replicates from close relatives, the zoomed histogram should show a clear gap between the third and fourth peaks: one or more bins with zero counts between the close-relative peak and the replicate peak. If the close-relative and replicate distributions overlap (no zero-count gap), you should treat replicate calls as uncertain and consider increasing marker quality/quantity, tightening filters, or raising 'loc_threshold' and/or 'perc_geno'.
A list with three elements (returned invisibly):
table.rep: A dataframe with pairwise results of percentage of same genotypes between two individuals, the number of loci used in the comparison and the missing data for each individual.
ind.list.drop: A vector of replicated individuals suggested for removal – for each pair, the member with the higher missing-data rate (ties drop the second-named individual).
ind.list.rep: A list of of each individual that has replicates in the dataset, the name of the replicates and the percentage of the same genotype.
Author(s): Luis Mijangos. Custodian: Luis Mijangos – Post to https://groups.google.com/d/forum/dartr
Other matched report:
gl.report.allna(),
gl.report.callrate(),
gl.report.contamination(),
gl.report.excess.het(),
gl.report.factorloadings(),
gl.report.fstat(),
gl.report.hamming(),
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.KING(),
gl.report.reproducibility(),
gl.report.secondaries(),
gl.report.taglength()
if (isTRUE(getOption("dartR_fbm"))) platypus.gl <- gl.gen2fbm(platypus.gl)
res_rep <- gl.report.replicates(platypus.gl, loc_threshold = 500,
perc_geno = 0.85)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.