View source: R/find_parentage.R
| find_parentage | R Documentation |
Assigns the most likely parent(s) to each progeny from SNP genotype data using Mendelian error rates or homozygous mismatch rates. Parents or progeny absent from the genotype file are removed with a warning.
find_parentage(
genotypes_file,
parents_file,
progeny_file,
method = "best_pair",
min_markers = 10,
error_threshold = 5,
show_ties = TRUE,
allow_parent_selfing = FALSE,
exclude_self_match = TRUE,
verbose = TRUE,
plot_results = TRUE
)
genotypes_file |
Path to a TSV/CSV/TXT file, OR a data.frame / data.table with an 'id' column followed by marker columns coded as 0, 1, 2. |
parents_file |
Path to a TSV/CSV/TXT file, OR a data.frame / data.table with an 'id' column and an optional 'sex' column ('M', 'F', or 'A'). If absent, all parents are treated as ambiguous. |
progeny_file |
Path to a TSV/CSV/TXT file, OR a data.frame / data.table with an 'id' column. |
method |
Character. One of "best_male_parent", "best_female_parent", "best_match", or "best_pair" (default). |
min_markers |
Integer. Minimum markers required; fewer flags low_markers (default: 10). |
error_threshold |
Numeric. Maximum mismatch percentage; exceeded values flag high_error (default: 5.0). Must be between 0 and 100. |
show_ties |
Logical. If TRUE, tied best pairs are appended as suffix columns. Default is TRUE. |
allow_parent_selfing |
Logical. If FALSE, candidate pairs with identical male and female parent IDs are excluded. Applies only when method is "best_pair". Default is FALSE. |
exclude_self_match |
Logical. If TRUE, each progeny ID is excluded from its own candidate parent set, preventing self-matches when progeny are also present in the parents file. Default is TRUE. |
verbose |
Logical. If TRUE, prints progress and summary. Default is TRUE. |
plot_results |
Logical. If TRUE, plots the Mendelian error distribution. Requires ggplot2. Default is TRUE. |
A named list (returned invisibly) with elements:
Progeny with a confident parentage assignment.
Progeny whose best assignment exceeds the error threshold.
Progeny with insufficient markers for a valid assignment.
Complete data.table with all progeny and all output columns.
ggplot object if plot_results = TRUE, otherwise NULL.
Josue Chinchilla-Vargas
geno_df <- data.frame(
id = c("P1", "P2", "P3", "Off1", "Off2"),
S1 = c(0L, 2L, 0L, 1L, 0L),
S2 = c(2L, 0L, 2L, 1L, 2L),
S3 = c(0L, 2L, 0L, 1L, 0L),
S4 = c(2L, 0L, 2L, 1L, 2L),
S5 = c(0L, 2L, 0L, 1L, 0L),
S6 = c(2L, 0L, 2L, 1L, 2L),
S7 = c(0L, 2L, 0L, 1L, 0L),
S8 = c(2L, 0L, 2L, 1L, 2L),
S9 = c(0L, 2L, 0L, 1L, 0L),
S10 = c(2L, 0L, 2L, 1L, 2L)
)
parents_df <- data.frame(
id = c("P1", "P2", "P3"),
sex = c("M", "F", "F"),
stringsAsFactors = FALSE
)
progeny_df <- data.frame(
id = c("Off1", "Off2"),
stringsAsFactors = FALSE
)
results <- find_parentage(
genotypes_file = geno_df,
parents_file = parents_df,
progeny_file = progeny_df,
method = "best_pair",
verbose = FALSE,
plot_results = FALSE
)
print(results$full_results)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.