-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhistogram.py
More file actions
executable file
·40 lines (32 loc) · 957 Bytes
/
histogram.py
File metadata and controls
executable file
·40 lines (32 loc) · 957 Bytes
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
#!/usr/bin/env python3
from scipy.stats import poisson
import matplotlib.pyplot as plt
import numpy
import sys
# For plotting a histogram of a samtools depth file.
file_name = sys.argv[1]
y_axis = sys.argv[2] #Name of the y-axis
if len(sys.argv) > 3:
x_axis = sys.argv[3] #If 3rd arg added, x_axis will be named, and actual chromosome vals will be tracked
else:
x_axis = None
d_list = []
loc_list = []
with open(file_name, 'r') as file:
for line in file:
line = line.split('\t')
d_list.append(line[2])
if bool(x_axis) == True:
loc_list.append(line[1])
#if bool(loc_list) == True:
# plt.plot(loc_list, d_list)
# plt.ylabel(y_axis)
# plt.xlabel(x_axis)
# plt.show()
#else:
# plt.plot(d_list)
# plt.ylabel(y_axis)
# plt.show()
#plt.savefig(f'x_y_plot_{file_name[:-3]}')
#plt.hist(loc_list)
#n, bins, patches = patches = plt.hist(x, 75, density = True, facecolor = 'g', alpha=0.75)