Mercurial > repos > greg > ideas_preprocessor
changeset 14:20c21d946a8e draft
Uploaded
author | greg |
---|---|
date | Wed, 24 Jan 2018 14:04:55 -0500 |
parents | 4d542da396a7 |
children | ce2021cd68d2 |
files | ideas_preprocessor.R |
diffstat | 1 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ideas_preprocessor.R Wed Jan 24 14:04:47 2018 -0500 +++ b/ideas_preprocessor.R Wed Jan 24 14:04:55 2018 -0500 @@ -1,11 +1,22 @@ #!/usr/bin/env Rscript +# TODO: implement support for the following: +# 1. Scenario where user did not select chrom_bed_input +# 2. --exclude_bed_input +# 3. --bychr +# 4. --chrom_len_file +# 5. --reads_per_bp +# 6. --restrict_to_chroms +# 7. --standardize_datasets +# 8. Scenario where --window_size is NULL and need to handle bamCoverage - see TODO near line # 57. + + suppressPackageStartupMessages(library("data.table")) suppressPackageStartupMessages(library("optparse")) option_list <- list( make_option(c("--chrom_bed_input"), action="store", dest="chrom_bed_input", defaul=NULL, help="Chromosome windows positions file"), - make_option(c("--exclude_input"), action="store", dest="exclude_input", defaul=NULL, help="File(s) containing regions to exclude"), + make_option(c("--exclude_bed_input"), action="store", dest="exclude_bed_input", defaul=NULL, help="File(s) containing regions to exclude"), make_option(c("--bychr"), action="store_true", dest="bychr", defaul=FALSE, help="Separate files by chromosome"), make_option(c("--chrom_len_file"), action="store", dest="chrom_len_file", default=NULL, help="Chromosome lengths file"), make_option(c("--ideaspre_input_config"), action="store", dest="ideaspre_input_config", help="Preprocessing input config file"), @@ -42,8 +53,13 @@ # Read the ideaspre_input_config text file which has this format: # "cell type name" "epigenetic factor name" "file path" "file name" "datatype" ideaspre_input_config = as.matrix(read.table(opt$ideaspre_input_config)); + +# TODO: fix this +window_size = opt$window_size +if (is.null(opt$window_size)) { + window_size = 500; +} # Process data to windows mean. -# TODO: implement scenario where user did not select chrom_bed_input. if (!is.null(opt$chrom_bed_input)) { for (i in 1:dim(ideaspre_input_config)[1]) { file_path = ideaspre_input_config[i, 3] @@ -53,7 +69,8 @@ cmd = paste("samtools index", file_path); system(cmd); bigwig_file_name = paste(file_name, "bw", sep="."); - cmd = paste("bamCoverage --bam", file_path, "-o", bigwig_file_name, "--binSize", opt$window_size); + + cmd = paste("bamCoverage --bam", file_path, "-o", bigwig_file_name, "--binSize", window_size); system(cmd); } else { bigwig_file_name = file_path;