allele_counts: Calculate allele counts

View source: R/allele_counts.R

allele_countsR Documentation

Calculate allele counts

Description

Calculate allele counts

Usage

allele_counts(dat, biallelic = TRUE)

Arguments

dat

Character/Integer: A vector of genotypes. If the class is 'character', then assumes alleles are separated with a '/'. Doesn't have to be biallelic (see param biallelic). If the class is 'integer', then assumes counts of Alt alleles, in which case, it assumes data is biallelic.

biallelic

Logical: Is the data biallelic? Affects processing and output (see also "Value" section).

Value

A vector of alleles counts. If biallelic==TRUE, returns vector with names 'ref' and 'alt'. If biallelic==FALSE, returns a vector with names as alleles.

Examples

library(genomalicious)

# Genotypes as separated alleles, biallelic
allele_counts(c('1/1', '0/1', '0/1', '0/0', '0/0'))

# Genotypes as separated alleles, not biallelic
allele_counts(c('1/1', '2/3', '1/3', '0/0', '2/2'), biallelic=FALSE)

# Genotypes as counts of the Alt allele
allele_counts(c(2, 1, 1, 0, 0))


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