# HG changeset patch # User greg # Date 1502382882 14400 # Node ID 7a77ec6342c12a52cda646615dce9ef6274eca22 # Parent d75cbb2db2c4794f98f214b393f34ffe689c0073 Uploaded diff -r d75cbb2db2c4 -r 7a77ec6342c1 build_matrix.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build_matrix.R Thu Aug 10 12:34:42 2017 -0400 @@ -0,0 +1,20 @@ +#!/usr/bin/env Rscript + +suppressPackageStartupMessages(library("optparse")) + +option_list <- list( + make_option(c("-i", "--input"), action="store", dest="input", help="Input .bed.gz file produced by prepMat"), + make_option(c("-o", "--output"), action="store", dest="output", help="Output file"), + make_option(c("-w", "--work_dir"), action="store", dest="work_dir", help="Working directory"), +) + +parser <- OptionParser(usage="%prog [options] file", option_list=option_list) +args <- parse_args(parser, positional_arguments=TRUE) +opt <- args$options + +input_dir = paste(opt$work_dir, "Input/", sep=""); +r_matrix = as.matrix(read.table(opt$input)); +status = match(r_matrix[,3], missing); +r_matrix[,3] = paste(input_dir, r_matrix[,1], ".", r_matrix[,2], ".bed.gz", sep=""); +r_matrix = r_matrix[is.na(status)==T,]; +write.table(array(r_matrix, dim = c(length(r_matrix) / 3, 3)), opt$output, quote=F, row.names=F, col.names=F);