R/gland_create.R

#' Create gland of cells from a single starting cell.
#'
#' @param starting_value logical vector of states.
#' @param change Rate of mutation for each cell splitting. First values is the
#'  chance of going form 0 to 1, and the second is the chance of going for 1 to 0.
#' @param n_iter number of generations of cell splitting. Defaults to 12 which
#' results in 4096 cells.
#' @return A list of cells. gland object.
#' @examples
#' gland_create(sample(c(0, 1), 10, TRUE))
#' @export
gland_create <- function(starting_value, change = c(0.002, 0.006),
                         n_iter = 12) {
  out <- matrix(starting_value, nrow = 1)
  cell_length <- length(starting_value)
  for (i in seq_len(n_iter)) {
    out <- cell_split(out, change = change)
  }
  structure(list(cells = out,
                 cell_length = cell_length,
                 mutation_chance = change), class = "gland")
}
EmilHvitfeldt/cell documentation built on May 5, 2019, 7:03 p.m.