Skip to contents

Read in genotype data from a tab-delimited file in matrix format (e.g. structure format) and convert it to a vcfR object

Usage

read.genotypes(
  file = NULL,
  data.type = "alleles",
  missing.value = "N",
  n.id.cols = NULL,
  n.id.rows = NULL,
  second.allele = "NA"
)

Arguments

file

Name of the tab-delimited file. Individuals should be in rows and alleles/genotypes should be in columns.

data.type

(character) Either "alleles" or "genotypes". Use alleles if each allele (e.g. A,C,G,T OR 1,2,3,4) is encoded separately in the file, either across rows or columns. Use genotypes if the alleles are encoded as a single genotype (e.g. 0=homozygous ref, 1=heterozygous, 2=homozygous alt). Default is alleles.

missing.value

(character) Value used for missing data. Default is "N".

n.id.cols

(numeric) Number of columns before genotypes start. Must be at least 1 with individual IDs.

n.id.rows

(numeric) Number of rows before genotypes start. Usually there is 1 with SNP IDs. If not, artificial IDs will be assigned.

second.allele

(numeric) Either "columns" or "rows". Use columns if second allele is in the next column. Use rows if second allele is in the next row. Not required if data are in genotype format.

Value

vcfR object

Examples

#read.genotypes(file = alleles.str, data.type = "alleles", missing.value = -9, n.id.cols = 2, n.id.rows = 1, second.allele = "rows")
#read.genotypes(file = genotypes.txt, data.type = "genotypes", missing.value = "N", n.id.cols = 2, n.id.rows = 1)