Skip to contents

This script calculates various distances between individuals based on sequence tag Presence/Absence data.

Usage

utils.dist.binary(
  x,
  method = "simple",
  scale = FALSE,
  swap = FALSE,
  output = "dist",
  verbose = NULL
)

Arguments

x

Name of the genlight containing the genotypes [required].

method

Specify distance measure [default simple].

scale

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

swap

If TRUE and working with presence-absence data, then presence (no disrupting mutation) is scored as 0 and absence (presence of a disrupting mutation) is scored as 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 or 1. Presence and absence equally weighted.

  • simple -- simple matching, both 1 or both 0 = 0; one 1 and the other 0 = 1. Presence and absence equally weighted.

  • Jaccard -- ignores matching 0, both 1 = 0; one 1 and the other 0 = 1. Absences could be for different reasons.

  • Bray-Curtis -- both 0 = 0; both 1 = 2; one 1 and the other 0 = 1. Absences could be for different reasons. Sometimes called the Dice or Sorensen distance.

One might choose to disregard or downweight absences in comparison with presences because the homology of absences is less clear (mutation at one or the other, or both restriction sites). Your call.

Author

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

Examples

 # \donttest{
D <- utils.dist.binary(testset.gs, method='Jaccard')
#> Starting utils.dist.binary 
#>   Processing genlight object with Presence/Absence (SilicoDArT) data
#>   Calculating the distance matrix -- jaccard 
#>   Returning a stats::dist object
#> Completed: utils.dist.binary 
#> 
D <- utils.dist.binary(testset.gs, method='Euclidean',scale=TRUE)
#> Starting utils.dist.binary 
#>   Processing genlight object with Presence/Absence (SilicoDArT) data
#>   Calculating the scaled distance matrix -- euclidean 
#>   Returning a stats::dist object
#> Completed: utils.dist.binary 
#> 
# }
D <- utils.dist.binary(testset.gs, method='Simple')
#> Starting utils.dist.binary 
#>   Processing genlight object with Presence/Absence (SilicoDArT) data
#>   Calculating the distance matrix -- simple 
#>   Returning a stats::dist object
#> Completed: utils.dist.binary 
#>