current datset selection fix
This commit is contained in:
parent
7851048fb6
commit
fc4e62f799
2
fluent
2
fluent
|
@ -77,7 +77,7 @@ class FluentApp:
|
|||
|
||||
def create_navigator_view(self, str1, str2, int1, int2):
|
||||
tree = self.project.data_tree
|
||||
self.navigator_view = navigator.NavigatorView(tree, self)
|
||||
self.navigator_view = navigator.NavigatorView(self.project, self)
|
||||
self.navigator_view.show()
|
||||
return self.navigator_view
|
||||
|
||||
|
|
|
@ -3,12 +3,16 @@ import gtk
|
|||
import gobject
|
||||
import plots
|
||||
import logger
|
||||
import dataset
|
||||
import project
|
||||
|
||||
class NavigatorView (gtk.TreeView):
|
||||
def __init__(self, nav, app):
|
||||
gtk.TreeView.__init__(self, nav)
|
||||
self.navigator = nav
|
||||
def __init__(self, project, app):
|
||||
self.project = project
|
||||
self.data_tree = project.data_tree
|
||||
self.app = app
|
||||
|
||||
gtk.TreeView.__init__(self, self.data_tree)
|
||||
|
||||
self.set_headers_visible(False)
|
||||
self.connect('row-activated', self.row_activated_handler)
|
||||
|
@ -20,8 +24,14 @@ class NavigatorView (gtk.TreeView):
|
|||
logger.log('debug', 'Initializing naviagor window')
|
||||
|
||||
def row_activated_handler(self, widget, path, column):
|
||||
|
||||
iter = self.navigator.get_iter(path)
|
||||
object = self.navigator.get_value(iter, 2)
|
||||
logger.log('notice', 'Button pressed')
|
||||
self.app.change_plot(object)
|
||||
iter = self.data_tree.get_iter(path)
|
||||
obj = self.data_tree.get_value(iter, 2)
|
||||
if isinstance(obj, plots.Plot):
|
||||
logger.log('debug', 'Activating plot')
|
||||
self.app.change_plot(obj)
|
||||
elif isinstance(obj, dataset.Dataset):
|
||||
logger.log('debug', 'Selecting dataset')
|
||||
self.project.set_current_data(obj)
|
||||
else:
|
||||
t = type(obj)
|
||||
logger.log('debug', 'Datatype was %s. Don\'t know what to do.' % t)
|
||||
|
|
|
@ -87,3 +87,5 @@ class Project:
|
|||
object.show()
|
||||
return object
|
||||
|
||||
def set_current_data(self, obj):
|
||||
self.current_data = obj
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import gtk
|
||||
import logger
|
||||
from workflow import *
|
||||
from scipy import array
|
||||
from scipy import array,zeros
|
||||
from data import read_affy_annot,read_mootha,data_dict_to_matrix
|
||||
import plots
|
||||
import dataset
|
||||
|
||||
class PCAWorkflow(Workflow):
|
||||
|
||||
|
@ -12,7 +13,7 @@ class PCAWorkflow(Workflow):
|
|||
self.name = 'PCAs Workflow'
|
||||
|
||||
load = Stage('load', 'Load Data')
|
||||
load.add_function(Function('load_mootha', 'Load'))
|
||||
load.add_function(LoadMoothaData())
|
||||
self.add_stage(load)
|
||||
|
||||
preproc = Stage('preprocess', 'Preprocessing')
|
||||
|
@ -113,6 +114,7 @@ class LoadMoothaData(Function):
|
|||
f = open(filename)
|
||||
logger.log('notice', 'Loading expression file: %s' % filename)
|
||||
self.file = f
|
||||
self.filename = filename
|
||||
|
||||
def on_response(self, dialog, response):
|
||||
if response == gtk.RESPONSE_OK:
|
||||
|
@ -122,16 +124,23 @@ class LoadMoothaData(Function):
|
|||
def run(self, data):
|
||||
btns = ('Open', gtk.RESPONSE_OK, \
|
||||
'Cancel', gtk.RESPONSE_CANCEL)
|
||||
dialog = gtk.FileChooserDialog('Open Affy Annotation File',
|
||||
dialog = gtk.FileChooserDialog('Open diabetes expression File',
|
||||
buttons=btns)
|
||||
dialog.connect('response', self.on_response)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
|
||||
### Reading and parsing here
|
||||
d,sample_names = read_mootha(self.file)
|
||||
x,gene_ids = data_dict_to_matrix(d)
|
||||
d,sample_names = read_mootha()
|
||||
n_samps = len(sample_names)
|
||||
n_genes = len(d.keys())
|
||||
typecode = 'f'
|
||||
x = zeros((n_samps,n_genes),typecode)
|
||||
gene_ids = []
|
||||
for i,(id,desc) in enumerate(d.items()):
|
||||
gene_ids.append(id)
|
||||
x[:,i] = desc[0].astype(typecode)
|
||||
gene_def = ['genes',gene_ids]
|
||||
sample_def = ['samples', sample_names]
|
||||
X = dataset.Dataset(x,[sample_def,gene_def]) # samples x genes
|
||||
return X
|
||||
return [X]
|
||||
|
|
Reference in New Issue