R/burst_copies.R

#' Chooses how much to burst a sequence by
#' That is, how much to increase the copy number of a sequence by
#' We choose the increase in copy number from a Poisson random distribution
#' @param copy_numbers The copy number for each sequence
#' @param mean The mean of the Poisson random distribution
#' @param burst_probability The probability of a sequence bursting
#' @return A vector of new copy numbers
#' @export
burst_copies <- function(copy_numbers, burst_mean, burst_probability)
{
  to_burst <- test_event(burst_probability, length(copy_numbers))
  burst_by <- function(index)
  {
    if (to_burst[index]) {
      return(rpois(1, burst_mean)+copy_numbers[index])
    }
    else { return(copy_numbers[index]) }
  }
  return(sapply(1:length(copy_numbers), burst_by))
}
sams25/rcombinator_old documentation built on May 28, 2019, 8:40 a.m.