
Collect every cross-center identity-mapping problem, without stopping
Source:R/checkCrossCenterMapping.R
checkCrossCenterMapping.RdThe "show every problem at once" companion to
resolveCrossCenterIds (issue #149 Slice 1), sharing its
five validation checks – id existence, mapping uniqueness, undeclared id
collisions, a pedB animal that reuses an id the mapping gives a
pedA animal, and conflicting recorded parents – via the same
internal helpers (D2,
docs/planning/issue149-cross-center-identity-mapping-workflow-plan.md
section 3). resolveCrossCenterIds() stop()s on the first
problem it finds; checkCrossCenterMapping() never stop()s
on a domain problem – every one found becomes a row in the returned
data.frame instead, so a curator can see and fix every issue at once
rather than one at a time. A structural problem (a required column
missing from any of the three inputs) still stop()s immediately,
matching every other checkXxx() function in this package
(checkKinshipOverrides, checkTwinRelations).
Value
A data.frame of every domain problem found, with columns
type ("existence", "uniqueness", "collision",
"mappedIdClash", or "conflict"), ids (the offending
id(s), as a single comma-separated string), and message (a
human-readable description). Zero rows means none of these five kinds of
problem was found. A "mappedIdClash" row names an id of a
pedB animal with no mapping row that the mapping already uses for a
pedA animal; a merge would hold two rows with that id.
resolveCrossCenterIds can still stop on conflicting
values in other columns shared by both pedigrees (e.g. sex), which
this function does not check.
Details
Existence and uniqueness problems (tier A) are checked first; if either is present, only those are returned and the collision, reused-id and conflict checks (tier B) are skipped entirely, since a mapped id that does not resolve to a real pedigree row makes those checks meaningless. Tier B – and all three of its checks, across every mapped pair – runs only once tier A is clean.
Examples
library(nprcgenekeepr)
pedA <- data.frame(
id = c("P1", "P2", "T1"), sire = c(NA, NA, "P1"), dam = c(NA, NA, "P2"),
stringsAsFactors = FALSE
)
pedB <- data.frame(
id = c("X9", "O1"), sire = c(NA, "X9"), dam = c(NA, NA),
stringsAsFactors = FALSE
)
mapping <- data.frame(idA = "T1", idB = "X9", stringsAsFactors = FALSE)
checkCrossCenterMapping(pedA, pedB, mapping) # zero rows: clean
#> [1] type ids message
#> <0 rows> (or 0-length row.names)