R/simulate_point_mutation_markov_cheap.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
#' @param dist_method The method for which to calculate distances between strings
#' @return A data frame with a list of times and the pairwise distances
simulate_point_mutation_markov_cheap <- function(sequences, num_jumps, transition_matrix, dist_method)
{
  data_seq <- data.frame(time = rep(NA_integer_, 1),
                         sequences = rep(NA, 1))
  data <- data.frame()

  for(t in 1:num_jumps)
  {
    cat(paste(t, "/", num_jumps, "\n", sep=""))
    data_seq[1, ] <- c(t, list(list(sequences)))
    data_new <- pairwise_distances_bursts(data_seq, t, dist_method)
    data <- rbind(data, data_new)
    sequences <- mutate_sequences(sequences, transition_matrix)
  }
  return(data)
}
sams25/rcombinator_old documentation built on May 28, 2019, 8:40 a.m.