Skip to content

Commit

Permalink
Preparation for submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik R Laetsch committed Jul 3, 2017
1 parent 65d2e37 commit d6c7fc4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
22 changes: 12 additions & 10 deletions scripts/plot_cluster_size_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def yield_counts_by_proteome_count(self, count_type):
self.proteome_counts_by_colour[colour].append(proteome_count)
if count_type == "absolute":
y = [self.counts_by_cluster_size_by_proteome_counts[proteome_count][cluster_size] + y_b for cluster_size, y_b in zip(sorted(self.counts_by_cluster_size_by_proteome_counts[proteome_count]), y_bottom)]
#filled = self.interpolate_gaps(y, 1)
yield proteome_count, x, y, y_bottom, colour
#y_bottom = [_y if _y >= 1 else 0.01 for _y in y]
y_bottom = y
elif count_type == "relative":
y = [self.counts_by_cluster_size_by_proteome_counts[proteome_count][cluster_size] for cluster_size in sorted(self.counts_by_cluster_size_by_proteome_counts[proteome_count])]
Expand All @@ -131,10 +133,10 @@ def plot_cluster_sizes(self, plot_type):
print "[+] Plotting \"%s\" ..." % (plot_type)
if plot_type in PLOTS:
if plot_type == "loglog" or plot_type == "loglin" or plot_type == "loglogpowerlaw":
ax.set_yscale('log')
for proteome_count, x, y, y_bottom, colour in self.yield_counts_by_proteome_count('absolute'):
ax.plot(x, y, c='None')
ax.fill_between(x, y, y_bottom, facecolor=colour)
mask = np.where(y >= 1, y, "nan")
ax.fill_between(x, y, y_bottom, facecolor=colour, interpolate = True, where = mask)
progress(proteome_count, 1, self.proteome_count_max)
ax.plot
elif plot_type == "logbar":
Expand Down Expand Up @@ -185,9 +187,9 @@ def plot_cluster_sizes(self, plot_type):
else:
out_f = "%s.loglogpowerlaw.%s" % (self.out_prefix, self.plot_fmt)
#ax.legend()
plt.gca().set_ylim(bottom=0.8, top=self.cluster_count_max * 2)
plt.gca().set_ylim(bottom=0.9, top=self.cluster_count_max * 2)
plt.gca().set_xlim(left=0.8, right=self.cluster_size_max * 2)
ax.set_yscale('log')
ax.set_yscale('symlog', linthreshy=1.0)
ax.set_xscale('log')
legend_handles = []
for colour, proteomes in self.proteome_counts_by_colour.items():
Expand All @@ -197,7 +199,7 @@ def plot_cluster_sizes(self, plot_type):
legend_handles.append(mpatches.Patch(label="%s" % (proteomes[0]), color=colour))
legend = ax.legend(handles=legend_handles, ncol=2, loc='best', numpoints=1, frameon=True, title="Number of proteomes in cluster")
legend.get_frame().set_facecolor('white')
plt.margins(0.8)
plt.margins(1)
ax.xaxis.set_major_formatter(FormatStrFormatter('%.0f'))
ax.yaxis.set_major_formatter(FormatStrFormatter('%.0f'))
ax.grid(True, linewidth=0.5, which="minor", color="lightgrey")
Expand Down Expand Up @@ -227,9 +229,9 @@ def plot_cluster_sizes(self, plot_type):
print "[+] Start ..."
dataObj = DataObj(out_prefix, plot_fmt, cmap, xlim)
dataObj.parse_data(input_f)
dataObj.plot_cluster_sizes('loglog')
dataObj.plot_cluster_sizes('loglin')
dataObj.plot_cluster_sizes('logbar')
dataObj.plot_cluster_sizes('barperc')
dataObj.plot_cluster_sizes('powerlaw')
#dataObj.plot_cluster_sizes('loglog')
#dataObj.plot_cluster_sizes('loglin')
#dataObj.plot_cluster_sizes('logbar')
#dataObj.plot_cluster_sizes('barperc')
#dataObj.plot_cluster_sizes('powerlaw')
dataObj.plot_cluster_sizes('loglogpowerlaw')
10 changes: 5 additions & 5 deletions src/kinfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def get_header_line(self, filetype, attribute):
cluster_1to1s_ALO_header = []
cluster_1to1s_ALO_header.append("#cluster_id")
cluster_1to1s_ALO_header.append("cluster_type")
cluster_1to1s_ALO_header.append("cardinality")
cluster_1to1s_ALO_header.append("1to1_type")
cluster_1to1s_ALO_header.append("proteome_count")
cluster_1to1s_ALO_header.append("percentage_at_target_count")
return "\t".join(cluster_1to1s_ALO_header)
Expand Down Expand Up @@ -1555,10 +1555,10 @@ def write_tree(self):
node_stats_f = join(dataFactory.dirs['tree'], "tree.node_metrics.txt")
node_stats_header = []
node_stats_header.append('#nodeID')
node_stats_header.append('taxon_specific_apomorphies_[singletons]')
node_stats_header.append('taxon_specific_apomorphies (non-singletons)')
node_stats_header.append('taxon_specific_apomorphies_singletons')
node_stats_header.append('taxon_specific_apomorphies_non_singletons')
node_stats_header.append('node_specific_synapomorphies_total')
node_stats_header.append('node_specific_synapomorphies_all')
node_stats_header.append('node_specific_synapomorphies_complete_presence')
node_stats_header.append('node_specific_synapomorphies_partial_absence')
node_stats_header.append('proteome_count')
node_stats = []
Expand Down Expand Up @@ -2282,7 +2282,7 @@ def welcome_screen():


if __name__ == "__main__":
__version__ = "0.9"
__version__ = "1.0"
welcome_screen()
args = docopt(__doc__)
inputObj = InputObj(args)
Expand Down

0 comments on commit d6c7fc4

Please sign in to comment.