Skip to contents

Turns one reportGV result into a one-row data.frame in the 27-column snapshot-history schema (issue #167, schema version 1), ready for appendColonySnapshot. Every metric field is a value the nprcgenekeeprGV object already carries, or a Summary Statistics aggregate (mean/median/calcSkewness/ calcKurtosis, NA removed) of its per-animal indivMeanKin/gu/guSE report columns, stored at full precision — no estimator is recomputed or duplicated.

Usage

createColonySnapshot(
  ped,
  geneticValue,
  membershipRule,
  guIter,
  guThresh,
  snapshotDate = Sys.Date()
)

Arguments

ped

The pedigree data.frame the reportGV analysis was run on, carrying at least an id column (plus the logical population column when membershipRule is "focalPopulation").

geneticValue

An object of class nprcgenekeeprGV as returned by reportGV.

membershipRule

Single string naming how the analysis population was assembled; one of "wholePedigree" or "focalPopulation".

guIter

Single positive whole number: the guIter value the reportGV call used. Required — there is no default.

guThresh

Single positive whole number: the guThresh value the reportGV call used. Required — there is no default.

snapshotDate

The snapshot's date: a Date or an ISO-8601 (YYYY-MM-DD) string. Defaults to Sys.Date().

Value

A one-row data.frame in the 27-column snapshot-history schema; it passes checkSnapshotHistory unchanged.

Details

guIter and guThresh are required because the reportGV return object does not carry them, and they are comparability provenance the snapshot must record truthfully: pass exactly the values the reportGV call used (its defaults are 1000L and 1L).

The claimed membershipRule is verified against ped and the report, and a contradiction stops:

"wholePedigree"

the report covers exactly the animals in ped.

"focalPopulation"

ped carries the logical population column (see setPopulation) and the report covers exactly ped$id[ped$population]. Pass the same population-designated pedigree the reportGV call analyzed.

Examples

ped <- nprcgenekeepr::qcPed
gv <- reportGV(ped, guIter = 10L)
snapshot <- createColonySnapshot(ped, gv, "wholePedigree",
  guIter = 10L, guThresh = 1L
)
history <- appendColonySnapshot(NULL, snapshot)