Workflow updates
This commit is contained in:
parent
1ad8b1a4f1
commit
b313cf29bc
|
@ -445,21 +445,23 @@ class SubgraphQuery(workflow.Function):
|
|||
|
||||
# 2.) Pairwise goodness in loading space
|
||||
indices = self._pairsim(Dw)
|
||||
print indices
|
||||
print indices.shape
|
||||
|
||||
idents1 = Dw.get_identifiers(self._dim, indices[:,0])
|
||||
idents2 = Dw.get_identifiers(self._dim, indices[:,1])
|
||||
idents = zip(idents1, idents2)
|
||||
|
||||
# 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
|
||||
|
||||
main.project.set_selection('gene_ids', idents1)
|
||||
#main.project.set_sele
|
||||
logger.log("notice", "Gene ids updated")
|
||||
#plt = GraphQueryScatterPlot(SS, Dw)
|
||||
plt = GraphQueryScatterPlot(S, Dw)
|
||||
#return [plt]
|
||||
|
||||
def _pairsim(self, Dw, ptype='cosine',cut_rat=.2):
|
||||
|
@ -505,38 +507,75 @@ class SubgraphQuery(workflow.Function):
|
|||
pass
|
||||
|
||||
class GraphQueryScatterPlot(plots.ScatterPlot):
|
||||
def __init__(self, S, Dw, *args, **kw):
|
||||
self.S = S
|
||||
self.Dw = Dw
|
||||
def __init__(self, subgraphs, Dw, *args, **kw):
|
||||
self._subgraphs = subgraphs
|
||||
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()
|
||||
self._dim = id_dim
|
||||
id_1, = Dw.get_identifiers(sel_dim, [0])
|
||||
id_2, = Dw.get_identifiers(sel_dim, [1])
|
||||
print id_1
|
||||
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()
|
||||
plots.ScatterPlot.__init__(self, Dw, Dw, id_dim, sel_dim, id_1, id_2, c='g', s=50,name="Hypo", alpha=.5)
|
||||
|
||||
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()
|
||||
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)
|
||||
nodes = sub_dw.get_identifiers(self._dim, sorted=True)
|
||||
xy = sub_dw.asarray()[:,:2]
|
||||
pos = {}
|
||||
for i, node in enumerate(nodes):
|
||||
pos[node] = xy[i]
|
||||
nx.draw_networkx_nodes(subgraph, pos, node_size=200, ax=self.axes, zorder=3)
|
||||
nx.draw_networkx_edges(subgraph, pos, ax=self.axes, zorder=3)
|
||||
def _delete_networks(self):
|
||||
if len(self._nx_nodes) > 0:
|
||||
for n in self._nx_nodes:
|
||||
self._nx_nodes.remove(n)
|
||||
self.axes.collections.remove(n)
|
||||
if len(self._nx_edges) > 0:
|
||||
for e in self._nx_edges:
|
||||
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):
|
||||
g = nx.subgraph(graph, selection)
|
||||
S = nx.connected_components_subgraphs(g)
|
||||
Setup multiple selections:
|
||||
|
||||
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
|
||||
|
||||
|
||||
class CASingleSelDouble(workflow.Function):
|
||||
"""
|
||||
"""
|
||||
|
||||
def run(X, Ckegg):
|
||||
pass
|
||||
|
||||
|
|
Reference in New Issue