Skip to content

MultiPop: Add prototype calcGenParamPop() and genParamPop()#288

Draft
darizasu wants to merge 9 commits into
gaynorr:MultPopfrom
darizasu:multipop-genParamPop
Draft

MultiPop: Add prototype calcGenParamPop() and genParamPop()#288
darizasu wants to merge 9 commits into
gaynorr:MultPopfrom
darizasu:multipop-genParamPop

Conversation

@darizasu

@darizasu darizasu commented Jul 9, 2026

Copy link
Copy Markdown

Description

This PR adds a prototype implementation of two new functions for population-level genetic parameter summaries on MultiPop objects:

  • calcGenParamPop(): internal/helper function computing trait-specific summaries per population with a user-defined function.
  • genParamPop(): user-facing wrapper that iterates across traits and returns population-level outputs (e.g. gv, bv, dd, variances/covariances currently implemented).

I also added basic roxygen documentation for both functions in R/popSummary.R (kept intentionally concise) and tests in tests/testthat/test-genParam.R (using Falconer's QG examples of genParam). These two functions were inspired by the functionality of calcGenParam and genParam.

The goal is to provide a first implementation for calculating genetic parameter summaries directly at the population level (including nested/partitioned MultiPop workflows).

Current behavior and scope

This implementation works as expected for linear summaries (e.g. FUN = mean, FUN = sum). It includes population-specific intercept handling so mean/sum behavior is consistent with the selected summary scale.

However, for non-linear summaries (e.g. FUN = prod, median, max), results should be interpreted with care, as the current decomposition is mathematically consistent for linear aggregation, but non-linear aggregators generally do not preserve the decomposition/equality with direct aggregation of individual total gv.

I'm making this a draft PR, so it's still a work-in-progress prototype.

@gregorgorjanc @gaynorr Please let me know your thoughts about it. I'd really appreciate feedback on the expected/desired behavior for non-linear FUN.

Related to #254

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 77.12264% with 97 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (MultPop@dc9bb4f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
R/popSummary.R 44.84% 91 Missing ⚠️
R/selection.R 95.90% 5 Missing ⚠️
R/mergePops.R 99.25% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             MultPop     #288   +/-   ##
==========================================
  Coverage           ?   46.79%           
==========================================
  Files              ?       38           
  Lines              ?    10232           
  Branches           ?        0           
==========================================
  Hits               ?     4788           
  Misses             ?     5444           
  Partials           ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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