Simulates 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)

Arguments

tree

An igraph object representing the phylogenetic tree structure.

chr_lengths

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

mutation_number

A named numeric vector specifying the number of mutations to simulate for each edge in the tree. Names should be in format "parent_child".

Value

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

Details

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:

  1. Randomly selecting a haplotype (maternal/paternal)

  2. Selecting a chromosome with probability proportional to its length

  3. Randomly selecting a position within the chosen chromosome