R/genome_relevant_functions.R
introduce_snv_sc.RdIncorporates single nucleotide variants (SNVs) into a genome sequence, handling both regular mutations and recurrent mutations at the same genomic position.
introduce_snv_sc(input_genome, sc_mut_table_with_nt)A list containing the modified genome sequences with all mutations incorporated
This function introduces mutations into a genome sequence with special handling for recurrent mutations (multiple mutations at the same genomic position):
Identifies recurrent mutations by detecting duplicated positions across haplotype, chromosome, and position
Processes non-recurrent mutations first using the insert_mutations() helper function
For recurrent mutations:
Groups mutations by their genomic coordinates
For each position with multiple mutations, creates a consolidated mutation that applies the cumulative effect (using the original nucleotide from the first mutation and the alternative nucleotide from the last mutation in the timeline)
Applies these consolidated recurrent mutations to the genome
This approach ensures that the final genome correctly represents the cumulative effect of sequential mutations at the same position, rather than applying each mutation independently which could lead to incorrect results.