R/plotting.R

#' Plot both the experimental data and the model fit.
#'
#' @param data data.frame containing the data and model fit to plot.
#'
#' @return Handle to the plot.
#' @export
#'
#' @examples
plotSim <- function(data) {
  p1 <- ggplot2::ggplot(data = data, ggplot2::aes_string(x = 'Time..hr.')) +
    ggplot2::geom_line(ggplot2::aes_string(y = 'simG1 / (simG0 + simG1)')) +
    ggplot2::geom_step(ggplot2::aes_string(y = 'G1 / (G0 + G1)')) +
    ggplot2::ylim(0, 1) + ggplot2::ylab("G1 Percentage") +
    ggplot2::xlab("Time (hrs)")

  p2 <- ggplot2::ggplot(data = data, ggplot2::aes(x = Time..hr.)) +
    ggplot2::geom_line(ggplot2::aes_string(y = 'simG0 + simG1')) +
    ggplot2::geom_step(ggplot2::aes_string(y = 'G0 + G1')) +
    ggplot2::ylab("Number of Cells") + ggplot2::xlab("Time (hrs)") +
    ggplot2::geom_line(ggplot2::aes_string(y = 'simDead'), color = "red") +
    ggplot2::geom_step(ggplot2::aes_string(y = 'dead'), color = "red")

  return(gridExtra::grid.arrange(p1, p2, nrow = 1))
}
meyer-lab/cell-cycle-growth documentation built on May 13, 2019, 6:09 p.m.