-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhagfish_cplot2
executable file
·161 lines (121 loc) · 5 KB
/
hagfish_cplot2
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python
import os
import sys
import math
import numpy as np
import matplotlib as mpl
mpl.use('agg')
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import matplotlib as mpl
#import matplotlib.transforms
#import matplotlib.rc as rc
import pylab as pl
import subprocess
from hagfishUtils import *
## Arguments: General options
parser = getHagfishOptparser()
parser.add_option('-S', dest='score', action='store_true',
help='plot the hagfish score' )
#parser.add_option('--pe', dest='pairedends', action='store_true',
# help='plot only based on paired ends')
#parser.add_option('--pe', dest='pairedends', action='store_true',
# help='plot only based on paired ends')
addPlotParameters(parser)
options, args = parser.parse_args()
l = getLogger('main', options.verbose)
l.info("starting %s" % sys.argv[0])
#load the coverage plots
data = hagfishData(options, args)
#prepare the plot
plot = hagfishPlot(options, data, tag='cplot2')
PLOTHIGH = True
PLOTOK = True
PLOTLOW = True
class plotter(hagfishPlotBand):
def plotBand(self):
self.l.debug("Start plotting")
yc = self.yCorrection
#low
self.ax.fill_between(
self.locx,
self.zero + yc,
np.minimum(self.bandTop, (0.5 * self.low) + yc),
zorder=10, color=COLDARKBLUE, linewidth=0)
#print 'ok'
self.ax.fill_between(
self.locx,
np.minimum(self.bandTop, (0.5 * self.low) + yc),
np.minimum(self.bandTop, (0.5 * (self.low + self.ok)) + yc),
zorder=10, color=COLDARKGREEN, linewidth=0)
#print 'high'
self.ax.fill_between(
self.locx,
np.minimum(self.bandTop, (0.5 * (self.low + self.ok)) + yc),
np.minimum(self.bandTop, (0.5 * (self.low + self.ok + self.high)) + yc),
zorder=10, color=COLDARKRED, linewidth=0)
#low
self.ax.fill_between(
self.locx,
self.zero + yc,
np.maximum(self.bandBottom, -(0.5 * self.low_ends) + yc),
zorder=10, color=COLDARKBLUE, linewidth=0)
#print 'ok'
self.ax.fill_between(
self.locx,
np.maximum(self.bandBottom, -(0.5 * self.low_ends) + yc),
np.maximum(self.bandBottom, -(0.5 * (self.low_ends + self.ok_ends)) + yc),
zorder=10, color=COLDARKGREEN, linewidth=0)
#print 'high'
self.ax.fill_between(
self.locx,
np.maximum(self.bandBottom, -(0.5 * (self.low_ends + self.ok_ends)) + yc),
np.maximum(self.bandBottom, -(0.5 * (self.low_ends + self.ok_ends + self.high_ends)) + yc),
zorder=10, color=COLDARKRED, linewidth=0)
if self.__dict__.has_key('nns'):
self.l.info("plotting N band")
self.l.info("maxY %s" % self.plot.maxY)
self.l.info("max min nns %s %s " % (np.max(self.nns), np.min(self.nns)))
self.l.info("bandbot, bandtop %s %s " % (self.bandBottom, self.bandTop))
self.ax.fill_between(
self.locx,
yc + (self.plot.maxY * self.nns),
yc - (self.plot.maxY * self.nns),
linewidth=0,
color=COLLIGHTYELLOW)
if options.score:
score = self.data.medianH * (
1 - 2 * np.exp(-1 * (self.ok / self.data.median))
+ np.exp(-1 * ( ( self.ok + self.low + self.high) / self.data.median))
)
l.info("Plotting score: min %s, max %s" % (np.min(score), np.max(score)))
self.ax.plot(self.locx, score + yc, color='black', linewidth=2, zorder=20)
l.info("%s %s" % (self.start, self.stop))
txtx = -0.01 * self.plot.ntPerBand
self.ax.text(txtx, yc - self.data.medianH,'ecp', fontsize=9,
horizontalalignment='right', verticalalignment='center',
zorder=50)
self.ax.text(txtx, yc + self.data.medianH,'icp', fontsize=9,
horizontalalignment='right', verticalalignment='center',
zorder=50)
if self.band > 0:
self.ax.axhline(
self.yCorrection + self.plot.maxY, linewidth=3,
alpha=0.3, color=COLDARKYELLOW)
def setYticks2(self):
self.plot.yTicks2.append(self.yCorrection - self.data.medianH)
self.plot.yTicks2.append(self.yCorrection)
self.plot.yTicks2.append(self.yCorrection + self.data.medianH)
self.plot.yTickLabels2.append("%s" % -self.data.median)
self.plot.yTickLabels2.append("0")
self.plot.yTickLabels2.append("%s" % self.data.median)
self.ax.axhline(
self.yCorrection - self.data.medianH,
alpha=0.3,
color='black')
self.ax.axhline(
self.yCorrection + self.data.medianH,
alpha=0.3,
color='black')
plot.plotBands(plotter)
plot.save(tag='cplot2')