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

Cline.fit

R Documentation

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.

Author(s)

Benjamin M. Fitzpatrick

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.

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/Cline.fit.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Cline.fit
> ### Title: Fit alternative cline functions to data from one or more genetic
> ### loci.
> ### Aliases: Cline.fit
> ### Keywords: ~kwd1 ~kwd2
>
> ### ** Examples
>
>
> data(Bluestone)
> BS.fit <- Cline.fit(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(BS.fit)
>
>
>
>
>
>
> dev.off()
null device
1
>