
De-identify an MHC haplotype carrier table
Source:R/obfuscateMhcHaplotypes.R
obfuscateMhcHaplotypes.RdRemaps the id column of a mhcHaplotypeCarriers
table 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 an MHC carrier table needs so an
"obfuscated" export never leaks real animal ids while the main
pedigree is de-identified.
Arguments
- carriers
data.frame with columns
haplotype,id,uncertainas returned bymhcHaplotypeCarriers.- map
named character vector of aliases, keyed by the original id – the
mapelement ofobfuscatePed(..., map = TRUE)'s return value.
Details
Haplotype labels are left byte-identical: an MHC haplotype name is a
shared nomenclature term, not an animal identifier, and there is no
validity-preserving way to obfuscate one. Only id is ever
remapped – a map entry whose name happens to match a haplotype label
never touches the haplotype column. The uncertain
disclosure column passes through unchanged.
A row whose id is absent from map stop()s rather
than silently dropping or leaking the real id.
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
)
genotype <- data.frame(
id = c("S1", "S2"),
haplotype1 = c("A001_B001", "A001_B001"),
haplotype2 = c("A002_B012", "A008_B015b"),
stringsAsFactors = FALSE
)
carriers <- mhcHaplotypeCarriers(genotype, rareOnly = FALSE)
obfuscated <- obfuscatePed(ped, map = TRUE)
obfuscateMhcHaplotypes(carriers, obfuscated$map)
#> haplotype id uncertain
#> 1 A001_B001 FCDNFK FALSE
#> 2 A001_B001 GJGR1A FALSE
#> 3 A002_B012 FCDNFK FALSE
#> 4 A008_B015b GJGR1A FALSE