Learn R Programming

nprcgenekeepr (version 3.0.0)

obfuscatePed: Obfuscate a pedigree by aliasing IDs and shifting dates

Description

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

Usage

obfuscatePed(
  ped,
  size = 6L,
  maxDelta = 30L,
  existingIds = character(0L),
  map = FALSE,
  linkedDateShift = TRUE
)

Value

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.

Arguments

ped

The pedigree information in data.frame format

size

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

maxDelta

integer value indicating maximum number of days that the birthdate can be shifted

existingIds

character vector of existing aliases to avoid duplication.

map

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.

linkedDateShift

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

Details

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.

See Also

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

Examples

Run this code
library(nprcgenekeepr)
ped <- qcStudbook(nprcgenekeepr::pedGood)
obfuscatedPed <- obfuscatePed(ped)
ped
obfuscatedPed

Run the code above in your browser using DataLab