Skip to content

Add parentage functions#64

Merged
alex-sandercock merged 23 commits into
developmentfrom
add_parentage_functions
Jun 5, 2026
Merged

Add parentage functions#64
alex-sandercock merged 23 commits into
developmentfrom
add_parentage_functions

Conversation

@alex-sandercock

@alex-sandercock alex-sandercock commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces several improvements and updates to the BIGr package, including enhanced documentation, new functionality, and updates to dependencies and imports. The most significant changes are the addition of a new pedigree validation export, expanded documentation for core functions, and updates to how dependencies are managed.

Documentation and Functionality Enhancements:

  • Improved documentation for allele_freq_poly and solve_composition_poly functions in R/breedtools_functions.R, including clearer parameter descriptions, return values, and example usage. This makes the functions easier to understand and use for both developers and end-users. [1] [2]
  • Refactored and clarified the implementation of allele_freq_poly, QPsolve, and solve_composition_poly for better readability and maintainability, including more explicit use of base:: for base R functions and improved handling of input matrices. [1] [2]

New Exports and Imports:

  • Added validate_pedigree to the list of exported functions in NAMESPACE, making it available for package users.
  • Expanded NAMESPACE imports to include additional functions from dplyr, ggplot2, and janitor, supporting new or updated functionality and improving data manipulation and visualization capabilities.

Dependency and Configuration Updates:

  • Updated the package version from 0.7.0 to 0.8.0 in DESCRIPTION to reflect the new features and changes.
  • Added Config/roxygen2/version: 8.0.0 to DESCRIPTION to specify the required Roxygen2 version for documentation generation.

josuechinchilla and others added 22 commits April 22, 2026 13:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… or file paths, updated documentation and test files
…ring genotype matrices for comparisons. updated test file to accomodate nw arguments
Replaced separate with extract to parse SNP ID into CHROM and POS. Updated POS formatting to handle leading zeros.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates BIGr’s pedigree/parentage tooling by introducing list-based, in-memory-friendly outputs (and optional plotting) for parentage workflows, alongside broad documentation/test updates and minor package configuration changes.

Changes:

  • Refactors validate_pedigree() and find_parentage() to return invisible named lists (with full_results, subsets, and optional ggplot output) and to accept in-memory inputs in addition to file paths.
  • Overhauls check_ped() behavior and tests to align with id/male_parent/female_parent naming and a richer, structured report.
  • Updates documentation/man pages, NAMESPACE imports/exports, and package metadata (version bump, roxygen config, build ignores).

Reviewed changes

Copilot reviewed 14 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
R/validate_pedigree.R Refactors pedigree validation to list-based output, adds plotting, removes file-writing, adds in-memory input support.
R/find_parentage.R Refactors parentage assignment to list-based output, adds self-match controls and plotting, removes file-writing, adds in-memory input support.
R/check_ped.R Reworks pedigree QC/correction reporting and options; supports in-memory inputs and standardizes column naming.
R/updog2vcf.R Adjusts SNP-to-CHROM/POS parsing logic to be more robust to extra underscores and leading zeros.
R/imputation_concordance.R Documentation/import hygiene improvements for concordance utility.
R/breedtools_functions.R Documentation and readability refactors in breed composition helpers.
NAMESPACE Exports validate_pedigree; expands targeted imports (dplyr/ggplot2/janitor/data.table).
DESCRIPTION Version bump to 0.8.0 and roxygen2 config update.
inst/check_ped_test.txt Updates fixture headers/content to male_parent/female_parent convention.
tests/testthat/test-validate_pedigree.R Rewrites/expands tests for new return structure, plotting flag, and in-memory inputs.
tests/testthat/test-find_parentage.R Rewrites/expands tests for new return structure, new flags, plotting flag, and in-memory inputs.
tests/testthat/test-check_ped.R Replaces prior minimal test with comprehensive structured tests for new report outputs and behaviors.
tests/testthat/corrected_pedigree.txt Removes previously written-output fixture (reflects “no write” behavior).
man/*.Rd Regenerates man pages to match refactored APIs and docs.
.Rbuildignore Ignores .positai and .claude directories.
.gitignore Ignores .positai.
Files not reviewed (6)
  • man/allele_freq_poly.Rd: Language not supported
  • man/check_ped.Rd: Language not supported
  • man/find_parentage.Rd: Language not supported
  • man/imputation_concordance.Rd: Language not supported
  • man/solve_composition_poly.Rd: Language not supported
  • man/validate_pedigree.Rd: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/find_parentage.R
Comment on lines +92 to 110
valid_ids <- genos$id
removed_parents <- base::setdiff(all_parents$id, valid_ids)
if (base::length(removed_parents) > 0) {
warning("The following parent IDs were not in the genotype file and will not be analyzed: ",
paste(removed_parents, collapse = ", "), call. = FALSE)
all_parents <- all_parents[ID %in% valid_ids]
all_parents <- all_parents[id %in% valid_ids]
}

removed_progeny <- base::setdiff(progeny_candidates$ID, valid_ids)
removed_progeny <- base::setdiff(progeny_candidates$id, valid_ids)
if (base::length(removed_progeny) > 0) {
warning("The following progeny IDs were not in the genotype file and will not be analyzed: ",
paste(removed_progeny, collapse = ", "), call. = FALSE)
progeny_candidates <- progeny_candidates[ID %in% valid_ids]
progeny_candidates <- progeny_candidates[id %in% valid_ids]
}

if (!"Sex" %in% base::colnames(all_parents)) {
warning("No 'Sex' column in parents file. All parents treated as ambiguous ('A').")
all_parents[, Sex := "A"]
if (!"sex" %in% base::colnames(all_parents)) {
warning("No 'sex' column in parents file. All parents treated as ambiguous ('A').")
all_parents[, sex := "A"]
}
Comment thread R/find_parentage.R
Comment on lines +325 to +327
final_df <- merge(results_dt, tie_rows, by = "id", all.x = TRUE)
for (col in base::names(final_df))
data.table::set(final_df, which(final_df[[col]] == ""), col, NA_character_)
Comment thread R/find_parentage.R
Comment on lines +412 to +416
ggplot2::geom_vline(xintercept = error_threshold,
linetype = "dashed", color = "black", linewidth = 1) +
ggplot2::scale_x_continuous(breaks = seq(0, 100, by = 5)) +
ggplot2::scale_y_continuous(breaks = seq(0, 10000, by = 5)) +
ggplot2::scale_fill_manual(
Comment thread R/validate_pedigree.R
Comment on lines 85 to 93
#### Check required columns ####
required_ped_cols <- c("ID", "Male_Parent", "Female_Parent")
required_ped_cols <- c("id", "male_parent", "female_parent")
missing_cols <- base::setdiff(required_ped_cols, base::names(pedigree))
if (base::length(missing_cols) > 0)
stop("Pedigree file missing required columns: ",
base::paste(missing_cols, collapse = ", "))
if (!"ID" %in% base::names(genos))
stop("Genotypes file must have an 'ID' column")
if (!"id" %in% base::names(genos))
stop("Genotypes file must have an 'id' column")

@alex-sandercock alex-sandercock merged commit 7707dcd into development Jun 5, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants