Skip to contents

Server logic for breeding group formation using the groupAddAssign algorithm. This module integrates with the kinship-based maximal independent set (MIS) algorithm to form optimal breeding groups that minimize relatedness within groups while maximizing group sizes.

Usage

modBreedingGroupsServer(
  id,
  pedigree,
  geneticValues = NULL,
  kinshipMatrix = NULL,
  kinshipOverrides = NULL
)

Arguments

id

character vector of length 1. Module namespace identifier.

pedigree

reactive returning pedigree data frame with columns: id, sire, dam, sex, and optionally birth, exit, gen.

geneticValues

optional reactive returning genetic value results from modGeneticValueServer, used to source the topRanked animal-source candidate list. Unrelated to kinship.

kinshipMatrix

optional reactive returning a kinship matrix, typically a full-pedigree matrix shared with modSummaryStatsServer (e.g. from appServer) rather than independently recomputed. If NULL, the module calculates kinship from the pedigree.

kinshipOverrides

optional reactive returning a validated outside-information kinship-override data frame (id1, id2, kinship); see applyKinshipOverrides. When the module recomputes kinship from the pedigree (the shared kinshipMatrix is unavailable), the overrides are applied to that matrix so group formation reflects them regardless of tab order. NULL (the default) is a no-op. A provided kinshipMatrix is expected to already carry overrides applied at its source.

Value

List with reactive components:

  • groups - List of character vectors with animal IDs per group

  • nGroups - Number of groups formed

  • score - Optimization score from groupAddAssign (minimum group size)

  • unassigned - Character vector of candidate IDs not placed in groups

  • groupKinship - List of kinship matrices per group (if withKin=TRUE)

Details

The module supports multiple configuration options:

  • Animal source: Select top-ranked animals or all available

  • Kinship threshold: Maximum allowed kinship within groups

  • Harem mode: Form groups with exactly one male each

  • Sex ratio: Target female-to-male ratio in groups