Learn R Programming

HIest (version 2.0)

Cline.fit: Fit alternative cline functions to data from one or more genetic loci.

Description

This function takes individual or population data for multiple genetic loci and fits genomic clines. This implementation assumes markers are diagnostic.

Usage

Cline.fit(Data, By = NULL, S = NULL, model, Start = NULL, Methods = NULL, iterations = 99, SD = NULL, headstart = TRUE, Grid = FALSE, ploidy = 2, trim = 0, include = 1:ncol(Data))

Arguments

Data
Data matrix of allele counts (allele diagnostic for one species desgnated 1, all others 0) by individual or sample (rows) and marker (columns).
By
Optional factor defining aggregation of individuals into samples (e.g., sites or populations). Length must be equal to the number of rows in Data.
S
Optional alternative values for the genome wide hybrid index. By default, the mean ancestry across all loci in Data will be used. If S is specified, the values given by the user trump the default.
model
Character vector specifying which models to fit. Valid choices are "multinom","binom","logit.logistic","Barton","Beta", and "Richards".
Start
Optional starting values for optimization. If NULL, start values at the 1:1 line are provided by default.
Methods
Optional named list of strings indicating the optimization method for each cline model (logit-logistic, Barton, Beta, and Richards). Choices are "L-BFGS-B", "SANN", and "mcmc". Default is Methods=list(logit.logistic="L-BFGS-B",Barton="L-BFGS-B",Beta="L-BFGS-B",Richards="L-BFGS-B").
iterations
The number of MCMC generations to use if "mcmc" is used for any Methods.
SD
Dispersion parameters for the "mcmc" and "SANN" methods. In these methods, new parameter values are proposed by drawing values from normal distributions centered on the current value and with standard deviations from SD.
headstart
Logical: if TRUE and method="mcmc" or "SANN", starting values will be found by first using optim with "L-BFGS-B".
Grid
Logical: if TRUE and method="mcmc" and model="Beta", starting values for the Markov Chain will be found by finding the highest likelihood on a 100 x 100 grid made by mu <- seq(from=0.02,to=0.90,length.out=10); nu <- 2^(0:9)/10.
ploidy
Ploidy of the data, i.e., an integer (1 or 2) to multiply the sample size (number of individuals).
trim
Optional fraction of extreme values to omit from calculation of $S$ (see mean).
include
Optional vector of column indices to include in calculation of $S$ - can be used to omit biological outliers.

Value

A list including a named matrix for each fitted model. Each such matrix includes the parameter estimates, maximum log-likelihood, AICc, squared Mahalanobis distance D2, P-value for Mahalanobis-based outlier detection, and TRUE/FALSE declaration of whether a marker is an outlier based on a Bonferroni-adjusted critical P-value. If more than one model was fit, an additional data frame best.fit is included, giving the model with lowest AIC for each marker.

References

Fitzpatrick, B. M. 2012. Alternative forms for genomic clines. In prep

See Also

See gcline.fn for the basic fitting function. Cline.plot provides an easy way to visualize the output of Cline.fit.

Examples

Run this code
	
data(Bluestone)
BS.fit <- Cline.fit(Bluestone[,1:12],model=c("logit.logistic","Barton"))
Cline.plot(BS.fit)

Run the code above in your browser using DataLab