Skip to content
Permalink
master
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
#!/bin/env Rscript
#'
#' fixed global variables
#'
# select the input file
chipfile <- "../test_data/CTCF.bedgraph"
# set the output file
outfile <- "CTCF.png"
# specify a region to plot
region <- NULL
dpi <- 600
width <- 6
height <- 2
minimum_signal <- NULL
# load the libraries
library_path <- "."
#
source(file.path(library_path, "chip_body.R"))
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",
"dpi", "d", 2, "integer",
"minimum-signal", "s", 2, "double",
"width", "w", 2, "integer",
"height", "h", 2, "integer",
"library", "l", 1, "character",
"verbose", "v", 0, "logical",
"help", "", 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
chipfile <- 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[["minimum-signal"]])){
minimum_signal <- commandline_options[["minimum-signal"]]
}
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[["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("Minimum signal", minimum_signal))
message(paste("DPI", dpi))
message(paste("Width", width))
message(paste("Height", height))
message(paste("Library path", library_path))
}
# perform the analysis
source(file.path(library_path, "chip_body.R"))