comparison build_matrix.R @ 13:c59cbd44dcff draft

Uploaded
author greg
date Thu, 10 Aug 2017 14:09:18 -0400
parents 7a77ec6342c1
children 65739ddd00be
comparison
equal deleted inserted replaced
12:5b5733e09344 13:c59cbd44dcff
3 suppressPackageStartupMessages(library("optparse")) 3 suppressPackageStartupMessages(library("optparse"))
4 4
5 option_list <- list( 5 option_list <- list(
6 make_option(c("-i", "--input"), action="store", dest="input", help="Input .bed.gz file produced by prepMat"), 6 make_option(c("-i", "--input"), action="store", dest="input", help="Input .bed.gz file produced by prepMat"),
7 make_option(c("-o", "--output"), action="store", dest="output", help="Output file"), 7 make_option(c("-o", "--output"), action="store", dest="output", help="Output file"),
8 make_option(c("-w", "--work_dir"), action="store", dest="work_dir", help="Working directory"),
9 ) 8 )
10 9
11 parser <- OptionParser(usage="%prog [options] file", option_list=option_list) 10 parser <- OptionParser(usage="%prog [options] file", option_list=option_list)
12 args <- parse_args(parser, positional_arguments=TRUE) 11 args <- parse_args(parser, positional_arguments=TRUE)
13 opt <- args$options 12 opt <- args$options
14 13
15 input_dir = paste(opt$work_dir, "Input/", sep="");
16 r_matrix = as.matrix(read.table(opt$input)); 14 r_matrix = as.matrix(read.table(opt$input));
17 status = match(r_matrix[,3], missing); 15 status = match(r_matrix[,3], missing);
18 r_matrix[,3] = paste(input_dir, r_matrix[,1], ".", r_matrix[,2], ".bed.gz", sep=""); 16 r_matrix[,3] = paste(opt$work_dir, r_matrix[,1], ".", r_matrix[,2], ".bed.gz", sep="");
19 r_matrix = r_matrix[is.na(status)==T,]; 17 r_matrix = r_matrix[is.na(status)==T,];
20 write.table(array(r_matrix, dim = c(length(r_matrix) / 3, 3)), opt$output, quote=F, row.names=F, col.names=F); 18 write.table(array(r_matrix, dim = c(length(r_matrix) / 3, 3)), opt$output, quote=F, row.names=F, col.names=F);