Learn R Programming

nprcgenekeepr (version 3.0.0)

obfuscateGenotypeMatrix: De-identify a sequence-scale genotype matrix

Description

Remaps the row names (individual ids) of a buildMarkerGenotypeMatrix-shaped wide genotype matrix through the same alias vector obfuscatePed(..., map = TRUE) already returns, mirroring obfuscateTwinRelations's and obfuscateLdBlocks's pattern. Genotype/allele values themselves are never perturbed -- unlike a date, there is no scientifically-valid "obfuscation" of an allele call that preserves validity while hiding identity, so the only real protection this primitive provides is which people see the exported file at all (issue #152 Slice 4, design decision D7).

Usage

obfuscateGenotypeMatrix(genotypeMatrix, map)

Value

genotypeMatrix with row names replaced by their aliases; column names and every genotype cell value are unchanged.

Arguments

genotypeMatrix

a character matrix as returned by buildMarkerGenotypeMatrix: rows are individual ids, columns are loci.

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 id is absent from map stop()s rather than silently dropping or leaking the real id.

See Also

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

Examples

Run this code
library(nprcgenekeepr)
ped <- data.frame(
  id = c("A01", "A02"),
  sire = c(NA, NA),
  dam = c(NA, NA),
  sex = c("M", "F"),
  stringsAsFactors = FALSE
)
genotypeMatrix <- matrix(
  c("A/A", "A/B"), nrow = 2L, dimnames = list(c("A01", "A02"), "L1")
)
obfuscated <- obfuscatePed(ped, map = TRUE)
obfuscateGenotypeMatrix(genotypeMatrix, obfuscated$map)

Run the code above in your browser using DataLab