Showing
2 changed files
with
38 additions
and
20 deletions
| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | import os | 3 | import os |
| 4 | import matplotlib.pyplot as plt | 4 | import matplotlib.pyplot as plt |
| 5 | from numpy import log10 | 5 | from numpy import log10 |
| 6 | - | 6 | +from pdb import set_trace as st |
| 7 | 7 | ||
| 8 | def analyze_pair(group_anlized, gropus_dir, rev, eigenvectors, fo): | 8 | def analyze_pair(group_anlized, gropus_dir, rev, eigenvectors, fo): |
| 9 | dic_part = {} | 9 | dic_part = {} |
| ... | @@ -72,6 +72,9 @@ def get_cmap(n, name='hsv'): | ... | @@ -72,6 +72,9 @@ def get_cmap(n, name='hsv'): |
| 72 | return plt.cm.get_cmap(name, n) | 72 | return plt.cm.get_cmap(name, n) |
| 73 | 73 | ||
| 74 | 74 | ||
| 75 | +plotting = False | ||
| 76 | +out_file = "persistence.csv" | ||
| 77 | +log = False | ||
| 75 | rev = 120 | 78 | rev = 120 |
| 76 | ff = "report_persistence_.csv" | 79 | ff = "report_persistence_.csv" |
| 77 | eigenvectors = "one-by-one/eigen_vectors/eigenBOs_120-eigens.txt" | 80 | eigenvectors = "one-by-one/eigen_vectors/eigenBOs_120-eigens.txt" |
| ... | @@ -95,22 +98,37 @@ for g in groups_analyzed: | ... | @@ -95,22 +98,37 @@ for g in groups_analyzed: |
| 95 | rev=rev, eigenvectors=eigenvectors, fo=ff) | 98 | rev=rev, eigenvectors=eigenvectors, fo=ff) |
| 96 | plots.append(partition) | 99 | plots.append(partition) |
| 97 | 100 | ||
| 98 | -fig = plt.figure() | 101 | +if plotting: |
| 99 | -ax1 = fig.add_subplot(111) | 102 | + fig = plt.figure() |
| 100 | - | 103 | + ax1 = fig.add_subplot(111) |
| 101 | -for i, p in enumerate(plots): | 104 | + |
| 102 | - if " ".join(p['tfs'][0]) == marked: | 105 | + for i, p in enumerate(plots): |
| 103 | - width = 6 | 106 | + if " ".join(p['tfs'][0]) == marked: |
| 104 | - mark = "D" | 107 | + width = 6 |
| 105 | - else: | 108 | + mark = "D" |
| 106 | - width = 2 | 109 | + else: |
| 107 | - mark = "" | 110 | + width = 2 |
| 108 | - | 111 | + mark = "" |
| 109 | - ax1.plot(p['part'], log10(p['n_tfs']), c=cmap(i), linewidth=width, | 112 | + |
| 110 | - marker=mark, label=" ".join(p['tfs'][0])) | 113 | + ax1.plot(p['part'], log10(p['n_tfs']) if log else p['n_tfs'], |
| 111 | - | 114 | + c=cmap(i), linewidth=width, marker=mark, |
| 112 | -plt.legend(loc='upper right') | 115 | + label=" ".join(p['tfs'][0])) |
| 113 | -plt.title("TF pair persistence through partitions of model resolution") | 116 | + |
| 114 | -plt.xlabel("Partition") | 117 | + plt.legend(loc='upper right') |
| 115 | -plt.ylabel("Number of TFs (log_10)") | 118 | + plt.title("TF pair persistence through partitions of model resolution") |
| 116 | -plt.show() | 119 | + plt.xlabel("Partition") |
| 120 | + plt.ylabel("Number of TFs (log_10)") | ||
| 121 | + plt.show() | ||
| 122 | +else: | ||
| 123 | + import csv | ||
| 124 | + | ||
| 125 | + lists = [] | ||
| 126 | + pn = [' '] + list(plots[0]['part']) | ||
| 127 | + lists.append(pn) | ||
| 128 | + for p in plots: | ||
| 129 | + lists.append([p['tfs'][0]] + list(p['n_tfs'])) | ||
| 130 | + lists.append([p['tfs'][0]] + list(p['tfs'])) | ||
| 131 | + | ||
| 132 | + with open(out_file, 'w') as f: | ||
| 133 | + writer = csv.writer(f, delimiter='\t') | ||
| 134 | + writer.writerows(zip(*lists)) | ... | ... |
persistence.csv
0 → 100644
This diff could not be displayed because it is too large.
-
Please register or login to post a comment