-
Notifications
You must be signed in to change notification settings - Fork 2
/
bed2direction.R
executable file
·33 lines (28 loc) · 1.16 KB
/
bed2direction.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env Rscript
suppressPackageStartupMessages(library("optparse"))
## parse command line arguments
option_list <- list(
make_option(c("-i", "--inFile"), help="input file containing results from bed2direction script"),
make_option(c("-j", "--sessionFile"), help="input session file containing SVM model"),
make_option(c("-o", "--outFile"), help="output file containing predictions")
)
parser <- OptionParser(usage = "%prog [options]", option_list=option_list)
opt <- parse_args(parser)
## check, if all required arguments are given
if(is.null(opt$inFile) | is.null(opt$outFile)) {
cat("\nProgram: bed2direction.R (R script to predict NFR directionality)\n")
cat("Author: BRIC, University of Copenhagen, Denmark\n")
cat("Version: 1.0\n")
cat("Contact: pundhir@binf.ku.dk\n");
print_help(parser)
q()
}
## load libraries
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(e1071))
suppressPackageStartupMessages(library(randomForest))
load(opt$sessionFile)
test <- read.table(opt$inFile)
res <- predict(model, test[,c(7:14)])
test[,(ncol(test)+1)] <- res
write.table(test, opt$outFile, sep="\t", row.names=F, col.names=F, quote=F)