maskPed {pedtools} | R Documentation |
Mask and unmask pedigree datasets
Description
The maskPed()
function replaces the individual IDs, marker names and allele
names with generic labels, and randomly changes their internal order. For
markers with stepwise mutation models, the allelic ladder is simply
translated to start at 1, thereby preserving the intra-allelic differences.
Usage
maskPed(
x,
ids = NULL,
markerNames = NULL,
markerShuffle = TRUE,
alleleLabels = NULL,
alleleShuffle = TRUE,
seed = NULL
)
unmaskPed(x, keys)
Arguments
x |
A |
ids |
(Optional) A named character with the new IDs, written as |
markerNames |
(Optional) A named character with the new marker names
(and order), written as |
markerShuffle |
A logical: Randomly reorder the markers? (Default: TRUE) |
alleleLabels |
(Optional) A list of character vectors. The list names
should be the original marker names. Each vector gives the new allele
labels, as |
alleleShuffle |
A logical: Randomly reorder the alleles? (Default: TRUE) |
seed |
An optional seed for the random number generator. |
keys |
A list with entries |
Details
Note that in order to preserve likelihoods, the allele frequencies are not modified. Thus, if the data uses a publicly available frequency databases, the result cannot be considered to be fully anonymised, since one could (at least in theory) deduce the original marker names and alleles from the frequencies.)
Value
An object similar to x
but with replaced ID labels, marker names
and allele labels.
Examples
x = nuclearPed(father = "fa", mother = "mo", children = "ch") |>
addMarker(name = "myMarker", ch = "b/c", afreq = c(a=0.2, b=0.3, c=0.5)) |>
setMutmod(model = "proportional", rate = 0.01)
# Mask
y = maskPed(x, seed = 1729)
# Unmask
z = unmaskPed(y$maskedPed, keys = y$keys)
stopifnot(identical(x, z))
# With stepwise model
x2 = x |>
addMarker(name = "mySTR", ch = "7.2/8.2",
alleles = c("7", "7.2", "8", "8.2")) |>
setMutmod(marker = 2, model = "stepwise", rate = 0.1, rate2 = 1e-6,
range = 0.1)
y2 = maskPed(x2, seed = 1729)
z2 = unmaskPed(y2$maskedPed, keys = y2$keys)
stopifnot(identical(x2, z2))
# Check likelihoods with pedprobr:
# stopifnot(setequal(likelihood(x2), likelihood(y2$maskedPed)))