genepop_to_genind: Convert a GENEPOP file into a genind object

View source: R/genepop_to_genind.R

genepop_to_genindR Documentation

Convert a GENEPOP file into a genind object

Description

The function converts a text file in the format used by GENEPOP software into a genind object

Usage

genepop_to_genind(path, n.loci, pop_names = NULL, allele.digit.coding = 3)

Arguments

path

A character string with the path leading to the GENEPOP file in format .txt, or alternatively the name of this file in the working directory.

n.loci

The number of loci in the GENEPOP file (integer or numeric).

pop_names

(optional) Populations' names in the same order as in the GENEPOP file. Vector object (class character) of the same length as the number of populations. Without this parameter, populations are numbered from 1 to the number of populations.

allele.digit.coding

Number indicating whether alleles are coded with 3 (default) or 2 digits.

Details

This function uses functions from pegas package. GENEPOP file should can include microsatellites loci or SNPs with allele names of length 2 or 3 (noted as 01, 02, 03 or 04 for SNPs). The loci line(s) must not start with a spacing.

Value

An object of type genind.

Author(s)

P. Savary

References

\insertRef

raymond1995genepopgraph4lg

See Also

For more details about GENEPOP file formatting : https://genepop.curtin.edu.au:443/help_input.html For the opposite conversion, see genind_to_genepop. The output file can be used to compute pairwise FST matrix with mat_pw_fst

Examples

path_in <- system.file('extdata', 'gpop_simul_10_g100_04_20.txt',
                       package = 'graph4lg')
file_n <- file.path(tempdir(), "gpop_simul_10_g100_04_20.txt")
file.copy(path_in, file_n, overwrite = TRUE)
genepop_to_genind(path = file_n, n.loci = 20,
                  pop_names = as.character(order(as.character(1:10))))
file.remove(file_n)

graph4lg documentation built on Feb. 16, 2023, 5:43 p.m.