Last data update: 2014.03.03

R: Fit alternative cline functions to data from one or more...
Cline.fitR Documentation

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


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

Usage, 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))



Data matrix of allele counts (allele diagnostic for one species desgnated 1, all others 0) by individual or sample (rows) and marker (columns).


Optional factor defining aggregation of individuals into samples (e.g., sites or populations). Length must be equal to the number of rows in Data.


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.


Character vector specifying which models to fit. Valid choices are "multinom","binom","logit.logistic","Barton","Beta", and "Richards".


Optional starting values for optimization. If NULL, start values at the 1:1 line are provided by default.


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").


The number of MCMC generations to use if "mcmc" is used for any Methods.


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.


Logical: if TRUE and method="mcmc" or "SANN", starting values will be found by first using optim with "L-BFGS-B".


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 of the data, i.e., an integer (1 or 2) to multiply the sample size (number of individuals).


Optional fraction of extreme values to omit from calculation of S (see mean).


Optional vector of column indices to include in calculation of S - can be used to omit biological outliers.


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 is included, giving the model with lowest AIC for each marker.


Benjamin M. Fitzpatrick


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


data(Bluestone) <-[,1:12],model=c("logit.logistic","Barton"))


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HIest)
Loading required package: nnet
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HIest/", width=480, height=480)
> ### Name:
> ### Title: Fit alternative cline functions to data from one or more genetic
> ###   loci.
> ### Aliases:
> ### Keywords: ~kwd1 ~kwd2
> ### ** Examples
> data(Bluestone)
> <-[,1:12],model=c("logit.logistic","Barton"))

 2  NA's were omitted

 2  NA's were omitted

 1  NA's were omitted

 1  NA's were omitted

 1  NA's were omitted

 1  NA's were omitted

 1  NA's were omitted

 1  NA's were omitted
> Cline.plot(
null device