% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Amatrix.R
\name{Amatrix}
\alias{Amatrix}
\title{Construction of Relationship Matrix A}
\usage{
Amatrix(
  data = NULL,
  ploidy = 2,
  w = 0,
  verify = TRUE,
  dominance = FALSE,
  slater = FALSE,
  ASV = FALSE,
  ...
)
}
\arguments{
\item{data}{Pedigree data frame in a 3-column format. Unknown values should 
be set to 0.}

\item{ploidy}{An even number representing the ploidy level (default is 2).}

\item{w}{Proportion of parental gametes that are IBD due to double 
reduction (default is 0). Applicable only when \code{ploidy = 4}.}

\item{verify}{Logical; if TRUE (default), the pedigree file is checked for 
conflicting entries.}

\item{dominance}{Logical; if TRUE, computes the dominance relationship 
matrix (valid only for \code{ploidy = 2}).}

\item{slater}{Logical; if TRUE and \code{ploidy = 4}, computes the additive 
autotetraploid relationship matrix using Slater (2013).}

\item{ASV}{Logical; if TRUE, transforms the matrix into the average 
semivariance (ASV) defined as 
\eqn{K = K / (\text{trace}(K) / (\text{nrow}(K) - 1))}. See Feldmann et al. 
(2022), Formula 2.}

\item{...}{Additional arguments passed to \code{datatreat()}.}
}
\value{
A square matrix representing the relationship between individuals 
in the pedigree.
}
\description{
Constructs an additive relationship matrix (A) from pedigree data in a 
three-column format. The calculation depends on the specified ploidy level 
(must be an even  number). If \code{ploidy = 4}, the matrix can incorporate a 
user-defined proportion (\code{w}) of parental gametes that are IBD 
(Identical by Descent) due to double reduction.

When \code{ploidy = 2} and \code{dominance = FALSE}, the diploid additive 
numerator relationship matrix is built using Henderson's (1976) method. If 
\code{dominance = TRUE}, a diploid dominance numerator relationship matrix 
is computed following Cockerham (1954). The recursive approach is detailed 
in Mrode (2005).

For \code{ploidy > 2} and \code{dominance = FALSE}, an autopolyploid 
additive relationship matrix is computed based on Kerr et al. (2012). 
If \code{slater = TRUE} and \code{ploidy = 4}, Slater's (2013) method is 
used instead.
}
\note{
This function uses compiled C++ code via Rcpp for improved performance.
}
\examples{
data(ped.mrode)
# Additive relationship matrix for diploids (Henderson 1976):
Amatrix(ped.mrode, ploidy = 2)

# Dominance relationship matrix for diploids (Cockerham 1954):
Amatrix(ped.mrode, ploidy = 2, dominance = TRUE)

# Additive relationship matrix for autotetraploids (Kerr 2012):
Amatrix(ped.mrode, ploidy = 4)

# Additive relationship matrix for autooctaploids (Kerr 2012):
Amatrix(ped.mrode, ploidy = 8)

# Additive relationship matrix for autotetraploids with double reduction 
# (Kerr 2012):
Amatrix(ped.mrode, ploidy = 4, w = 0.1)

# Additive relationship matrix for autotetraploids with double reduction 
# using Slater (2013):
Amatrix(ped.mrode, ploidy = 4, w = 0.1, slater = TRUE)

# Additive relationship matrix for autohexaploids with double reduction 
# (Kerr 2012):
Amatrix(ped.mrode, ploidy = 6, w = 0.1)

}
\references{
\emph{Cockerham, C.C. (1954). An extension of the concept of partitioning 
  hereditary variance for analysis of covariances among relatives when 
  epistasis is present. Genetics, 39, 859–882.}

\emph{Feldmann, M.J., et al. (2022). Average semivariance directly yields 
  accurate estimates of the genomic variance in complex trait analyses. 
  G3 (Bethesda), 12(6).}

\emph{Henderson, C.R. (1976). A simple method for computing the inverse 
  of a numerator relationship matrix used in prediction of breeding values. 
  Biometrics, 32, 69–83.}

\emph{Kerr, R.J., et al. (2012). Use of the numerator relationship matrix 
  in genetic analysis of autopolyploid species. Theoretical and Applied 
  Genetics, 124, 1271–1282.}

\emph{Mrode, R.A. (2014). Linear Models for the Prediction of Animal 
  Breeding Values (3rd ed.). CABI.}

\emph{Slater, A.T., et al. (2013). Improving the analysis of low 
  heritability complex traits for enhanced genetic gain in potato. 
  Theoretical and Applied Genetics, 127, 809–820.}
}
\author{
Rodrigo R Amadeu, \email{rramadeu@gmail.com}

Thiago de Paula Oliveira, \email{toliveira@abacusbio.com}
}
