annotate normalize.R @ 24:431aebd93843 draft default tip

Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
author nikos
date Wed, 05 Aug 2015 09:21:02 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
1 ##!/usr/bin/Rscript
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
2
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
3 ## Setup R error handling to go to stderr
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
4 options( show.error.messages = FALSE, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
5
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
6 # we need that to not crash galaxy with an UTF8 error on LC settings.
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
7 Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
8
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
9 suppressMessages(library('getopt'))
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
10
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
11 #get options, using the spec as defined by the enclosed list.
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
12 #we read the options from the default: commandArgs(TRUE).
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
13 spec = matrix(c(
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
14 'treated', 't', 1, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
15 'control', 'c', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
16 'method', 'm', 1, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
17 'fuComplexity', 'b', 2, "integer",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
18 'k2nTreated', 'k', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
19 'k2nControl', 'a', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
20 'cutoff', 'g', 1, "integer",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
21 'reference', 'r', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
22 'compdata', 'h', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
23 'dtcr', 'd', 0, "logical",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
24 'dtcrWindow', 'e', 2, "integer",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
25 'dtcrToZero', 'f', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
26 'slograt', 's', 0, "logical",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
27 'slogratWindow', 'p', 2, "integer",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
28 'depthCorrection', 'q', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
29 'pseudocount', 'l', 2, "integer",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
30 'swinsor', 'w', 0, "logical",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
31 'swinsorWindow', 'x', 2, "integer",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
32 'winsorLevel', 'y', 2, "double",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
33 'fixQuantile', 'z', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
34 'ntOffset', 'n', 2, "integer",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
35 'outputDir', 'o', 1, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
36 'bedgraph', 'v', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
37 'bed', 'j', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
38 'genome', 'i', 2, "character",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
39 'trackName', 'u', 2, "character"
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
40 ), byrow=TRUE, ncol=4);
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
41
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
42 opt = getopt(spec);
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
43
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
44 suppressMessages(require(RNAprobR))
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
45
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
46
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
47 #Create output dir
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
48 dir.create(opt$outputDir, showWarnings = FALSE, recursive = TRUE)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
49
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
50
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
51 if (opt$method=="counts"){
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
52 treated_euc <- readsamples(opt$treated, euc=opt$method)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
53 } else if (opt$method=="Fu") {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
54 treated_euc <- readsamples(opt$treated, euc=opt$method, m = opt$fuComplexity)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
55 } else {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
56 treated_euc <- readsamples(opt$treated, euc=opt$method, k2n_files=opt$k2nTreated)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
57 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
58
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
59
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
60 if ( !is.null(opt$reference)){
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
61 comp_treated <- comp(treated_euc, cutoff=opt$cutoff,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
62 fasta_file=opt$reference)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
63 } else {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
64 comp_treated <- comp(treated_euc, cutoff=opt$cutoff)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
65 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
66
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
67
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
68 #If present, read control file
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
69 if ( !is.null(opt$control) && opt$control != 'None'){
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
70 if (opt$method=="counts"){
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
71 control_euc <- readsamples(opt$control, euc=opt$method)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
72 } else if (opt$method=="Fu") {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
73 control_euc <- readsamples(opt$control, euc=opt$method, m = opt$fuComplexity)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
74 } else {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
75 control_euc <- readsamples(opt$control, euc=opt$method, k2n_files=opt$k2nControl)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
76 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
77 if ( !is.null(opt$reference)){
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
78 comp_control <- comp(control_euc, cutoff=opt$cutoff,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
79 fasta_file=opt$reference)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
80 } else {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
81 comp_control <- comp(control_euc, cutoff=opt$cutoff)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
82 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
83 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
84
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
85 #compdata
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
86 if ( !is.null(opt$compdata) ) {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
87
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
88 normalized <- compdata(comp_treated, nt_offset=opt$ntOffset)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
89 colnames(mcols(normalized))[1:4] <- paste(colnames(mcols(normalized))[1:4], ".treated", sep="")
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
90
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
91 if ( !is.null(opt$control) && opt$control != 'None') {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
92 normalized <- compdata(comp_control, nt_offset=opt$ntOffset, add_to=normalized)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
93 colnames(mcols(normalized))[6:9] <- c("TC.control", "TCR.control", "Cover.control", "PC.control")
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
94 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
95 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
96
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
97 #dtcr
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
98 if ( !is.null(opt$dtcr) ) {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
99 if ( exists("normalized")) {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
100 normalized <- dtcr(comp_control, comp_treated, window_size=opt$dtcrWindow,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
101 nt_offset=opt$ntOffset, bring_to_zero=opt$dtcrToZero,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
102 add_to=normalized)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
103 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
104 else {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
105 normalized <- dtcr(comp_control, comp_treated, window_size=opt$dtcrWindow,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
106 nt_offset=opt$ntOffset, bring_to_zero=opt$dtcrToZero)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
107 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
108 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
109
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
110 #slograt
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
111 if ( !is.null(opt$slograt) ) {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
112 if ( exists("normalized")) {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
113 normalized <- slograt(comp_control, comp_treated, window_size=opt$slogratWindow,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
114 nt_offset=opt$ntOffset, depth_correction = opt$depthCorrection,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
115 pseudocount=opt$pseudocount, add_to=normalized)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
116 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
117 else {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
118 normalized <- slograt(comp_control, comp_treated, window_size=opt$slogratWindow,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
119 nt_offset=opt$ntOffset, depth_correction = opt$depthCorrection,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
120 pseudocount=opt$pseudocount)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
121 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
122 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
123
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
124 #swinsor
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
125 if ( !is.null(opt$swinsor) ) {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
126 if ( exists("normalized")) {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
127 normalized <- swinsor(comp_treated, winsor_level = opt$winsorLevel,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
128 window_size=opt$swinsorWindow,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
129 only_top=opt$fixQuantile, nt_offset=opt$ntOffset,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
130 add_to=normalized)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
131 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
132 else {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
133 normalized <- swinsor(comp_treated, winsor_level = opt$winsorLevel,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
134 window_size=opt$swinsorWindow,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
135 only_top=opt$fixQuantile, nt_offset=opt$ntOffset)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
136 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
137 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
138
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
139 #bedgraph output
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
140 if ( !is.null(opt$bedgraph)) {
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
141 if ( !is.null(opt$dtcr)){
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
142 norm2bedgraph(normalized, bed_file = opt$bed, norm_method = "dtcr",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
143 genome_build = opt$genome,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
144 bedgraph_out_file = paste(opt$outputDir, "/dtcr",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
145 sep=""),
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
146 track_name = opt$trackName,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
147 track_description = opt$trackDesc)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
148 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
149 if ( !is.null(opt$slograt)){
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
150 norm2bedgraph(normalized, bed_file = opt$bed, norm_method = "slograt",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
151 genome_build = opt$genome,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
152 bedgraph_out_file = paste(opt$outputDir, "/slograt",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
153 sep=""),
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
154 track_name = opt$trackName,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
155 track_description = opt$trackDesc)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
156 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
157 if ( !is.null(opt$swinsor)){
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
158 norm2bedgraph(normalized, bed_file = opt$bed, norm_method = "swinsor",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
159 genome_build = opt$genome,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
160 bedgraph_out_file = paste(opt$outputDir, "/swinsor",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
161 sep=""),
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
162 track_name = opt$trackName,
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
163 track_description = opt$trackDesc)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
164 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
165 }
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
166
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
167 output <- GR2norm_df(normalized)
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
168 write.table( output, paste(opt$outputDir, "/norm_df.txt", sep = ""), sep = "\t",
431aebd93843 Fixed a bug in k2n.R where the function k2n_calc() would result in an error for single-end read files.
nikos
parents:
diff changeset
169 quote = F, row.names = F)