forked from sungyoung-lee/visbam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize.py
More file actions
64 lines (51 loc) · 1.67 KB
/
Copy pathvisualize.py
File metadata and controls
64 lines (51 loc) · 1.67 KB
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
import os
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('TKAgg')
import matplotlib.pyplot as plt
roi_path = 'egfr.roi.txt'
path_dir = 'out'
file_list = os.listdir(path_dir)
roifile = open(roi_path, "r")
lines = roifile.readlines()
for i, line in enumerate(lines) :
first = line.find(':')
second = line.find('-')
contig = line[:first]
start = int(line[first+1:second])
stop = int(line[second+1:])
coverage = [[] for i in range(stop-start+1)]
for file_name in file_list :
outlist = list(map(int, open(path_dir+"/"+file_name, "r").readlines()[i].split(',')))
for j, out in enumerate(outlist) :
coverage[j].append(out)
print('\r', file_name+", roi"+str(i+1), end='')
print('\n'+"roi"+str(i+1)+" saving...")
fig = plt.figure()
xticks = np.arange(start, stop+1)
df = pd.DataFrame(list(map(list, zip(*coverage))))#, columns=xticks)
boxplot = df.boxplot()
plt.savefig(roi_path+"_"+"roi"+str(i+1)+"_boxplot"+'.png')
plt.close(fig)
print(roi_path+"_"+"roi"+str(i+1)+"_boxplot"+'.png saved!')
fig2 = plt.figure()
df2 = pd.DataFrame(coverage, index=xticks, columns=None)
df2.plot(color='black', alpha=0.1)
plt.legend().remove()
plt.savefig(roi_path+"_"+"roi"+str(i+1)+"_lineplot"+'.png')
plt.close(fig)
print(roi_path+"_"+"roi"+str(i+1)+"_lineplot"+'.png saved!')
roifile.close()
'''
# box plot test
df = pd.DataFrame(samlist, columns = [columnname])
plt.figure(figsize=(7, 6))
boxplot = df.boxplot(column = [columnname])
plt.yticks(np.arange(min(samlist), max(samlist), step=(max(samlist)-min(samlist))/20))
# line plot test
cvindex = np.arange(start-span, stop+span+1)
df2 = pd.DataFrame(cv, index = cvindex)
lines = df2.plot.line()
plt.show()
'''