Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Workflow updates

This commit is contained in:
Arnar Flatberg 2008-02-29 16:23:57 +00:00
parent 1ad8b1a4f1
commit b313cf29bc
1 changed files with 70 additions and 31 deletions

View File

@ -445,21 +445,23 @@ class SubgraphQuery(workflow.Function):
# 2.) Pairwise goodness in loading space # 2.) Pairwise goodness in loading space
indices = self._pairsim(Dw) indices = self._pairsim(Dw)
print indices
print indices.shape
idents1 = Dw.get_identifiers(self._dim, indices[:,0]) idents1 = Dw.get_identifiers(self._dim, indices[:,0])
idents2 = Dw.get_identifiers(self._dim, indices[:,1]) idents2 = Dw.get_identifiers(self._dim, indices[:,1])
idents = zip(idents1, idents2) idents = zip(idents1, idents2)
# 3.) Identify close subgraphs # 3.) Identify close subgraphs
G = DA.asnetworkx()
for edge in G.edges():
if edge not in idents:
G.delete_edge(edge)
S = nx.connected_component_subgraphs(G)
print map(len, S)
# 4.) Rank subgraphs # 4.) Rank subgraphs
main.project.set_selection('gene_ids', idents1) main.project.set_selection('gene_ids', idents1)
#main.project.set_sele #main.project.set_sele
logger.log("notice", "Gene ids updated") logger.log("notice", "Gene ids updated")
#plt = GraphQueryScatterPlot(SS, Dw) plt = GraphQueryScatterPlot(S, Dw)
#return [plt] #return [plt]
def _pairsim(self, Dw, ptype='cosine',cut_rat=.2): def _pairsim(self, Dw, ptype='cosine',cut_rat=.2):
@ -505,38 +507,75 @@ class SubgraphQuery(workflow.Function):
pass pass
class GraphQueryScatterPlot(plots.ScatterPlot): class GraphQueryScatterPlot(plots.ScatterPlot):
def __init__(self, S, Dw, *args, **kw): def __init__(self, subgraphs, Dw, *args, **kw):
self.S = S self._subgraphs = subgraphs
self.Dw = Dw self._nx_nodes = []
self._nx_edges = []
self._init_scatter(Dw)
self.overlay_subgraphs()
def _init_scatter(self, Dw):
self._Dw = Dw
id_dim, sel_dim = Dw.get_dim_name() id_dim, sel_dim = Dw.get_dim_name()
self._dim = id_dim self._dim = id_dim
id_1, = Dw.get_identifiers(sel_dim, [0]) id_1, = Dw.get_identifiers(sel_dim, [0])
id_2, = Dw.get_identifiers(sel_dim, [1]) id_2, = Dw.get_identifiers(sel_dim, [1])
print id_1 plots.ScatterPlot.__init__(self, Dw, Dw, id_dim, sel_dim, id_1, id_2, c='g', s=50,name="Hypo", alpha=.5)
print id_2
plots.ScatterPlot.__init__(self, Dw, Dw, id_dim, sel_dim, id_1, id_2, c='g', s=50,name="Kegg test", alpha=.5)
self.overlay_subgraphs()
def overlay_subgraphs(self): def overlay_subgraphs(self):
for subgraph in self.S: all_nodes = self._Dw.get_identifiers(self._dim, sorted=True)
for subgraph in self._subgraphs:
# get xy positions from
nodes = subgraph.nodes() nodes = subgraph.nodes()
print self._dim for i, node in enumerate(all_nodes):
pos[node] = (self.xaxis_data[i], self.yaxis_data[i])
nn = nx.draw_networkx_nodes(subgraph, pos, node_size=200, ax=self.axes, zorder=10)
ee = nx.draw_networkx_edges(subgraph, pos, ax=self.axes, zorder=9)
self._nx_nodes.append(nn)
self._nx_edges.append(ee)
sub_dw = self.Dw.subdata(self._dim, nodes) def _delete_networks(self):
nodes = sub_dw.get_identifiers(self._dim, sorted=True) if len(self._nx_nodes) > 0:
xy = sub_dw.asarray()[:,:2] for n in self._nx_nodes:
pos = {} self._nx_nodes.remove(n)
for i, node in enumerate(nodes): self.axes.collections.remove(n)
pos[node] = xy[i] if len(self._nx_edges) > 0:
nx.draw_networkx_nodes(subgraph, pos, node_size=200, ax=self.axes, zorder=3) for e in self._nx_edges:
nx.draw_networkx_edges(subgraph, pos, ax=self.axes, zorder=3) self._nx_edges.remove(e)
self.axes.collections.remove(e)
def set_ordinate(self, sb):
self._delete_networks()
self.overlay_subgraphs()
plots.ScatterPlot.set_ordinate(self, sb)
def set_absicca(self, sb):
self._delete_networks()
self.overlay_subgraphs()
plots.ScatterPlot.set_absicca(self, sb)
class CAsinglesel(workflow.Function):
""" Modified non-symmetric correpsondence analysis.
def on_update(self, selection, graph): Setup multiple selections:
g = nx.subgraph(graph, selection)
S = nx.connected_components_subgraphs(g)
def _subgraph_score(self, subgraph): Input : - a subset(s) along a dimension (selection) of `interesting` identifiers.
- Predefined subsets (categories) along the same dimension.
1.) The cooccurence matrix of interesting identifers and categories is made.
2.) The variables are scaled to represent the relative frequencies.
"""
def run(X, Ckegg):
pass pass
class CASingleSelDouble(workflow.Function):
"""
"""
def run(X, Ckegg):
pass