From f07ce85e46efa6890408326b833bbcca7795fcc3 Mon Sep 17 00:00:00 2001 From: einarr Date: Fri, 6 Feb 2009 22:21:51 +0000 Subject: [PATCH] Changes to DAG plot. --- workflows/gobrowser.py | 21 ++++++++++++--------- workflows/smokers.py | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/workflows/gobrowser.py b/workflows/gobrowser.py index 6624398..243d4d4 100644 --- a/workflows/gobrowser.py +++ b/workflows/gobrowser.py @@ -483,8 +483,9 @@ class SetICFunction(workflow.Function): return class PlotDagFunction(workflow.Function): - def __init__(self): + def __init__(self, subtree="bp"): workflow.Function.__init__(self, 'go-dag', 'Build DAG') + self.subtree = subtree def run(self, selection): g = self.get_network(list(selection['go-terms'])) @@ -493,7 +494,7 @@ class PlotDagFunction(workflow.Function): name="DAG") return [ThresholdDagPlot(g)] - def get_network(self, terms, subtree='bp'): + def get_network(self, terms): """Returns a DAG connecting the given terms by including their parents up to the level needed to connect them. The subtree parameter is one of mf - molecular function @@ -502,6 +503,7 @@ class PlotDagFunction(workflow.Function): rpy.r.library("GOstats") + subtree = self.subtree if subtree == 'mf': subtree_r = rpy.r.GOMFPARENTS elif subtree == 'bp': @@ -573,6 +575,7 @@ class DagPlot(plots.Plot): self._nodecolor = nodecolor self._with_labels = with_labels self.visible = set() + self.labels = {} self.current_dim = dim @@ -753,15 +756,15 @@ class ThresholdDagPlot(DagPlot, plots.PlotThresholder): with_labels=False, name='DAG Plot'): DagPlot.__init__(self, graph, dim='go-terms', pos=None, nodecolor='b', nodesize=40, - with_labels=False, name='DAG Plot') + with_labels=True, name='DAG Plot') plots.PlotThresholder.__init__(self, "IC") - def rectangle_select_callback(self, x1, y1, x2, y2, key): - ids = self.points_in_rect(x1, y1, x2, y2, key) - ids = self.visible.intersection(ids) - ids = self.update_selection(ids, key) - - self.selection_listener(self.current_dim, ids) +# def rectangle_select_callback(self, x1, y1, x2, y2, key): +# ids = self.points_in_rect(x1, y1, x2, y2, key) +# ids = self.visible.intersection(ids) +# ids = self.update_selection(ids, key) +# +# self.selection_listener(self.current_dim, ids) def _update_color_from_dataset(self, ds): DagPlot._update_color_from_dataset(self, ds) diff --git a/workflows/smokers.py b/workflows/smokers.py index c3b5ae0..463e174 100644 --- a/workflows/smokers.py +++ b/workflows/smokers.py @@ -66,6 +66,8 @@ class SmallTestWorkflow(workflow.Workflow): # go.add_function(gobrowser.DistanceToSelectionFunction()) # go.add_function(gobrowser.TTestFunction()) go.add_function(gobrowser.PlotDagFunction()) + go.add_function(gobrowser.PlotDagFunction("cc")) + go.add_function(gobrowser.PlotDagFunction("mf")) go.add_function(GoEnrichment()) go.add_function(GoEnrichmentCond()) go.add_function(MapGO2Gene())