adegenet_DT2genX: Convert a long-format data table of genotypes into a...

View source: R/adegenet_DT2genX.R

adegenet_DT2genXR Documentation

Convert a long-format data table of genotypes into a genind/genlight object

Description

For a data table with samples and loci as rows (long-format data table), create a genind/genlight object, as per the adegenet package (Jombart 2011 Bioinformatics). Data must be biallelic SNPs.

Usage

adegenet_DT2genX(
  dat,
  genX,
  sampCol = "SAMPLE",
  locusCol = "LOCUS",
  genoCol = "GT",
  popCol = NULL
)

Arguments

dat

Data.table: Contains samples and loci in rows, with a separate column endcoding genotypes, where each allele is separated by a '/', or as a count of ref alleles (0, 1 or 2). Assumes biallelic loci. Code missing data as './.' for characters, and NA for Ref allele counts.

genX

Character: One of 'genind' or 'genlight'.

sampCol

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

locusCol

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

genoCol

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

popCol

Character: Column with population information. Optional. Default is NULL.

Value

A genind object, with the slot pop slot filled if argumnet popCol is specified.

References

Jombart (2008) adegenet 1.3-1: new tools for the analysis of genome-wide SNP data. Bioinformatics.

Examples

library(genomalicious)

data(data_Genos)

data_Genos

# Genind without and with populations
adegenet_DT2genX(data_Genos, genX='genind')
adegenet_DT2genX(data_Genos, genX='genind', popCol='POP')

# Genlight without and with populations
adegenet_DT2genX(data_Genos, genX='genlight')
adegenet_DT2genX(data_Genos, genX='genlight', popCol='POP')


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