joinMap2designMatrix: Genotype coding

View source: R/quantgen.R

joinMap2designMatrixR Documentation

Genotype coding

Description

Convert genotypes encoded in the JoinMap format into a design matrix. Genotypes are assumed to come from a bi-parental family with heterozygous parents (population type CP in JoinMap). * When phase information is not used, see equation 3 of Wang (2011) for the parameterization, as well as Chiquet et al (2016) for the constraints. Additive and dominance effects are handled, but epistasis is ignored. * When phase information is used, each marker is coded with four columns, one per parental haplotype. Only additive effects are handled.

Usage

joinMap2designMatrix(
  jm,
  use.phase = FALSE,
  parameterization = "allele",
  constraints = NULL,
  rm.col.zeros = TRUE,
  rm.dom = FALSE,
  verbose = 1
)

Arguments

jm

data frame in the JoinMap format, for instance from genoClasses2JoinMap; the first three columns should be "locus", "seg" and "phase"; any "clas" column will be discarded; if use.phase=FALSE, "phase" will also be discarded; no missing data is allowed

use.phase

if TRUE, phase information will be used

parameterization

parameterization (allele/F_infinity/allele-count); ignored if use.phase=TRUE

constraints

constraints (NULL/mu-zero/last-zero); ignored if use.phase=TRUE

rm.col.zeros

if TRUE, the columns full of zeros will be removed

rm.dom

if TRUE, the columns corresponding to dominance effects will be removed; ignored if use.phase=TRUE

verbose

verbosity level (0/1)

Value

matrix, with genotypes in rows and markers in columns

Author(s)

Timothee Flutre

See Also

genoClasses2JoinMap, writeSegregJoinMap, updateJoinMap

Examples

## Not run: nb.snps <- 6
x <- data.frame(par1=c("AA", "GC", "CG", "AT", NA, "AA"),
                par2=c("AT", "GC", "GG", "AT", "AT", "AT"),
                off1=c("AA", "GG", "CG", "AA", "AA", "AT"),
                off2=c("AT", "GG", "CG", "AT", "AT", "AA"),
                off3=c("AT", "GG", "GG", "TT", "TT", NA),
                off4=c(NA, NA, NA, NA, NA, NA),
                row.names=paste0("snp", 1:nb.snps),
                stringsAsFactors=FALSE)
jm <- genoClasses2JoinMap(x=x, reformat.input=TRUE, thresh.na=2, verbose=1)
jm <- jm[! is.na(jm$seg),
         c("seg", grep("^off", colnames(jm), value=TRUE))]
jm <- cbind(locus=rownames(jm), jm)
any.na <- apply(jm, 2, function(x) any(is.na(x)))
jm <- jm[, - which(any.na)]
joinMap2designMatrix(jm)

## End(Not run)

timflutre/rutilstimflutre documentation built on Feb. 7, 2024, 8:17 a.m.