Global stutter model where the expected stutter rate is constant across alleles and loci
global_stutter_model.Rd
Global stutter model where the expected stutter rate is constant across alleles and loci
Usage
global_stutter_model(
back_stutter_rate,
forward_stutter_rate,
size_regression,
sex_locus_name = "AMEL"
)
Arguments
- back_stutter_rate
Numeric. (Optional)
- forward_stutter_rate
Numeric. (Optional)
- size_regression
Function, see read_size_regression.
- sex_locus_name
Character vector, defaults to "AMEL".
Value
Object of class stutter_model
to be used by e.g. gamma_model.
Details
When a pg_model is constructed (see gamma_model), a stutter model can optionally be applied. In the global stutter model, the expected stutter rate is constant across all loci and for all parent alleles.
See also
allele_specific_stutter_model for a stutter model where the expected stutter rate depends on the allele and locus.
Examples
# the stutter model needs a size regression to determine fragment length
# of stutter products
size_regression <- read_size_regression(system.file("extdata",
"GlobalFiler_SizeRegression.csv",package = "simDNAmixtures"))
# define a stutter model with an expected back stutter rate of 10%
stutter_model <- global_stutter_model(back_stutter_rate = 0.1,
size_regression = size_regression)
stutter_model
#> $stutters
#> $stutters$BackStutter
#> $stutters$BackStutter$rate
#> [1] 0.1
#>
#> $stutters$BackStutter$delta
#> [1] -1
#>
#>
#>
#> $sex_locus_name
#> [1] "AMEL"
#>
#> $size_regression
#> function (locus, allele)
#> {
#> if (has_exceptions) {
#> locus_exceptions <- exceptions[[locus]]
#> if (!is.null(locus_exceptions)) {
#> if (allele %in% names(locus_exceptions)) {
#> size <- locus_exceptions[[allele]]
#> return(size)
#> }
#> }
#> }
#> regression_locus <- regression_df_by_locus[[locus]]
#> if (is.null(regression_locus)) {
#> stop("No size regression available for locus ", locus)
#> }
#> intercept <- regression_locus$Intercept
#> slope <- regression_locus$Slope
#> allele_numeric <- as.numeric(allele)
#> if (has_repeat_length_by_marker) {
#> repeat_length <- repeat_length_by_marker[[locus]]
#> if (!is.null(repeat_length)) {
#> allele_numeric <- repeats_to_decimals(allele_numeric,
#> repeat_length)
#> }
#> }
#> intercept + slope * allele_numeric
#> }
#> <bytecode: 0x55ce0eb8eb40>
#> <environment: 0x55ce0f62cbd8>
#>
#> $add_expected_stutter
#> function (...)
#> global_stutter_model_add_expected_stutter(stutter_model, ...)
#> <bytecode: 0x55ce0f8bbd60>
#> <environment: 0x55ce0f8bb7e8>
#>
#> attr(,"class")
#> [1] "stutter_model"