Skip to content

Commit

Permalink
works on #83
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesABaker committed Feb 6, 2020
1 parent c441ba0 commit af03b97
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 69 deletions.
55 changes: 29 additions & 26 deletions scripts/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
return texts


def heatmap(var_freqs_list, title, aa_order, color, is_it_log, annotation_format="{x:n}"):
def heatmap(var_freqs_list, title, aa_order, color, is_it_log, annotation_format="{x:n}", bars=True):
'''
var_freqs_list
heatmap array in list of lists
Expand Down Expand Up @@ -168,7 +168,7 @@ def heatmap(var_freqs_list, title, aa_order, color, is_it_log, annotation_format
ax_histx.tick_params(direction='in', labelbottom=False)
ax_scale = plt.axes(rect_scale)

print(var_freqs_list)
#print(var_freqs_list)
im = ax_heatmap.imshow(var_freqs_list, cmap=color,
interpolation='nearest', norm=is_it_log)
texts = annotate_heatmap(im, valfmt=annotation_format)
Expand All @@ -190,43 +190,46 @@ def heatmap(var_freqs_list, title, aa_order, color, is_it_log, annotation_format
flagged_cells = impossible_cordinates(aa_order)
ax_heatmap.scatter(flagged_cells[0], flagged_cells[1], marker="x", color="silver", s=75)

# histogram on the right
ax_histx.bar(list(range(0, 20)), x_histogram(var_freqs_list),
orientation='vertical', color='grey')

ax_histy.axis('off')
ax_histx.axis('off')
ax_histx.margins(0.00)
rects = ax_histx.patches
if bars == True:
# histogram on the right
ax_histx.bar(list(range(0, 20)), x_histogram(var_freqs_list),
orientation='vertical', color='grey')

# Make some labels.
labels = x_histogram(var_freqs_list)
ax_histx.axis('off')
ax_histx.margins(0.00)
rects = ax_histx.patches

for rect, label in zip(rects, labels):
height = rect.get_height()
ax_histx.text(rect.get_x() + rect.get_width() / 2, height + 5, int(label),ha='center', va='bottom')
# Make some labels.
labels = x_histogram(var_freqs_list)

#ax_histx.hist(x_histogram(var_freqs_list), 21, histtype='stepfilled', orientation='vertical', color='grey')
for rect, label in zip(rects, labels):
height = rect.get_height()
ax_histx.text(rect.get_x() + rect.get_width() / 2, height + 5, int(label),ha='center', va='bottom')

# histogram in the top
#print(list(range(0, 20)), y_histogram(var_freqs_list))
# ax_histy.bar(list(range(0, 20)), y_histogram(var_freqs_list), orientation='horizontal', color='grey')
y_values_ordered = y_histogram(var_freqs_list).reverse()
ax_histy.barh(list(range(0, 20)), y_histogram(var_freqs_list),
orientation='horizontal', color='grey')
#ax_histx.hist(x_histogram(var_freqs_list), 21, histtype='stepfilled', orientation='vertical', color='grey')

ax_histy.axis('off')
ax_histy.margins(0.00)
for i, v in enumerate(y_histogram(var_freqs_list)):
ax_histy.text(v + 3, i , int(v))
#ax_histy.barh(list(range(0, 20)), y_values_ordered, color='gainsboro')
# histogram in the top
#print(list(range(0, 20)), y_histogram(var_freqs_list))
# ax_histy.bar(list(range(0, 20)), y_histogram(var_freqs_list), orientation='horizontal', color='grey')
y_values_ordered = y_histogram(var_freqs_list).reverse()
ax_histy.barh(list(range(0, 20)), y_histogram(var_freqs_list),
orientation='horizontal', color='grey')


ax_histy.margins(0.00)
for i, v in enumerate(y_histogram(var_freqs_list)):
ax_histy.text(v + 3, i , int(v))
#ax_histy.barh(list(range(0, 20)), y_values_ordered, color='gainsboro')

# ax_histx.set_xlim(ax_heatmap.get_xlim())
# ax_histy.set_ylim(ax_heatmap.get_ylim())
# And now the colorbar
# --------------------------------------------------------
ax_scale = plt.colorbar(im)

plt.tight_layout()
#plt.tight_layout()
filename = f"images/{title}_{date}.png"

for x_coordinate, x_amino_acid in enumerate(aa_order):
Expand Down
Loading

0 comments on commit af03b97

Please sign in to comment.