genepop_to_genind {graph4lg} | R 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
Raymond M (1995). “GENEPOP: Population genetics software for exact tests and ecumenism. Vers. 1.2.” Journal of Heredity, 86, 248–249.
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)