User provides a pedigree object (ped), the number of characters to be
used for alias IDs (size), and the maximum number of days that the
birthdate can be shifted (maxDelta).
obfuscatePed(
ped,
size = 6L,
maxDelta = 30L,
existingIds = character(0L),
map = FALSE,
linkedDateShift = TRUE
)An obfuscated pedigree: IDs aliased, name set to NA,
Date columns shifted and age recomputed. With map = TRUE, a
list holding that pedigree and the alias map.
The pedigree information in data.frame format
integer value indicating number of characters in alias IDs.
IDs that stand for unknown parents get longer aliases when size is
too short to keep them recognizable as placeholders (see
obfuscateId).
integer value indicating maximum number of days that the birthdate can be shifted
character vector of existing aliases to avoid duplication.
logical if TRUE a list object is returned with the new
pedigree and a named character vector with the names being the original IDs
and the values being the new alias values. Defaults to FALSE.
logical, defaults to TRUE. When TRUE,
every Date column of one individual is shifted by the same, single random
offset (drawn once per individual), so the gaps between an individual's
own dates (e.g. birth, exit, death) are preserved
exactly -- avoiding a defect where independently-shifted date columns can
invert an individual's recorded date order (e.g. an obfuscated exit
preceding an obfuscated birth), producing a negative recomputed
age (issue #150 D3). When FALSE, each Date column is shifted
independently via obfuscateDate (the original, pre-#150
behavior).
Any name column is overwritten with NA. Every Date column
(e.g. birth, exit, death) is shifted, not only the
birthdate. When the age, birth and exit columns are
all present and birth is a Date, age is recomputed from the
shifted dates.
Other obfuscation:
mapIdsToObfuscated(),
obfuscateDate(),
obfuscateGenomicROH(),
obfuscateGenotypeMatrix(),
obfuscateId(),
obfuscateLdBlocks(),
obfuscateMhcHaplotypes(),
obfuscateTwinRelations()
library(nprcgenekeepr)
ped <- qcStudbook(nprcgenekeepr::pedGood)
obfuscatedPed <- obfuscatePed(ped)
ped
obfuscatedPed
Run the code above in your browser using DataLab