Skip to content
Snippets Groups Projects
Commit 0d92cb04 authored by Rohmer Coralie's avatar Rohmer Coralie
Browse files

python graph

parent 4854c62d
Branches
No related tags found
No related merge requests found
#!/usr/bin/env python3
import sys,csv
import matplotlib.pyplot as plt
from pylab import *
plt.style.use('seaborn-whitegrid')
import numpy as np
def recovered_threshold(file):
path=file.split("_")[-1].split(".")[0][1:]
return path
attribute=sys.argv[1]
dir_out=sys.argv[2]
files=[sys.argv[3]]#,sys.argv[4]]
data={}
attribute_max=""
for file in files:
threshold=recovered_threshold(file)
with open(file, newline='') as csvfile:
data[threshold]={}
spamreader=csv.reader(csvfile)
titles={}
for row in spamreader:
if row[0]== "MSA":
for i in range(len(row)):
titles[row[i]]=i
else:
msa=row[titles["MSA"]]
region_size=row[titles["region_size"]]
depth=row[titles["depth"]]
if msa not in data[threshold]:
data[threshold][msa]={}
if region_size not in data[threshold][msa]:
data[threshold][msa][region_size]={}
data[threshold][msa][region_size]["depth"]=[]
data[threshold][msa][region_size]["attribute"]=[]
if depth not in data[threshold][msa][region_size]:
data[threshold][msa][region_size]["depth"].append(int(depth))
val=row[titles[attribute]]
if val > attribute_max:
attribute_max=val
data[threshold][msa][region_size]["attribute"].append(float(val))
print(data)
print(attribute_max)
color=["b","r","g","p","y"]
for threshold in data:
for msa in data[threshold]:
fig = plt.figure()
ax = plt.axes()
ax = ax.set(xlabel='Depth', ylabel=attribute)
plt.title(attribute + " for " + msa)
i=0
plt.axis([0, 50,0, float(attribute_max)+10]);
for region_size in data[threshold][msa]:
x = np.array(data[threshold][msa][region_size]["depth"])
y = np.array(data[threshold][msa][region_size]["attribute"])
plt.plot(x, y, color=color[i], linestyle='solid', label=" Region size: " + region_size)
i+=1
plt.legend(loc='lower left');
fig = plt.figure()
ax = plt.axes()
x = np.array([10,20,50])
y = np.array([10,20,50])
plt.plot(x, y, color='blue', linestyle='solid', label='bleu')
show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment