Learn R Programming

polysat (version 0.1)

codominant.to.dominant: Convert a Genotype Object to Binary Data

Description

Given a genotype object in the form of a two-dimensional list of vectors, codomiant.to.dominant produces a matrix of binary data indicating the presence and absence of alleles in samples.

Usage

codominant.to.dominant(gendata, makecolinfo = FALSE, allelepresent = 1,
alleleabsent = 0, missingin = -9, missingout = -9,
loci = dimnames(gendata)[[2]], samples = dimnames(gendata)[[1]])

Arguments

gendata
Genotypes. A two dimensional list of vectors as produced by other functions in polysat. Samples are represented in the first dimension of the list and loci in the second dimension. Each vector contains all unique alleles for a given samp
makecolinfo
Boolean. If TRUE, codominant.to.dominant also produces a data frame indicating which loci and alleles are represented in which columns.
allelepresent
The symbol to be used in the output to indicate that a sample has an allele.
alleleabsent
The symbol to be used in the output to indicate that a sample does not have an allele.
missingin
The symbol used to indicate missing data in gendata.
missingout
The symbol used to indicate missing data in the output.
loci
A character vector that is a subset of dimnames(gendata)[[2]], indicating which loci to process.
samples
A character vector that is a subset of dimnames(gendata)[[1]], indicating which samples to process.

Value

  • If makecolinfo=FALSE, a matrix is returned containing the binary genotype data. The row names of the matrix are the sample names. The column names of the matrix are locus and allele names concatenated together, separated by a period. The symbols allelepresent, alleleabsent, and missingout (by default 1, 0, and -9) are used in the matrix to indicate the presence or absence of alleles, or missing data, respectively. Loci are in the same order as in the input, and alleles are arranged in numerical order. If makecolinfo=TRUE, the matrix described above is returned as the first element of a list. The second element is a data frame with loci in the first column and alleles in the second column, with data in the same order as the columns in the matrix.

See Also

dominant.to.codominant, write.table

Examples

Run this code
# Create a data set to convert
mygendata <-
  array(list(c(124,128,138),c(122,130,140,142),c(122,132,136),c(122,134,140),
             c(203,212,218),c(197,206,221),c(215),c(200,218),
             c(140,144,148,150),c(-9),c(146,150),c(152,154,158))
        , dim=c(4,3), dimnames=list(c("ind1","ind2","ind3","ind4"),
  c("locus1","locus2","locus3")))

# Convert the data
mybinary <- codominant.to.dominant(mygendata, makecolinfo=TRUE)

# Inspect the results
mybinary[[1]]
mybinary[[2]]

Run the code above in your browser using DataLab