Skip to contents

This script calculates various distances between individuals based on SNP genotypes.

Usage

utils.dist.ind.snp(
  x,
  method = "Euclidean",
  scale = FALSE,
  output = "dist",
  verbose = NULL
)

Arguments

x

Name of the genlight containing the genotypes [required].

method

Specify distance measure [default Euclidean].

scale

If TRUE and method='Euclidean', the distance will be scaled to fall in the range [0,1] [default FALSE].

output

Specify the format and class of the object to be returned, dist for a object of class dist, matrix for an object of class matrix [default "dist"].

verbose

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

Value

An object of class 'dist' or 'matrix' giving distances between individuals

Details

The distance measure can be one of:

  • Euclidean – Euclidean Distance applied to Cartesian coordinates defined by the loci, scored as 0, 1 or 2.

  • Simple – simple mismatch, 0 where no alleles are shared, 1 where one allele is shared, 2 where both alleles are shared.

  • Absolute – absolute mismatch, 0 where no alleles are shared, 1 where one or both alleles are shared.

  • Czekanowski (or Manhattan) calculates the city block metric distance by summing the scores on each axis (locus).

Author

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

Examples

 # \donttest{
D <- utils.dist.ind.snp(testset.gl, method='Manhattan')
#> Starting utils.dist.ind.snp 
#>   Processing genlight object with SNP data
#>   Calculating the distance matrix -- manhattan 
#>   Returning a stats::dist object
#> Completed: utils.dist.ind.snp 
#> 
D <- utils.dist.ind.snp(testset.gl, method='Euclidean',scale=TRUE)
#> Starting utils.dist.ind.snp 
#>   Processing genlight object with SNP data
#>   Calculating the scaled distance matrix -- euclidean 
#>   Returning a stats::dist object
#> Completed: utils.dist.ind.snp 
#> 
# }
D <- utils.dist.ind.snp(testset.gl, method='Simple')
#> Starting utils.dist.ind.snp 
#>   Processing genlight object with SNP data
#>   Calculating the distance matrix -- simple 
#>   Returning a stats::dist object
#> Completed: utils.dist.ind.snp 
#>