# Simulating YSTR profiles

#### Maarten Kruijver

#### 2025-04-14

In addition to autosomal profiles, it is also possible to sample YSTR profiles.

## Example

We start by reading the YSTR kit and stutter data.

      require(simDNAmixtures)
      data_dir <- system.file("extdata", package = "simDNAmixtures")
      kit_filename <- file.path(data_dir, "YFiler_Plus_3500_FSSA.xml")
      YSTR_kit <- read_STRmix_kit_settings(kit_filename, data_dir, include_y_loci = TRUE)

Then we input two genotypes

    y_refs_with_names <- as.data.frame(readxl::read_excel(path = system.file("extdata","South_Australia_YSTRs.xlsx",
                                                                             package = "simDNAmixtures"),
                                                          col_types = rep("text", 27)))

    x <- y_refs_with_names[1:2, -c(1, 2)]
    rownames(x) <- c("K1", "K2")
    genotypes <- simDNAmixtures:::.wide_YSTR_references_to_allele_tables(x)

Sample Name | Locus | Allele1 | Allele2
--- | --- | --- | ---
K1 | DYS576 | 18 | NA
K1 | DYS389I | 13 | NA
K1 | DYS635 | 23 | NA
K1 | DYS389II | 29 | NA
K1 | DYS627 | 22 | NA
K1 | DYS460 | 11 | NA
K1 | DYS458 | 17 | NA
K1 | DYS19 | 14 | NA
K1 | YGATAH4 | 11 | NA
K1 | DYS448 | 19 | NA
K1 | DYS391 | 11 | NA
K1 | DYS456 | 16 | NA
K1 | DYS390 | 24 | NA
K1 | DYS438 | 12 | NA
K1 | DYS392 | 13 | NA
K1 | DYS518 | 41 | NA
K1 | DYS570 | 18 | NA
K1 | DYS437 | 15 | NA
K1 | DYS385 | 12 | 13
K1 | DYS449 | 29 | NA
K1 | DYS393 | 13 | NA
K1 | DYS439 | 11 | NA
K1 | DYS481 | 22 | NA
K1 | DYF387S1 | 34 | 36
K1 | DYS533 | 12 | NA

Sample Name | Locus | Allele1 | Allele2
--- | --- | --- | ---
K2 | DYS576 | 17 | NA
K2 | DYS389I | 13 | NA
K2 | DYS635 | 23 | NA
K2 | DYS389II | 29 | NA
K2 | DYS627 | 21 | NA
K2 | DYS460 | 10 | NA
K2 | DYS458 | 17 | NA
K2 | DYS19 | 14 | NA
K2 | YGATAH4 | 12 | NA
K2 | DYS448 | 19 | NA
K2 | DYS391 | 11 | NA
K2 | DYS456 | 15 | NA
K2 | DYS390 | 23 | NA
K2 | DYS438 | 12 | NA
K2 | DYS392 | 13 | NA
K2 | DYS518 | 40 | NA
K2 | DYS570 | 18 | NA
K2 | DYS437 | 15 | NA
K2 | DYS385 | 11 | 14
K2 | DYS449 | 28 | NA
K2 | DYS393 | 13 | NA
K2 | DYS439 | 12 | NA
K2 | DYS481 | 22 | NA
K2 | DYF387S1 | 35 | 36
K2 | DYS533 | 11 | NA

## Simulation

    sampling_parameters <- list(min_template = 250., max_template = 5000.,
                                degradation_shape = 2.5, degradation_scale = 5e-4)

    mixtures <- sample_mixtures_from_genotypes(n = 10, genotypes = genotypes, sampling_parameters = sampling_parameters,
                                   model_settings = YSTR_kit, sample_model = sample_log_normal_model,
                                   number_of_replicates = 3, tag = "YSTR 2P")
    length(mixtures)
    #> [1] 4
    # add results_directory="..." to save results to disk