R/plot_pairwise_data_complex.R

#' Plots the pairwise distances for a matrix of strings
#' @param location A place where the data is stored
#' @importFrom magrittr "%>%"
#' @return A plot
#' @export
plot_pairwise_data_complex <- function(location, timestep)
{
  title = "Pairwise sequence distances over time"
  if(stringr::str_detect(location, "norecomb"))
  {
    title = paste(title, "WITHOUT recombination")
  }
  else
  {
    title = paste(title, "WITH recombination")
  }
  load(location)
  pair_data <- sim_data[[2]]
  pair_data <- pair_data %>%
    tidyr::unite(seq1, seq2, col="comparing", sep = " and ")

  p <- ggplot2::ggplot(data=pair_data,
                       ggplot2::aes(x=time, y=seq_dist, group=comparing))
  p <- p + ggplot2::geom_line()
  p <- p + ggplot2::labs(x = paste("Time (in", timestep, "years)"),
                         y = paste("Sequence distances"),
                         title = title)
  return(p)
}
sams25/rcombinator_old documentation built on May 28, 2019, 8:40 a.m.