Learn R Programming

pedtools (version 2.12.0)

splitGenotypes: 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)

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.

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.

Examples

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

Run the code above in your browser using DataLab