Learn R Programming

SimRVSequences (version 0.2.7)

genos2sparseMatrix: Convert genotypes to haplotypes.

Description

This function may be used to convert phased genotype data for diplod organisms into a sparse matrix.

Usage

genos2sparseMatrix(genotypes)

Arguments

genotypes

A dataframe or matrix of genotypes. The columns of genotypes are assumed to be individuals (i.e. a diploid human) and the rows are assumed to be mutations. See details.

Value

A sparseMatrix. Note that the rows and columns of the returned matrix have been transposed so that individual haplotypes are rows, and each column represents an SNV.

Details

The columns of genotypes are assumed to be individuals (i.e. a diploid human) and the rows are assumed to be mutations. Thus, the (i,j)th entry of genotypes is the genotype of the jth person at the ith SNV site. Please note that genotypes should not contain missing values. Additionally, genotypes may take one of the following three forms:

  • "0|0" if the individual is homozygous for the reference allele,

  • "0|1" or "0|1" if the individual is heterozygous for the alternate allele,

  • "1|1" if the individual is homozygous for the alternate allele.