splitGenotypes: Split genotype columns into allele columns

View source: R/marker_allelematrix.R

splitGenotypesR Documentation

Split genotype columns into allele columns

Description

Converts a matrix or data frame with one genotype column per marker into a matrix with two allele columns per marker. Malformed genotypes give an error.

Usage

splitGenotypes(x, sep = NULL, missing = 0, clean = FALSE, colNames = FALSE)

Arguments

x

A matrix or data frame containing genotypes.

sep

Allele separator. If NULL, detected automatically from the first 50 non-missing genotypes, trying "/", ",", "-", ";" and " ".

missing

Symbol for missing alleles (default 0).

clean

If TRUE, trim whitespace and fill in missing individual alleles, e.g. "1/" becomes "1/0". Default FALSE for speed.

colNames

If TRUE, append .1 and .2 to the input column names. If FALSE (default), columns are unnamed.

Value

A matrix with twice as many columns as x, preserving row names. Missing alleles are represented by missing, except for completely missing input, which returns a matrix of zeroes.

Examples

x = cbind(M1 = c("1/2", "/3"), M2 = c(NA, "1/1"))
splitGenotypes(x, clean = TRUE, colNames = TRUE)


pedtools documentation built on Nov. 5, 2026, 5:06 p.m.