Started on a function to enhance gene lists by using GO similarities.
Not in a usable state.
This commit is contained in:
parent
68cc583d2c
commit
e5cd8a8077
|
@ -222,3 +222,125 @@ class LoadGOFunction(workflow.Function):
|
||||||
label.set_use_underline(True)
|
label.set_use_underline(True)
|
||||||
fluents.app['bottom_notebook'].append_page(browser, label)
|
fluents.app['bottom_notebook'].append_page(browser, label)
|
||||||
|
|
||||||
|
class LoadAnnotationsFunction(workflow.Function):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
workflow.Function.__init__(self, 'load-go-ann', 'Load Annotations')
|
||||||
|
self.annotations = None
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
global evidence
|
||||||
|
f = open(GO_DATA_DIR + '/goa-condensed')
|
||||||
|
ev_codes = f.readline().split()
|
||||||
|
go_terms = []
|
||||||
|
|
||||||
|
lines = f.readlines()
|
||||||
|
m = zeros((len(lines), len(ev_codes)))
|
||||||
|
|
||||||
|
for i, l in enumerate(lines):
|
||||||
|
values = l.split()
|
||||||
|
go_terms.append(values[0])
|
||||||
|
for j, v in enumerate(values[1:]):
|
||||||
|
m[i,j] = float(v.strip())
|
||||||
|
|
||||||
|
d = dataset.Dataset(m,
|
||||||
|
[['go-terms', go_terms], ['evidence', ev_codes]],
|
||||||
|
name='GO evidence')
|
||||||
|
|
||||||
|
evidence = d
|
||||||
|
return [d]
|
||||||
|
|
||||||
|
|
||||||
|
class GOWeightDialog(gtk.Dialog):
|
||||||
|
def __init__(self):
|
||||||
|
gtk.Dialog.__init__(self, 'GO Gene List Influence',
|
||||||
|
None,
|
||||||
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
|
(gtk.STOCK_OK, gtk.RESPONSE_OK,
|
||||||
|
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
|
||||||
|
|
||||||
|
table = gtk.Table(2, 2)
|
||||||
|
|
||||||
|
sim_lbl = gtk.Label('Similarity threshold: ')
|
||||||
|
table.attach(sim_lbl, 0, 1, 0, 1)
|
||||||
|
adjustment = gtk.Adjustment(0, 0, 10, 0.1, 1.0, 1.0)
|
||||||
|
sim_spin = gtk.SpinButton(adjustment, 0.0, 2)
|
||||||
|
table.attach(sim_spin, 1, 2, 0, 1)
|
||||||
|
|
||||||
|
rank_lbl = gtk.Label('Rank threshold: ')
|
||||||
|
table.attach(rank_lbl, 0, 1, 1, 2)
|
||||||
|
rank_adj = gtk.Adjustment(0, 0, 10, 0.1, 1.0, 1.0)
|
||||||
|
rank_spin = gtk.SpinButton(rank_adj, 0.0, 2)
|
||||||
|
table.attach(rank_spin, 1, 2, 1, 2)
|
||||||
|
|
||||||
|
sim_lbl.show()
|
||||||
|
sim_spin.show()
|
||||||
|
rank_lbl.show()
|
||||||
|
rank_spin.show()
|
||||||
|
|
||||||
|
table.show()
|
||||||
|
self.vbox.add(table)
|
||||||
|
self._sim_spin = sim_spin
|
||||||
|
self._rank_spin = rank_spin
|
||||||
|
|
||||||
|
def set_options(self, options):
|
||||||
|
self._sim_spin.set_value(options['similarity_threshold'])
|
||||||
|
self._rank_spin.set_value(options['rank_threshold'])
|
||||||
|
|
||||||
|
def set_editable(self, editable):
|
||||||
|
self._sim_spin.set_sensitive(editable)
|
||||||
|
self._rank_spin.set_sensitive(editable)
|
||||||
|
|
||||||
|
def update_options(self, options):
|
||||||
|
options['similarity_threshold'] = self._sim_spin.get_value()
|
||||||
|
options['rank_threshold'] = self._rank_spin.get_value()
|
||||||
|
|
||||||
|
|
||||||
|
class GOWeightFunction(workflow.Function):
|
||||||
|
def __init__(self):
|
||||||
|
workflow.Function.__init__(self, 'load-go-ann', 'GO Influence')
|
||||||
|
self.options = GOWeightOptions()
|
||||||
|
|
||||||
|
def run(self, genelist, similarity):
|
||||||
|
## Show dialog box
|
||||||
|
self.show_gui(self.options)
|
||||||
|
|
||||||
|
## assure that data is "correct", i.e., that we can perform
|
||||||
|
## the desired operations.
|
||||||
|
common_dims = genelist.common_dims(similarity)
|
||||||
|
if len(common_dims) == 0:
|
||||||
|
logger.log('error', 'No common dimension in the selected datasets.')
|
||||||
|
elif len(common_dims) > 1:
|
||||||
|
logger.log('error', "More than one common dimension in the " +
|
||||||
|
"selected datasets. Don't know what to do.")
|
||||||
|
gene_dim = common_dims[0]
|
||||||
|
logger.log('debug', 'Assuming genes are in dimension: %s' % gene_dim)
|
||||||
|
|
||||||
|
## Do the calculations.
|
||||||
|
d = {}
|
||||||
|
|
||||||
|
|
||||||
|
def show_gui(self, options, edit=True):
|
||||||
|
dialog = GOWeightDialog()
|
||||||
|
dialog.set_options(self.options)
|
||||||
|
dialog.show_all()
|
||||||
|
dialog.set_editable(edit)
|
||||||
|
response = dialog.run()
|
||||||
|
dialog.hide()
|
||||||
|
if response == gtk.RESPONSE_OK:
|
||||||
|
return dialog.update_options(self.options)
|
||||||
|
else:
|
||||||
|
return options
|
||||||
|
|
||||||
|
|
||||||
|
class Options(dict):
|
||||||
|
def __init__(self):
|
||||||
|
dict.__init__(self)
|
||||||
|
|
||||||
|
|
||||||
|
class GOWeightOptions(Options):
|
||||||
|
def __init__(self):
|
||||||
|
Options.__init__(self)
|
||||||
|
self['similarity_threshold'] = 0.0
|
||||||
|
self['rank_threshold'] = 0.0
|
||||||
|
|
||||||
|
|
Reference in New Issue