R/simulate_point_mutation_markov.R

#' The Markov chain simulation for point mutations on a list of sequences
#' @param sequences A list of nucleic acid sequences
#' @param num_jumps The number of steps to simulate the point mutations for
#' @param transition_matrix The transition matrix coressponding to the model we are using
#' for point mutations
#' @return A data frame with a list of times and the mutated sequences at each time
#' @export
simulate_point_mutation_markov <- function(sequences, num_jumps,
                                           transition_matrix = get_k80_matrix(10^6),
                                           dist_method = "levenshtein",
                                           save_sequences = FALSE, save_file = NULL)
{
  if(save_sequences)
  {
    sim_data <- simulate_point_mutation_markov_expensive(sequences, num_jumps, transition_matrix)
  }
  else
  {
    sim_data <- simulate_point_mutation_markov_cheap(sequences, num_jumps, transition_matrix,
                                                     dist_method)
  }
  if(!is.null(save_file))
  {
    save(sim_data, file = paste(save_file, ".RData", sep = ""))
  }
  return(sim_data)
}
sams25/rcombinator_old documentation built on May 28, 2019, 8:40 a.m.