gl.dist.pop: Calculates a distance matrix for populations with SNP or...

View source: R/gl.dist.pop.r

gl.dist.popR Documentation

Calculates a distance matrix for populations with SNP or Silicodart genotypes in a genlight object

Description

This script calculates various distances between populations based on allele frequencies (SNP genotypes) or frequency of presences in PA (SilicoDArT) data

Usage

gl.dist.pop(
  x,
  as.pop = NULL,
  method = "euclidean",
  scale = FALSE,
  type = "dist",
  plot.display = TRUE,
  plot.theme = theme_dartR(),
  plot.colors = NULL,
  plot.file = NULL,
  plot.dir = NULL,
  verbose = NULL
)

Arguments

x

Name of the genlight object [required].

as.pop

Temporarily assign another locus metric as the population for the purposes of deletions [default NULL].

method

Specify distance measure [default euclidean].

scale

If TRUE and method='euclidean', the distance will be scaled: for SilicoDArT data the scaled distance falls in the range [0,1]; for SNP data the attainable maximum is 0.5 (see Details) [default FALSE].

type

Specify the type of output, dist or matrix [default 'dist']

plot.display

If TRUE, resultant plots are displayed in the plot window [default TRUE].

plot.theme

Theme for the plot. See Details for options [default theme_dartR()].

plot.colors

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

plot.file

Name for the RDS binary file to save (base name only, exclude extension) [default NULL]

plot.dir

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

verbose

Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log ; 3, progress and results summary; 5, full report [default 2 or as specified using gl.set.verbosity].

Details

For SNP data, the distance measure can be one of 'euclidean', 'nei', 'reynolds', 'chord' or 'fixed-diff'. For SilicoDArT data, the distance measure can be one of 'euclidean', 'simple', 'jaccard' or 'sorensen'.

Two of the SNP measures are variants of their textbook forms. The 'reynolds' distance is the linearised (divergence-time) variant -log(1 - D) of the Reynolds, Weir and Cockerham (1983) coancestry distance D. The 'chord' distance is the Cavalli-Sforza and Edwards (1967) chord distance scaled by the constant 2*sqrt(2)/pi.

With scale=TRUE and method='euclidean', the scaled distance falls in the range [0,1] for SilicoDArT data; for SNP data the attainable maximum is 0.5 (two populations fixed for opposite alleles at every locus), a consequence of the 0.5 scaling factor applied to the SNP form.

The euclidean distance for SilicoDArT data is computed from the population frequencies of tag presence; it is a different statistic from a between-individual euclidean distance averaged over population pairs ('simple', 'jaccard' and 'sorensen' are computed the latter way, via gl.dist.ind).

Refer to the documentation of functions in https://doi.org/10.1101/2023.03.22.533737 for algorithms and definitions.

Value

An object of class 'dist' giving distances between populations

Author(s)

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

See Also

Other distance: gl.dist.ind(), gl.fst.pop(), gl.propShared(), utils.dist.ind.snp()

Examples

 
# SNP genotypes
if (isTRUE(getOption("dartR_fbm"))) possums.gl <- gl.gen2fbm(possums.gl)
D <- gl.dist.pop(possums.gl, method='euclidean')
D <- gl.dist.pop(possums.gl, method='euclidean',scale=TRUE)
D <- gl.dist.pop(possums.gl, method='nei')
D <- gl.dist.pop(possums.gl, method='reynolds')
D <- gl.dist.pop(possums.gl, method='chord')
D <- gl.dist.pop(possums.gl, method='fixed-diff')
#Presence-Absence data [only 10 individuals due to speed]
D <- gl.dist.pop(testset.gs[1:10,], method='euclidean')



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