% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/validate_pedigree.R
\name{validate_pedigree}
\alias{validate_pedigree}
\title{Validate Pedigree Trios Using Mendelian Error Analysis}
\usage{
validate_pedigree(
  pedigree_file,
  genotypes_file,
  founders_file = NULL,
  trio_error_threshold = 5,
  min_markers = 10,
  single_parent_error_threshold = 2,
  verbose = TRUE,
  write_txt = TRUE,
  output_filename = "pedigree_validation_results.txt"
)
}
\arguments{
\item{pedigree_file}{Character. Path to the pedigree file (TSV/CSV/TXT)
with columns: ID, Male_Parent, Female_Parent.}

\item{genotypes_file}{Character. Path to the genotypes file (TSV/CSV/TXT)
with an ID column followed by marker columns coded as 0, 1, 2.}

\item{founders_file}{Character, optional. Path to a one-column file
listing the IDs of founder individuals. Founders with both parents
coded as 0 are left unchanged with no recommendations. Defaults to NULL.}

\item{trio_error_threshold}{Numeric. Maximum Mendelian error percentage
to classify a trio as PASS (default: 5.0). Must be between 0 and 100.}

\item{min_markers}{Integer. Minimum number of non-missing markers
required to evaluate a trio (default: 10).}

\item{single_parent_error_threshold}{Numeric. Maximum homozygous-marker
mismatch percentage for a parent to be considered acceptable during
parent-level evaluation (default: 2.0). Must be between 0 and 100.}

\item{verbose}{Logical. If TRUE, prints progress messages, a summary
table, and results to the console (default: TRUE).}

\item{write_txt}{Logical. If TRUE, writes validation results to
output_filename (default: TRUE).}

\item{output_filename}{Character. Path/name of the output file
(default: "pedigree_validation_results.txt").}
}
\value{
A data.table (returned invisibly) with one row per trio and
the following columns:
\describe{
\item{ID}{Individual ID.}
\item{Male_Parent}{Declared male parent ID.}
\item{Female_Parent}{Declared female parent ID.}
\item{Mendelian_Error_Pct}{Trio-level Mendelian error percentage.}
\item{Markers_Tested}{Number of markers with non-missing genotypes.}
\item{Status}{One of PASS, FAIL, LOW_MARKERS, NO_DATA, FOUNDERS,
MISSING_MALE_PARENT, MISSING_FEMALE_PARENT, MISSING_BOTH_PARENTS,
or NO_GENOTYPE_DATA.}
\item{Correction_Decision}{One of NONE, KEEP_BOTH,
REMOVE_MALE_PARENT, REMOVE_FEMALE_PARENT, REMOVE_BOTH,
LOW_MARKERS_KEEP_BOTH, LOW_MARKERS_REMOVE_MALE_PARENT,
LOW_MARKERS_REMOVE_FEMALE_PARENT, LOW_MARKERS_REMOVE_BOTH.}
\item{Male_Parent_Hom_Error_Pct}{Male parent homozygous-marker mismatch percentage.}
\item{Female_Parent_Hom_Error_Pct}{Female parent homozygous-marker mismatch percentage.}
\item{Best_Male_Parent}{Best-matching male parent candidate ID.}
\item{Best_Male_Parent_Error_Pct}{Homozygous mismatch percentage for the best male parent candidate.}
\item{Best_Female_Parent}{Best-matching female parent candidate ID.}
\item{Best_Female_Parent_Error_Pct}{Homozygous mismatch percentage for the best female parent candidate.}
}
}
\description{
Validates parent-offspring trios by calculating Mendelian error rates from
SNP genotype data. Identifies incorrect parentage assignments and suggests
best-matching replacements. If a list of founders is supplied, trios that
are declared founders (both parents coded as 0) are preserved unchanged
with no recommendations. Trios removed due to missing genotype data are
retained in the output with a NO_GENOTYPE_DATA status.
}
