gl.fdsim: Estimates the rate of false positives in a fixed difference...

View source: R/gl.fdsim.r

gl.fdsimR Documentation

Estimates the rate of false positives in a fixed difference analysis

Description

Estimates how many fixed differences between two populations would arise from sampling error alone, given the observed allele frequencies and sample sizes, and the probability that false positives alone reach the observed count of fixed differences.

Usage

gl.fdsim(
  x,
  poppair,
  obs = NULL,
  sympatric = FALSE,
  reps = 1000,
  delta = 0.02,
  verbose = NULL
)

Arguments

x

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

poppair

Labels of two different populations for comparison, in the form c(popA, popB) [required].

obs

Observed number of fixed differences between the two populations. If NULL, it is calculated with gl.fixed.diff [default NULL].

sympatric

If TRUE, the two populations are sympatric; if FALSE, allopatric [default FALSE].

reps

Number of replicates in the simulation, a whole number of at least 2 [default 1000].

delta

The threshold value for the minor allele frequency to regard the difference between two populations as fixed [default 0.02].

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

Loci that are missing in either population are dropped, as are loci that already show a true fixed difference: minor allele frequency below delta in one population and above 1 - delta in the other. Each remaining locus can produce a false positive.

In each of reps replicates, a true allele frequency is drawn for each population and locus by binomial sampling around the observed frequency. From it, the probability that samples of the observed size show a fixed difference is computed, and a false positive is drawn with that probability. The count of false positives across loci is recorded.

For allopatric populations (sympatric = FALSE) each population is sampled from its own observed frequencies. For sympatric populations (sympatric = TRUE) both are sampled from the pooled frequency, weighted by sample size, each with its own sample size: the null hypothesis that both samples come from one gene pool.

Sample sizes are counted in alleles (twice the number of individuals) for SNP data, and in individuals for SilicoDArT data.

The p-value is the share of replicates whose count reaches the observed count, (sum(count >= obs) + 1) / (reps + 1), so the smallest reportable value is 1 / (reps + 1).

Value

A named list of four numbers:

  • observed – the observed count of fixed differences;

  • mnexpected – the mean simulated count of false positives;

  • sdexpected – the standard deviation of the simulated count of false positives;

  • prob – the probability that false positives alone reach the observed count.

Author(s)

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

See Also

Other fixed difference analysis: gl.fixed.diff()

Examples

if (isTRUE(getOption("dartR_fbm"))) testset.gl <- gl.gen2fbm(testset.gl)
fd <- gl.fdsim(testset.gl[, 1:100],
  poppair = c("EmsubRopeMata", "EmmacBurnBara"),
  reps = 100, verbose = 3
)


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