Ignacio Arroyo

PErsistencia para graficar lista

......@@ -3,7 +3,7 @@
import os
import matplotlib.pyplot as plt
from numpy import log10
from pdb import set_trace as st
def analyze_pair(group_anlized, gropus_dir, rev, eigenvectors, fo):
dic_part = {}
......@@ -72,6 +72,9 @@ def get_cmap(n, name='hsv'):
return plt.cm.get_cmap(name, n)
plotting = False
out_file = "persistence.csv"
log = False
rev = 120
ff = "report_persistence_.csv"
eigenvectors = "one-by-one/eigen_vectors/eigenBOs_120-eigens.txt"
......@@ -95,22 +98,37 @@ for g in groups_analyzed:
rev=rev, eigenvectors=eigenvectors, fo=ff)
plots.append(partition)
fig = plt.figure()
ax1 = fig.add_subplot(111)
for i, p in enumerate(plots):
if " ".join(p['tfs'][0]) == marked:
width = 6
mark = "D"
else:
width = 2
mark = ""
ax1.plot(p['part'], log10(p['n_tfs']), c=cmap(i), linewidth=width,
marker=mark, label=" ".join(p['tfs'][0]))
plt.legend(loc='upper right')
plt.title("TF pair persistence through partitions of model resolution")
plt.xlabel("Partition")
plt.ylabel("Number of TFs (log_10)")
plt.show()
if plotting:
fig = plt.figure()
ax1 = fig.add_subplot(111)
for i, p in enumerate(plots):
if " ".join(p['tfs'][0]) == marked:
width = 6
mark = "D"
else:
width = 2
mark = ""
ax1.plot(p['part'], log10(p['n_tfs']) if log else p['n_tfs'],
c=cmap(i), linewidth=width, marker=mark,
label=" ".join(p['tfs'][0]))
plt.legend(loc='upper right')
plt.title("TF pair persistence through partitions of model resolution")
plt.xlabel("Partition")
plt.ylabel("Number of TFs (log_10)")
plt.show()
else:
import csv
lists = []
pn = [' '] + list(plots[0]['part'])
lists.append(pn)
for p in plots:
lists.append([p['tfs'][0]] + list(p['n_tfs']))
lists.append([p['tfs'][0]] + list(p['tfs']))
with open(out_file, 'w') as f:
writer = csv.writer(f, delimiter='\t')
writer.writerows(zip(*lists))
......
This diff could not be displayed because it is too large.