Mercurial > repos > greg > ideas
comparison create_heatmaps.R @ 159:04db93e8566b draft
Uploaded
author | greg |
---|---|
date | Fri, 12 Jan 2018 14:14:38 -0500 |
parents | 08e77c105188 |
children | 19142fc18b2d |
comparison
equal
deleted
inserted
replaced
158:c996089f1747 | 159:04db93e8566b |
---|---|
3 suppressPackageStartupMessages(library("optparse")) | 3 suppressPackageStartupMessages(library("optparse")) |
4 | 4 |
5 option_list <- list( | 5 option_list <- list( |
6 make_option(c("--input_dir"), action="store", dest="input_dir", help="IDEAS para files directory"), | 6 make_option(c("--input_dir"), action="store", dest="input_dir", help="IDEAS para files directory"), |
7 make_option(c("--output_dir"), action="store", dest="output_dir", help="PDF output directory"), | 7 make_option(c("--output_dir"), action="store", dest="output_dir", help="PDF output directory"), |
8 make_option(c("--script_dir"), action="store", dest="script_dir", help="R script source directory") | 8 make_option(c("--script_dir"), action="store", dest="script_dir", help="R script source directory"), |
9 make_option(c("--in_training_mode"), action="store_true", dest="in_training_mode", default=FALSE, help="Flag for training mode") | |
9 ) | 10 ) |
10 | 11 |
11 parser <- OptionParser(usage="%prog [options] file", option_list=option_list); | 12 parser <- OptionParser(usage="%prog [options] file", option_list=option_list); |
12 args <- parse_args(parser, positional_arguments=TRUE); | 13 args <- parse_args(parser, positional_arguments=TRUE); |
13 opt <- args$options; | 14 opt <- args$options; |
14 | 15 |
15 heatmap_path <- paste(opt$script_dir, "create_heatmap.R", sep="/"); | 16 heatmap_path <- paste(opt$script_dir, "create_heatmap.R", sep="/"); |
16 source(heatmap_path); | 17 source(heatmap_path); |
17 | 18 |
18 para_files <- list.files(path=opt$input_dir, pattern="\\.para$", full.names=TRUE); | 19 if (opt$in_training_mode) { |
20 ext <- ".para"; | |
21 para_files <- list.files(path=opt$input_dir, pattern="\\.para$", full.names=TRUE); | |
22 } else { | |
23 ext <- ".para0"; | |
24 para_files <- list.files(path=opt$input_dir, pattern="\\.para0$", full.names=TRUE); | |
25 } | |
19 for (i in 1:length(para_files)) { | 26 for (i in 1:length(para_files)) { |
20 para_file <- para_files[i]; | 27 para_file <- para_files[i]; |
21 para_file_base_name <- strsplit(para_file, split="/")[[1]][2]; | 28 para_file_base_name <- strsplit(para_file, split="/")[[1]][2]; |
22 output_file_base_name <- gsub(".para", "", para_file_base_name); | 29 output_file_base_name <- gsub(ext, "", para_file_base_name); |
23 output_file_name <- paste(output_file_base_name, "state", i, "pdf", sep="."); | 30 output_file_name <- paste(output_file_base_name, "state", i, "pdf", sep="."); |
24 output_file_path <- paste(opt$output_dir, output_file_name, sep="/"); | 31 output_file_path <- paste(opt$output_dir, output_file_name, sep="/"); |
25 data_frame <- read.table(para_file, comment="!", header=T); | 32 data_frame <- read.table(para_file, comment="!", header=T); |
26 create_heatmap(data_frame, output_file_path); | 33 create_heatmap(data_frame, output_file_path); |
27 } | 34 } |