inject_errors: Inject errors into a sample of genotypes.

Description Usage Arguments Value Note See Also Examples

Description

Takes a geno_table object and injects a total of perr errors with a concentration-dependent rate described by a cumulative distribution functions, cdf, using the probability calculation described in loose_eag..

Usage

1
inject_errors(x, cdf, perr, odds = 1)

Arguments

x

A geno_table object with attribute has_errors = FALSE.

cdf

A cumulative distribution function describing a DNA-concentration- dependent error rate. See cdfA and cdfB for two precomputed error functions based on HLA-A and HLA-B.

perr

The overall error rate.

odds

The odds of loosing an EAG on exon 2 or exon 3, respectively. E.g. odds = 2 means a 2:1 chance that the loss occurs on Exon 2; odds = 0.25 means a 1:4 chance that the loss occurs on Exon 3.

Value

A geno_table object with attribute has_errors = TRUE.

Note

The next step is to map genotype frequencies onto the sampled genotypes: map_genotype_frequencies.

See Also

Other simulation.functions: make_genotype_sampler, map_genotype_frequencies

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Not run: 
## Extract HLA-DPB1 genotype frequencies
dpb1 <- HLA("DPB1", "01/01/2014", "23/03/2015")

## Restrict the data to the German sample
dpb1.de <- dpb1[provenance == "DE"]

## Generate an EAG table
dpb1_eag1412 <- eag_table(gene = "DPB1", nextype_basis_id = "1412")

## Generate a distribution of DNA concentrations
conc <- sample_dna_concentration(dpb1.de, n = 1000, ncores = 8)

## Generate a sampling function
sample_dpb1_de <- make_genotype_sampler(dpb1.de, eag_1267)

## Load precomputed DNA-concentration-dependent error distribution for HLA-A
data(cdfA)

## Sample genotypes
n <- 10000
bin_size <- 3
perr <- 0.01
odds <- 0.25
ans <- sample_dpb1_de(conc, n, bin_size) %>%
  inject_errors(cdfA, perr, odds)
ans

summary(ans)
samples(ans)
errors(ans)
merge(ans)

## End(Not run)

gschofl/HLAsim documentation built on May 17, 2019, 8:51 a.m.