Learn R Programming

kairos (version 2.2.0)

fit: Frequency Increment Test

Description

Frequency Increment Test

Usage

fit(object, dates, ...)

# S4 method for data.frame,numeric fit(object, dates, calendar = CE(), level = 0.95, roll = FALSE, window = 3)

# S4 method for matrix,numeric fit(object, dates, calendar = CE(), level = 0.95, roll = FALSE, window = 3)

Value

An IncrementTest object.

Arguments

object

A \(m \times p\) numeric matrix or data.frame of count data (absolute frequencies giving the number of individuals for each category, i.e. a contingency table). A data.frame will be coerced to a numeric matrix via data.matrix().

dates

A length-\(m\) numeric vector of dates.

...

Currently not used.

calendar

An aion::TimeScale object specifying the calendar of dates (see calendar()). Defaults to Gregorian Common Era.

level

A length-one numeric vector giving the confidence level.

roll

A logical scalar: should each time series be subsetted to look for episodes of selection?

window

An odd integer giving the size of the rolling window. Only used if roll is TRUE.

Author

N. Frerebeau

Details

The Frequency Increment Test (FIT) rejects neutrality if the distribution of normalized variant frequency increments exhibits a mean that deviates significantly from zero.

If roll is TRUE, each time series is subsetted according to window to see if episodes of selection can be identified among variables that might not show overall selection.

References

Feder, A. F., Kryazhimskiy, S. & Plotkin, J. B. (2014). Identifying Signatures of Selection in Genetic Time Series. Genetics, 196(2): 509-522. tools:::Rd_expr_doi("10.1534/genetics.113.158220").

See Also

Other chronological analysis: apportion(), plot_fit

Examples

Run this code
## Data from Crema et al. 2016
data("merzbach", package = "folio")

## Keep only decoration types that have a maximum frequency of at least 50
keep <- apply(X = merzbach, MARGIN = 2, FUN = function(x) max(x) >= 50)
counts <- merzbach[, keep]

## Group by phase
## We use the row names as time coordinates (roman numerals)
dates <- as.numeric(utils::as.roman(rownames(counts)))

## Frequency Increment Test
freq <- fit(counts, dates, calendar = NULL)

## Plot time vs abundance
plot(freq, calendar = NULL, ncol = 3, xlab = "Phases")

## Plot time vs abundance and highlight selection
freq <- fit(counts, dates, calendar = NULL, roll = TRUE, window = 5)
plot(freq, calendar = NULL, ncol = 3, xlab = "Phases")

Run the code above in your browser using DataLab