genos2freqs: Get population allele frequencies from a (long) data table of...

View source: R/genos2freqs.R

genos2freqsR Documentation

Get population allele frequencies from a (long) data table of genotypes

Description

Parses a data table of genotypes and returns a matrix of allele frequencies.

Usage

genos2freqs(
  dat,
  popCol = "POP",
  sampCol = "SAMPLE",
  locusCol = "LOCUS",
  genoCol = "GT",
  returnMat = TRUE
)

Arguments

dat

Data table: It is expected that there are only two alleles, and therefore, only three possible genotypes: 0/0, 0/1 (or 1/0), and 1/1, where the Ref allele is '0'. This data.table needs the following columns:

  1. The population ID (see param popCol).

  2. The sample ID (see param sampCol)

  3. The locus ID (see param locusCol).

  4. The genotypes (see param genoCol).

popCol

Character: The column name with the sampled individual information. Default = 'POP'.

sampCol

Character: The column name with the sampled individual information. Default = 'SAMPLE'.

locusCol

Character: The column name with the locus information. Default = 'LOCUS'.

genoCol

Character: The column name with the genotype information. Default = 'GT'.

returnMat

Logical: Should an allele frequency matrix be returned? Default = TRUE, but if FALSE, will return a data table.

Value

Returns a matrix of allele frequencies for the Alt allele, or a data table with the columns $POP, $SAMPLE, $LOCUS and $FREQ.

Examples

library(genomalicious)

# Import genotype data
data(data_Genos)
data_Genos

# Convert to frequency matrix
freqMat <- genos2freqs(data_Genos)


j-a-thia/genomalicious documentation built on Oct. 19, 2024, 7:51 p.m.