R/standard_tests.R

Defines functions perform_DNA_test

Documented in perform_DNA_test

#' Perform DNA test and plot
#'
#' @param algorithm = the function that you want to use. It has to receive the chain as first argument and
#'  return a list of the format `("change_points", "estimated_matrices")`, where `change_points` is vector of
#'  indeces of fixed points and `estimated_matrices` is the list of estimated matrices for each chunk
#'
#' @param size = test size
#' @param ... = the additional parameters to be passed to the algorithm
#'
#' @return what the inner algorithm returns
#' @export

perform_DNA_test = function(algorithm, size = 1000, ...)
{
  # Read genomic data
  dat <- read.fasta(file = "../changepoints/data/chrI.fa.gz")
  dat2 <- unlist(dat, use.names = FALSE)
  dat2f <- as.factor(dat2)[1:size]

  results <- algorithm(dat2f, ...)

  change_points = results$change_points
  matrices = results$estimated_matrices

  DNA_plot(dat2f, change_points)

  results
}
aaaaana/changepoints documentation built on May 26, 2019, 1:35 p.m.