Learn R Programming

nprcgenekeepr (version 3.0.0)

obfuscateTwinRelations: De-identify a twin/zygosity relations table

Description

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)

Value

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

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.

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.

See Also

Other obfuscation: mapIdsToObfuscated(), obfuscateDate(), obfuscateGenomicROH(), obfuscateGenotypeMatrix(), obfuscateId(), obfuscateLdBlocks(), obfuscateMhcHaplotypes(), obfuscatePed()

Examples

Run this code
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)

Run the code above in your browser using DataLab