Skip to content
Permalink
e7fbf8d086
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
119 lines (92 sloc) 2.99 KB
#!/bin/env Rscript
#'
#' fixed global variables
#'
# select the input file
infile <- "../test_data/combined.matrix.bed"
# set the output file
outfile <- "interactions.png"
# specify a region to plot
region <- NULL
colour_range <- NULL
dpi <- 600
width <- 6
height <- 6
add_borders_to_elements <- FALSE
library_path <- "."
verbose <- FALSE
require(getopt, quietly = TRUE)
# set the commandline option specifications
specification <- matrix(c(
"bedfile", "b", 1, "character",
"outfile", "o", 2, "character",
"chromosome", "c", 2, "character",
"start", "s", 2, "integer",
"end", "e", 2, "integer",
"colour-minimum", "m", 2, "double",
"colour-maximum", "x", 2, "double",
"dpi", "d", 2, "integer",
"width", "w", 2, "integer",
"height", "h", 2, "integer",
"library", "l", 1, "character",
"verbose", "v", 0, "logical",
"tad", "t", 1, "character",
"organism", "r", 1, "character",
"name", "n", 1, "character",
"borders", "y", 0, "logical",
"help", "a", 0, "logical"
), byrow = TRUE, ncol = 4)
# parse the commandline options
commandline_options <- getopt(specification)
# print the usage if help was asked
if(!is.null(commandline_options[["help"]])) {
cat(getopt(specification, usage = TRUE))
q(status = 1)
}
tadfile <- commandline_options[["tad"]]
organism <- commandline_options[["organism"]]
# set the required variables
infile <- commandline_options[["bedfile"]]
#
if(!is.null(commandline_options[["chromosome"]]) && !is.null(commandline_options[["start"]]) && !is.null(commandline_options[["end"]])){
region <- list(
"chr" = commandline_options[["chromosome"]],
"start" = commandline_options[["start"]],
"end" = commandline_options[["end"]])
}
if(!is.null(commandline_options[["outfile"]])){
outfile <- commandline_options[["outfile"]]
}
if(!is.null(commandline_options[["colour-minimum"]]) && !is.null(commandline_options[["colour-maximum"]])) {
colour_range <- c(
commandline_options[["colour-minimum"]],
commandline_options[["colour-maximum"]])
}
if(!is.null(commandline_options[["dpi"]])){
dpi <- commandline_options[["dpi"]]
}
if(!is.null(commandline_options[["width"]])){
width <- commandline_options[["width"]]
}
if(!is.null(commandline_options[["heigth"]])){
height <- commandline_options[["heigth"]]
}
if(!is.null(commandline_options[["borders"]])){
add_borders_to_elements <- TRUE
}
if(!is.null(commandline_options[["library"]])){
library_path <- commandline_options[["library"]]
}
if(verbose){
message(paste("BED file", infile))
message(paste("Output", outfile))
message(paste("Region", paste(region, collapse = " ")))
message(paste("Colour range", paste(colour_range, collapse = " ")))
message(paste("DPI", dpi))
message(paste("Width", width))
message(paste("Height", height))
message(paste("Borders", add_borders_to_elements))
message(paste("Library path", library_path))
}
# perform the analysis
source(file.path(library_path, "cis_matrix_body_multi.R"))