From 0bc4a6e3f05e2a7df19426f90c76130887bf096c Mon Sep 17 00:00:00 2001 From: einarr Date: Mon, 30 Jul 2007 14:15:23 +0000 Subject: [PATCH] Fixed drag'n'drop of datasets to DAG-plots to convert inf/-inf to maximum/minimum values of the dataset. --- workflows/gobrowser.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/workflows/gobrowser.py b/workflows/gobrowser.py index ea1e6af..b300c3a 100644 --- a/workflows/gobrowser.py +++ b/workflows/gobrowser.py @@ -1,6 +1,6 @@ import gtk -from fluents import dataset, logger, plots, workflow, fluents, project +from fluents import dataset, logger, plots, workflow, fluents, project, view import geneontology from matplotlib.nxutils import points_inside_poly import matplotlib @@ -547,12 +547,13 @@ class VolcanoPlot(plots.ScatterPlot): name="Volcano plot", sel_dim_2='_p', **kw) - + class DagPlot(plots.Plot): def __init__(self, graph, dim='go-terms', pos=None, nodecolor='b', nodesize=40, with_labels=False, name='DAG Plot'): plots.Plot.__init__(self, name) + self._add_ic_spin_button() self.nodes = graph.nodes() self.graph = graph self._pos = pos @@ -617,6 +618,25 @@ class DagPlot(plots.Plot): self.axes.set_frame_on(False) self.fig.subplots_adjust(left=0, right=1, bottom=0, top=1) + def _add_ic_spin_button(self): + sb = gtk.SpinButton() + sb.set_range(0, 100) + sb.set_value(1) + sb.set_increments(1, 3) + label = gtk.Label("IC > ") + hbox = gtk.HBox() + hbox.pack_start(label) + hbox.pack_start(sb) + ti = gtk.ToolItem() + ti.set_expand(False) + ti.add(hbox) + sb.show() + label.show() + hbox.show() + ti.show() + self._toolbar.insert(ti, -1) + ti.set_tooltip(self._toolbar.tooltips, "Set information content threshold") + def _calc_pos(self, graph): """Calculates position for graph nodes.""" gv_graph = networkx.DiGraph() @@ -704,7 +724,13 @@ class DagPlot(plots.Plot): indices = ds.get_indices(self.current_dim, self.nodes) nodes = ds.existing_identifiers(self.current_dim, self.nodes) + v = vec.take(indices, 0) + vec_min = min(v[v > -inf]) + vec_max = max(v[v < inf]) + v[v==inf] = vec_max + v[v==-inf] = vec_min + d = dict(zip(nodes, list(v))) map_vec = zeros(len(self.nodes))