general_cline_eqn: Calculate allele frequencies for a cline

Description Usage Arguments Details Value Examples

View source: R/general_cline_eqn.R

Description

A flexible function to evaluate hybrid zone genetic cline equations, with or without introgression tails.

Usage

1
2
3
general_cline_eqn(transectDist, decrease = c(TRUE, FALSE), center, width,
  pmin = 0, pmax = 1, deltaL = NULL, tauL = NULL, deltaR = NULL,
  tauR = NULL)

Arguments

transectDist

The position(s) at which to evaluate the cline equation. Must be a numeric vector.

decrease

Is the cline decreasing in frequency? TRUE or FALSE.

center

The location of the cline center, in the same distance units as transectDist. Numeric.

width

The width of the cline, in the same distance units as transectDist. Numeric, must be greater than 0.

pmin, pmax

Optional. The minimum and maximum allele frequency values in the tails of the cline. Default values are 0 and 1, respectively. Must be between 0 and 1 (inclusive). Numeric.

deltaL, tauL

Optional delta and tau parameters which describe the left exponential introgression tail. Must supply both to generate a tail. Default is NULL (no tails). Numeric. tauL must be between 0 and 1 (inclusive).

deltaR, tauR

Optional delta and tau parameters which describe the right exponential introgression tail. Must supply both to generate a tail. Default is NULL (no tails). Numeric. tauR must be between 0 and 1 (inclusive).

Details

This function evaluates hybrid zone cline equations of the general form:

p = (e^(4*((x-center))/(width))/((1+ e^(4*((x-center))/(wwidth)))

Where center is the center of the cline, width is the width of the cline, x is the distance along the transect, and p is the expected frequency of the allele.

This function can also include introgression tails by specifying delta and tau paramters. For the left introgression tail, when x ≤ (center - δ):

p = 1/(1 + e^(4(δ)/(w)))*\exp((4τ(x-c+δ)/width)/(1+e^(-4(δ)/(w))))

For the right introgression tail, when x ≥ (center + δ):

p = 1- 1/(1 + e^(4(δ)/(w)))*\exp((-4τ(x-c-δ)/width)/(1+e^(-4(δ)/(w))))

The above equations all describe an increasing cline with minimum and maximum values of 0 and 1. This equation can be rescaled for other minima and maxima:

p' = p_{min} + (p_{max} - p_{min})*p

And for clines which decrease in frequency:

p' = p_{min} + (p_{max} - p_{min})*(1-p)

The function will automatically use the appropriate equation based on arguments supplied by the user.

Value

The result of evaluating a cline equation with the specified parameters at the specified distance(s) (that is, p' in the notation of the equations above). A numeric vector equal in length to the transectDist argument.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# Calculate the allele frequency at x = 100 for an increasing cline
# with a center at x = 125, a width of 40, and no tails.

general_cline_eqn(transectDist = 100, decrease = F,
                  center = 125, width = 40)

# Calculate the allele frequency at x = 84 and x = 100 for a decreasing cline
# with a center at 76, a width of 22, and a right tail
# with deltaR = 7.5, tauR = 0.45.

general_cline_eqn(transectDist = c(84,100), decrease = TRUE,
                 center = 76, width = 22,
                 deltaR = 7.5, tauR = .45)

## End(Not run)

tjthurman/BAHZ documentation built on May 30, 2020, 8:28 a.m.