Skip to contents

Remaps 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.

Usage

obfuscateTwinRelations(twinRelations, map)

Arguments

twinRelations

data.frame with columns id1, id2, code. See checkTwinRelations.

map

named character vector of aliases, keyed by the original id – the map element of obfuscatePed(..., map = TRUE)'s return value.

Value

twinRelations with id1/id2 replaced by their aliases; code is unchanged.

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