R/get.coverage.by.sample.statistics.R

Defines functions get.coverage.by.sample.statistics

Documented in get.coverage.by.sample.statistics

#' Get statistics about coverage per sample
#'
#' @param project.directory Path to project directory. Each sample should have its own subdirectory
#' 
#' @return coverage.by.sample.statistics Data frame with coverage statistics per sample
#' 
#'
get.coverage.by.sample.statistics <- function(project.directory) {
    
    ### INPUT TESTS ###########################################################
    
    if( !is.character(project.directory) || length(project.directory) > 1 ) {
        stop('project.directory must be a string.');
    }
    
    if( !file.exists(project.directory) ) {
        error.message <- paste('Directory', project.directory, 'does not exist');
        stop(error.message);
    }
    
    
    ### MAIN ##################################################################
    
    # gather data from individual files
    total.coverage.statistics <- process.total.coverage.statistics(project.directory);
    coverage.report.data <- process.coverage.reports(project.directory);
    
    # merge – this has to be done pairwise
    # does the sample order have to match Ros' ? 
    coverage.by.sample.statistics <- merge(
        total.coverage.statistics,
        coverage.report.data,
        by = "sample.id",
        all = TRUE
    ); 
    
    return(coverage.by.sample.statistics);
    
}

Try the varitas package in your browser

Any scripts or data that you put into this service are public.

varitas documentation built on Nov. 14, 2020, 1:07 a.m.