function mutated_nucleotide= Mutation(nucleotide,w,tt_ratio) % Mutation - Mutates a given nucleotide with the Kimura 2-par model % % INPUT % nucleotide -> original nucleotide % w -> edge length % tt_ratio -> transition-transversion ratio % % OUTPUT % mutated_nucleotide -> nucleotide after mutation % % USAGE % mutated_nucleotide= Mutation(nucleotide,w,tt_ratio) % % FUNCTION CALLS % Kimura2P, SampleFromMultinomial % ------------ Check for Errors ------------- if nargin~=3 error('Wrong number of input arguments') end if w<0 | tt_ratio<=0 error('Parameters must be positive') end if sum([1 2 3 4]==nucleotide)~=1 error('nucleotide nust be in {1,2,3,4}') end % ------ Matrix of nucleotide transition probabilities ------ nuc_trans_prob= Kimura2PM(w, tt_ratio); % ------ New probabilties for the nucleotides ----- P_new= nuc_trans_prob(:,nucleotide); % -- Mutation: Draw a new sample from the multinomial distribution -- mutated_nucleotide= SampleFromMultinomial(P_new);