-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhagfish_cplot
executable file
·127 lines (98 loc) · 3.75 KB
/
hagfish_cplot
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
#!/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='cplot')
PLOTHIGH = True
PLOTOK = True
PLOTLOW = True
class plotter(hagfishPlotBand):
def plotBand(self):
self.l.debug("Start plotting")
yc = self.yCorrection
#print 'high'
self.ax.fill_between(
self.locx,
np.minimum(self.bandTop, self.okh + yc),
np.minimum(self.bandTop, self.okh + self.high + yc),
zorder = 1, linewidth=0, alpha=1,
color=COLDARKRED)
#print 'ok'
self.ax.fill_between(
self.locx,
np.minimum(self.bandTop, self.okh + yc),
np.maximum(self.bandBottom, -self.okh + yc),
color=COLDARKGREEN, linewidth=0, alpha=1,
zorder=1)
#low
self.ax.fill_between(
self.locx,
np.maximum(self.bandBottom, -self.okh + yc),
np.maximum(self.bandBottom, -(self.okh + self.low) + yc),
color=COLDARKBLUE, linewidth=0, alpha=1,
zorder=1)
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, zorder=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.debug("Plotting score: min %s, max %s" % (np.min(score), np.max(score)))
self.ax.plot(self.locx, score + yc, color='black', linewidth=2)
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.medianH)
self.plot.yTickLabels2.append("0")
self.plot.yTickLabels2.append("%s" % self.data.medianH)
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()