genotypeToCharacter: Convert number of A alleles to character genotypes

View source: R/genotypeToCharacter.R

genotypeToCharacterR Documentation

Convert number of A alleles to character genotypes

Description

Converts a vector or matrix of genotypes encoded as number of A alleles to character strings of the form "A/B".

Usage

genotypeToCharacter(geno, alleleA=NULL, alleleB=NULL, sort=TRUE)

Arguments

geno

Vector or matrix of genotype values, encoded as number of A alleles. If a matrix, dimensions should be (snp, sample).

alleleA

Character vector with allele A.

alleleB

Character vector with allele B.

sort

Logical for whether to sort alleles lexographically ("G/T" instead of "T/G").

Details

If geno is a vector, alleleA and alleleB should have the same length as geno or length 1 (in the latter case the values are recycled).

If geno is a matrix, length of alleleA and alleleB should be equal to the number of rows of geno.

If alelleA or alleleB is NULL, returned genotypes will have values "A/A", "A/B", or "B/B".

Value

Character vector or matrix of the same dimensions as geno.

Author(s)

Stephanie Gogarten

See Also

GenotypeData

Examples

geno <- matrix(c(0,1,2,0,1,2,1,NA), nrow=4)
alleleA <- c("A","T","C","T")
alleleB <- c("C","G","G","A")
genotypeToCharacter(geno, alleleA, alleleB)

smgogarten/GWASTools documentation built on May 18, 2024, 1:19 a.m.