Learn R Programming

HWxtest (version 1.0.5)

fillUpper: Utility functions for handling genotype counts

Description

Interconvert between different formats for genotype counts.

Usage

fillUpper(gmat)

alleleCounts(gmat)

vec.to.matrix(gvec, alleleNames = "")

remove.missing.alleles(gmat)

matrix.to.vec(gmat)

clearUpper(gmat)

df.to.matrices(df, sep = "/")

Arguments

gmat
a matrix of non-negative integers representing genotype counts. In a matrix of genotype counts, a[i,j] and a[j,i] both represent the same heterozygote. Only the lower-left half of gmat is used. Numbers along the diag
gvec
vector containing k(k+1)/2 genotype counts. All non-negative integers. Genotype counts should be in the order: a11, a21, a22, a31, a32, ..., akk
alleleNames
an optional list of names for the alleles. The length should be $k$
df
a dataframe containing individual genotypes. Each row represents an individual. The first column, named pop names the population. Each other column is named for a particular locus. The genotypes are as 123/124
sep
For a dataframe, this is the separator character. typically /

Details

Let k be the number of alleles:
  • clearUpperfills the upper-right half of the$k x k$matrix withNA
  • fillUppermakes the$k x k$matrix symmetrical by filling the upper-right half with numbers from the lower half.
  • vec.to.matrixconverts genotype counts in vector form and returns a matrix. The vector must have$k(k+1)/2$non-negative integers.
  • matrix.to.vecconverts a$k x k$matrix of genotype counts to a vector of length$k(k+1)/2$
  • alleleCountsreturns a vector of length$k$containing the numbers of each allele. The sum of this vector will be twice the number of diploids in the sample.
  • remove.missing.allelesreturns a matrix with no0's for allele counts
  • df.to.matricesconverts a data frame to a list of genotype count matrices. The data frame should be of the kind produced in the packageadegenetwithgenind2df

Examples

Run this code
gvec <- c(0,3,1,5,18,1,3,7,5,2)
gmat <- vec.to.matrix(gvec, alleleNames=letters[1:4])
alleleCounts(gmat)

Run the code above in your browser using DataLab