calc_genetic_distances: Calculate genetic distances between individuals or groups of...

calc_genetic_distancesR Documentation

Calculate genetic distances between individuals or groups of samples.

Description

Calculates the genetic distances between either individuals or the levels of any sample specific facets, broken apart by any requested snp level facets. For details on methods, see details.

Usage

calc_genetic_distances(
  x,
  facets = NULL,
  method = "Edwards",
  interpolate = "bernoulli"
)

Arguments

x

snpRdata object.

facets

character or NULL, default NULL. Facets for which to calculate genetic distances, as described in Facets_in_snpR. If snp or base level facets are requested, distances will be between individuals. Otherwise, distances will be between the levels of the sample facets.

method

character, default "Edwards". Name of the method to use. Options:

  • Edwards Angular distance as described in Edwards 1971.

See details.

interpolate

character, default "bernoulli". Missing data interpolation method, solely for individual/individual distances. Options detailed in documentation for format_snps.

Details

If a sample facet is requested, distances are calculated via code adapted from code derived from adegenet. Please cite them alongside the tree-building and distance methods. Available methods:

  • Edwards: Angular distance as described in Edwards 1971.

  • Nei: Nei's (1978) genetic distance measure.

Otherwise, genetic distances are calculated via the dist function using genotypes formatted numerically (the "sn" option in format_snps). In all cases, missing genotypes are first interpolated according to the method provided to the 'interpolate' argument.

Value

An overwrite-safe snpRdata object with genetic distance information (a named, nested list containing distance measures named according to facets and facet levels) added.

Author(s)

William Hemstrom

References

Edwards, A. W. F. (1971). Distances between populations on the basis of gene frequencies. Biometrics, 873-881.

Nei, M. (1978). Estimation of average heterozygosity and genetic distance from a small number of individuals. Genetics, 23, 341-369.

Jombart, T. (2008). adegenet: a R package for the multivariate analysis of genetic markers Bioinformatics 24: 1403-1405.

Examples

# by pop:
y <- calc_genetic_distances(stickSNPs, facets = "pop", method = "Edwards")
get.snpR.stats(y, "pop", "genetic_distance")

# by chr and pop jointly
y <- calc_genetic_distances(stickSNPs, facets = "pop.chr", 
                            method = "Edwards")
get.snpR.stats(y, "pop.chr", "genetic_distance")

## Not run: 
# by pop and fam separately
y <- calc_genetic_distances(stickSNPs, facets = c("pop", "fam"), 
                            method = "Edwards")
get.snpR.stats(y, c("pop", "chr"), "genetic_distance")

# individuals across all snps + plot
y <- calc_genetic_distances(stickSNPs)
dat <- get.snpR.stats(y, stats = "genetic_distance")$.base$.base$Edwards
heatmap(as.matrix(dat))

## End(Not run)

hemstrow/snpR documentation built on March 20, 2024, 7:03 a.m.