R: Read Allelic Data Files

read.loci {pegas} | R Documentation

## Read Allelic Data Files

### Description

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.

### Usage

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

### Arguments

`file` | a file name specified by either a variable of mode character, or a quoted string.
`header` | a logical specifying whether the first line of the data file gives the names of the loci (`TRUE` by default).
`loci.sep` | the character(s) separating the loci (columns) in the data file (a white space by default).
`allele.sep` | the character(s) separating the alleles for each locus in the data file (a forward slash by default).
`col.pop` | 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.
`col.loci` | 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`).

### Details

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).

### Value

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 http://ape-package.ird.fr/pegas/DefinitionDataClassesPegas.pdf

### Author(s)

Emmanuel Paradis

### See Also

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

[Package pegas version 0.13 Index]