read.loci: Read Allelic Data Files

Description Usage Arguments Details Value Author(s) See Also


This function reads allelic data from a text file: rows are individuals, and columns are loci and optional variables. By default, the first line of the file gives the locus names. If one column is labelled ‘population’, it is taken as a population variable.


read.loci(file, header = TRUE, loci.sep = "", allele.sep = "/|",
          col.pop = NULL, col.loci = NULL, ...)



a file name specified by either a variable of mode character, or a quoted string.


a logical specifying whether the first line of the data file gives the names of the loci (TRUE by default).


the character(s) separating the loci (columns) in the data file (a white space by default).


the character(s) separating the alleles for each locus in the data file (a forward slash by default).


specifies whether one of the column of the data file identifies the population. By default, if one column is labelled ‘population’ (case-insensitive), it is taken as the population variable; otherwise an integer giving the number of the column or a character string giving its name. It is eventually renamed ‘population’ and transformed as a factor.


a vector of integers or characters specifying the indices or the names of the columns that are loci. By default, all columns are taken as loci except the population one, if present or specified.


further arguments passed to read.table (e.g., row.names).


The rownames of the returned object identify the individual genotypes; they are either taken from the data file if present, or given the values "1", "2", ... Similarly for the colnames: if absent in the file (in which case header = FALSE must be set), they are given the values "V1", "V2", ...

In the returned genotypes, alleles are separated by "/", even if it is not the case in the data file.

The vignette “Reading Genetic Data Files Into R with adegenet and pegas” explains how to read various file formats including Excel files (type vignette("ReadingFiles") in R).


A data frame with class c("loci", "data.frame"). It is a data frame with an attribute "locicol" specifying the columns that must be treated as loci. The latter are factors. The other columns can be of any type.

Details on the structure can be found in


Emmanuel Paradis

See Also

read.gtx, read.vcf, write.loci, summary.loci

Search within the pegas package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.