genos2indAlleles: Convert a genotype data table to an allele data frame

View source: R/genos2indAlleles.R

genos2indAllelesR Documentation

Convert a genotype data table to an allele data frame

Description

A long-format data table of genotypes is converted into a wide-format data table of alleles, where each locus is represented by two columns: one for the first allele, the other for the second allele.

Usage

genos2indAlleles(dat, sampCol = "SAMPLE", locusCol = "LOCUS", genoCol = "GT")

Arguments

dat

Data.table: Contains samples and loci in rows, with a separate column endcoding genotypes, where each allele is separated by a '/'.

sampCol

Character: Column with sample information. Default = 'SAMPLE'.

locusCol

Character: Column with locus information. Default = 'LOCUS'.

genoCol

Character: Column with genotype information. Default = 'GT'.

Value

A data frame in wide format, with a sample column $SAMPLE and 2 * number of loci additional columns containing alleles for each locus. For example, $locus1_1 and $locus1_2 will contain the first and second allele for "locus1".

Examples

library(genomalicious)
data(data_Genos)

data_Genos

alle_dt <- genos2indAlleles(data_Genos)

# The first three loci, with count of allele 1 and 2.
alle_dt[1:4, 1:7]


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