R/simulate_point_mutation_markov_expensive.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
simulate_point_mutation_markov_expensive <- function(sequences, num_jumps, transition_matrix)
{
  sequence_length <- length(sequences[[1]])

  data <- data.frame(time = rep(NA_integer_, num_jumps),
                     sequences = rep(NA, num_jumps))
  row_num <- 1
  for(t in 1:num_jumps)
  {
      new_row <- c(t, list(list(sequences)))
      data[t, ] <- new_row
      sequences <- mutate_sequences(sequences, transition_matrix)
  }
  return(data)
}
sams25/rcombinator_old documentation built on May 28, 2019, 8:40 a.m.