distance_identities: Decay of identity along a transect

View source: R/distance_identities.R

distance_identitiesR Documentation

Decay of identity along a transect

Description

Calculates the probability of observing identical genotypes at different distances along a transect.

Usage

distance_identities(genotypes, positions, labels = 1:length(positions))

Arguments

genotypes

Vector of genotypes occupying each sampling point. Alternatively a list of vectors can be provided. Each element in the list should be a 1-d vector with an element for every sampling point along the transect, with each element the genotype observed at that sampliong point.

positions

1-d vector of positions along the transect. This should be the same length of each vector in genotypes.

labels

Optional vector of labels for each sampling point. Defaults to integers.

Details

distance_identities calculates how often pairs of identical genotypes are observed for all possible distances between sampling points along a transect. Identities are averaged over multiple years for a transect.

Value

Returns a data.frame with a row for each pair of sampling points. Columns give the labels for the points being compared, their distance, whether genotypes match, and the number of non-NA observations for each pair. If genotypes is a list this will return the average number of matches. Matches will return NaN if sampling points at some distance did not contain a plant.

Author(s)

Tom Ellis

Examples

positions <- sort(runif(16, -5,5))

# Example with vector
genotypes <- rep(letters[1:4], each=4)
distance_identities(genotypes, positions, labels = LETTERS[1:16])

# Example with list
genotypes <- list(
  rep(letters[1:4], each=4),
    rep(letters[1:4], 4)
    )
distance_identities(genotypes, positions, labels = LETTERS[1:16])

ellisztamas/simmiad documentation built on Dec. 12, 2023, 5:32 a.m.