Permalink
Cannot retrieve contributors at this time
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?
TOuCAN/bin/plot_cis_matrix.R
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
117 lines (90 sloc)
2.87 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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", | |
"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) | |
} | |
if(!is.null(commandline_options[["verbose"]])) { | |
verbose <- TRUE | |
} | |
# 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.R")) |