-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcov.py
More file actions
32 lines (26 loc) · 954 Bytes
/
cov.py
File metadata and controls
32 lines (26 loc) · 954 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
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("coverage.txt", sep="\t", header=None, names=["chrom", "pos", "depth"])
print(f"Srednia: {round(df["depth"].mean(), 2)}")
print(f"Minimalna glebokosc: {df["depth"].min()}\nMaksymalna glebokosc: {df["depth"].max()}")
window_size = 1000
step_size = 500
window_means = []
window_centers = []
for start in range(0, len(df) - window_size + 1, step_size):
window = df.iloc[start:start + window_size]
window_means.append(window["depth"].mean())
center = window.iloc[window_size // 2]["pos"]
window_centers.append(center)
plt.figure(figsize=(20, 10))
plt.plot(window_centers, window_means)
plt.xlabel("Pozycja")
plt.ylabel("Depth")
plt.savefig("coverage_windowed.png")
plt.close()
plt.figure(figsize=(20, 10))
plt.hist(df["depth"], bins=range(min_depth, max_depth + 1))
plt.xlabel("Glebokosc")
plt.ylabel("Ilosc pozycji")
plt.savefig("coverage_histogram.png")
plt.close()