Learn R Programming

diveRsity (version 1.9.89)

readGenepop: A function to calculate allele frequencies from genepop files.

Description

readGenepop allows the calculation of various parameters from 3 digit and 2 digit genepop files. The purpose of the function is mainly as a data manipulation process to allow for easy downstream analysis.

Usage

readGenepop(infile = NULL, gp = 3, bootstrap = FALSE)

Arguments

infile
Specifies the name of the `genepop'(Rousset, 2008) file from which the statistics are to be calculated. This file can be in either the 3 digit of 2 digit format, and must contain only one whitespace separator (e.g. ``space" or ``tab") between each column including the individual names column. The number of columns must be equal to the number of loci + 1 (the individual names column). If this file is not in the working directory the file path must be given. The name must be a character string (i.e. enclosed in ``" or `').
gp
A numeric argument specifying the format of the infile. Either `3' or `2' are accepted as arguments. Default is gp = 3.
bootstrap
A logical argument specifying whether the user would like the infile data bootstrapped. If bootstrap = TRUE a genepop format object is returned. See bootstrap_file in the value section below.

Value

Details

Results from this function allow for the calculation of various population genetics statistics, such as those calculated by div.part and in.calc. Users may find it useful for data exploration. For instance by employing the plot {graphics} function, an 'ad hoc' assessment of allele size distribution can be carried out using the code in the example section below. From this example it is clear that the function will be particularly useful for those wishing to develop their own novel analysis methods.

References

Rousset, F., ``genepop'007: a complete re-implementation of the genepop software for Windows and Linux.,'' Molecular ecology resources, vol. 8, no. 1, pp. 103-6, (2008).

Examples

Run this code
# Code to plot ordered allele fragment sizes to assess mutation model.
data(Test_data, package = "diveRsity") # define data
x <- readGenepop(infile = Test_data, gp = 3, bootstrap = FALSE)
locus10_pop1 <- c(x$pop_alleles[[1]][[2]][,10],
                  x$pop_alleles[[1]][[2]][,10])
sort_order <- order(locus10_pop1, decreasing = FALSE) #sort alleles
plot(locus10_pop1[sort_order], col="red", ylab = "Allele size")

Run the code above in your browser using DataLab