
De-identify a twin/zygosity relations table
Source:R/obfuscateTwinRelations.R
obfuscateTwinRelations.RdRemaps id1/id2 in a twin/zygosity sidecar table (see
checkTwinRelations) through the same alias vector
obfuscatePed(..., map = TRUE) already returns.
obfuscatePed scrubs exactly one pedigree data frame and
cannot reach a second, sidecar object – this is the companion scrub a
twin-relations table needs so an "obfuscated" export never leaks real
ids through the sidecar table while the main pedigree is de-identified.
Arguments
- twinRelations
data.frame with columns
id1,id2,code. SeecheckTwinRelations.- map
named character vector of aliases, keyed by the original id – the
mapelement ofobfuscatePed(..., map = TRUE)'s return value.
Details
A row whose id1 or id2 is absent from map
stop()s rather than silently dropping or leaking the real id.
checkTwinRelations's own existence rule should already
have excluded that case upstream against the un-obfuscated pedigree, so
this is a defensive check, not the primary validation path.
Examples
ped <- data.frame(
id = c("F1", "F2", "S1", "S2"),
sire = c(NA, NA, "F1", "F1"),
dam = c(NA, NA, "F2", "F2"),
sex = c("M", "F", "F", "F"),
stringsAsFactors = FALSE
)
twinRelations <- data.frame(
id1 = "S1", id2 = "S2", code = "MZ twin", stringsAsFactors = FALSE
)
obfuscated <- obfuscatePed(ped, map = TRUE)
obfuscateTwinRelations(twinRelations, obfuscated$map)
#> id1 id2 code
#> 1 832J19 KN3CMQ MZ twin