View source: R/structure_to_genind.R
structure_to_genind | R Documentation |
The function converts a text file in STRUCTURE format into a genind object to use in R
structure_to_genind( path, pop_names = NULL, loci_names = NULL, ind_names = NULL )
path |
A character string indicating the path to the STRUCTURE file in format .txt, or alternatively the name of the file in the working directory. The STRUCTURE file must only have :
The row for loci names is optional but recommended. Each individual is displayed on 2 rows. |
pop_names |
(optional) A character vector indicating the population names in the same order as in the STRUCTURE file. It is of the same length as the number of populations. Without this argument, populations are numbered from 1 to the total number of individuals. |
loci_names |
A character vector with the names of the loci if not specified in the file first row. This argument is mandatory if the STRUCTURE file does not include the names of the loci in the first row. In other cases, the names of the loci is extracted from the file first row |
ind_names |
(optional) A character vector indicating the individual names in the same order as in the STRUCTURE file. It is of the same length as the number of individuals. Without this argument, individuals are numbered from 1 to the total number of individuals. |
The column order of the resulting object can be different from
that of objects returned by gstud_to_genind
and genepop_to_genind
, depending on allele and loci coding
This function uses functions from pegas package.
For details about STRUCTURE file format :
STRUCTURE user manual
An object of type genind
.
P. Savary
data("data_ex_genind") loci_names <- levels(data_ex_genind@loc.fac) pop_names <- levels(data_ex_genind@pop) ind_names <- row.names(data_ex_genind@tab) path_in <- system.file('extdata', 'data_ex_str.txt', package = 'graph4lg') file_n <- file.path(tempdir(), "data_ex_str.txt") file.copy(path_in, file_n, overwrite = TRUE) str <- structure_to_genind(path = file_n, loci_names = loci_names, pop_names = pop_names, ind_names = ind_names) file.remove(file_n)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.