% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/expected_genotype_dist.R
\name{expected_genotype_dist}
\alias{expected_genotype_dist}
\alias{calculate_expected_genotype_distribution}
\title{Expected Allele Genotype Distribution Calculator}
\usage{
expected_genotype_dist(marType, croType, Gn = 2, x, y = 0)
}
\arguments{
\item{marType}{Character string specifying the marker type. Options include:
\itemize{
  \item \code{"22", "21", "20", "12", "11", "10", "02", "01", "00"}: Both flanking markers observed
  \item \code{"N2", "N1", "N0"}: Only right flanking marker observed
  \item \code{"2N", "1N", "0N"}: Only left flanking marker observed
}
These codes represent different combinations of flanking marker genotypes.}

\item{croType}{Character string specifying the cross type:
\itemize{
  \item \code{"Fn"}: F-n generation populations
  \item \code{"BCP1"}: Backcross to parent 1
  \item \code{"BCP2"}: Backcross to parent 2
  \item \code{"F2"}: F2 generation
  \item \code{"DH"}: Doubled haploid
  \item \code{"RIL"}: Recombinant inbred line
}}

\item{Gn}{Numeric value specifying the generation number. Must be greater than 0.}

\item{x}{Numeric value representing recombination fraction between loci A and Q.
Must be between 0 and 0.5.}

\item{y}{Numeric value representing recombination fraction between loci Q and B.
Must be between 0 and 0.5. Default is 0.}
}
\value{
A numeric value representing the expected probability of the specified genotype.
  The result is typically between -1 and 1, where positive values indicate higher
  probability of the target genotype.
}
\description{
Calculates expected allele genotype distribution probabilities for different marker types
and cross types in genetic mapping studies. This function implements sophisticated algorithms
to compute genotype probabilities based on flanking marker information and population structure.
}
\details{
This function calculates expected genotype probabilities using different approaches:

\strong{Marker Type Classification:}
\itemize{
  \item \strong{Double flanking markers} (\code{"22", "21", "20", etc.}): Both left and right
        flanking markers are observed, providing maximum information
  \item \strong{Single right flanking marker} (\code{"N2", "N1", "N0"}): Only the right
        flanking marker is observed
  \item \strong{Single left flanking marker} (\code{"2N", "1N", "0N"}): Only the left
        flanking marker is observed
}

\strong{Calculation Methods by Cross Type:}
\itemize{
  \item \strong{Fn populations}: Uses \code{\link{genotype_freq}} for complex calculations
        involving multiple genotype classes
  \item \strong{F2, DH, RIL}: Uses analytical formulas based on classical genetics
  \item \strong{BCP1, BCP2}: Uses \code{\link{genotype_freq}} with specific genotype indices
}

\strong{Mathematical Framework:}
The function uses different probability calculations depending on the available information:
\itemize{
  \item When both flanking markers are observed, it uses conditional probabilities
  \item When only one flanking marker is observed, it uses marginal probabilities
  \item The calculations incorporate recombination fractions and population-specific parameters
}

\strong{Genotype Coding:}
The marker types use a coding system where:
\itemize{
  \item \code{2}: Homozygous for alternative allele
  \item \code{1}: Heterozygous
  \item \code{0}: Homozygous for reference allele
  \item \code{N}: Missing or unknown genotype
}
}
\examples{
# Calculate probability for RIL population
prob_ril <- expected_genotype_dist("00", "RIL", Gn = 2, x = 0.1, y = 0.2)

# Example with different recombination fractions
prob_low_rec <- expected_genotype_dist("22", "F2", Gn = 2, x = 0.05, y = 0.05)
prob_high_rec <- expected_genotype_dist("22", "F2", Gn = 2, x = 0.3, y = 0.4)

}
\references{
Haldane, J.B.S. (1919). The combination of linkage values and the calculation of 
distances between the loci of linked factors. Journal of Genetics, 8(3), 299-309.
}
\seealso{
\code{\link{genotype_freq}} for genotype frequency calculations,
         \code{\link{genotype_prob}} for missing genotype imputation
}
