Introduce single nucleotide variants (SNVs) into a genome sequence by processing mutations grouped by haplotype and chromosome.

introduce_snv(genome, mut_table, verbose = TRUE)

Arguments

genome

A nested list containing genome sequences:

  • First level: haplotypes (maternal/paternal)

  • Second level: chromosomes with nucleotide sequences

mut_table

A data frame containing mutation information with columns:

  • haplotype - Maternal or paternal copy

  • chrom - Chromosome name

  • pos - Position where mutation occurs

  • alternative_nt - Alternative nucleotide to introduce

Value

A list containing:

  • genome - Modified genome with introduced SNVs

Details

The function:

  1. Groups mutations by haplotype and chromosome for efficient processing

  2. Processes each group of mutations in a vectorized operation

  3. Maintains the original genome structure while updating sequences

Note: Uses vectorized operations through replaceLetterAt for efficient mutation introduction

See also

replaceLetterAt

Examples

if (FALSE) { # \dontrun{
# Example mutation table
mutations <- data.frame(
  haplotype = "maternal",
  chrom = "chr1",
  pos = 100,
  alternative_nt = "A"
)
modified <- introduce_snv(genome, mutations)
} # }