R/snv_relevant_functions.R
sim_clonal_mutation_pos.RdSimulates random mutation positions along chromosomes for each edge in a phylogenetic tree. Mutations are distributed across chromosomes proportionally to their lengths, and can occur on either maternal or paternal haplotypes.
sim_clonal_mutation_pos(tree, chr_lengths, mutation_number)An igraph object representing the phylogenetic tree structure.
A nested list containing chromosome lengths for each clone and haplotype:
First level: clone names
Second level: haplotypes (maternal/paternal)
Third level: named numeric vector of chromosome lengths
A named numeric vector specifying the number of mutations to simulate for each edge in the tree. Names should be in format "parent_child".
A data frame containing simulated mutation information:
clone - Name of the clone where mutation occurs
edge_name - Tree edge identifier (parent_child)
haplotype - Maternal or paternal haplotype
chrom - Chromosome where mutation occurs
pos - Position of mutation on the chromosome
The function processes the tree in depth-first search order, starting from the first tumor clone (excluding root). For each edge, it simulates the specified number of mutations by:
Randomly selecting a haplotype (maternal/paternal)
Selecting a chromosome with probability proportional to its length
Randomly selecting a position within the chosen chromosome