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):
|
def create_navigator_view(self, str1, str2, int1, int2):
|
||||||
tree = self.project.data_tree
|
tree = self.project.data_tree
|
||||||
self.navigator_view = navigator.NavigatorView(tree, self)
|
self.navigator_view = navigator.NavigatorView(self.project, self)
|
||||||
self.navigator_view.show()
|
self.navigator_view.show()
|
||||||
return self.navigator_view
|
return self.navigator_view
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,17 @@ import gtk
|
||||||
import gobject
|
import gobject
|
||||||
import plots
|
import plots
|
||||||
import logger
|
import logger
|
||||||
|
import dataset
|
||||||
|
import project
|
||||||
|
|
||||||
class NavigatorView (gtk.TreeView):
|
class NavigatorView (gtk.TreeView):
|
||||||
def __init__(self, nav, app):
|
def __init__(self, project, app):
|
||||||
gtk.TreeView.__init__(self, nav)
|
self.project = project
|
||||||
self.navigator = nav
|
self.data_tree = project.data_tree
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
|
gtk.TreeView.__init__(self, self.data_tree)
|
||||||
|
|
||||||
self.set_headers_visible(False)
|
self.set_headers_visible(False)
|
||||||
self.connect('row-activated', self.row_activated_handler)
|
self.connect('row-activated', self.row_activated_handler)
|
||||||
|
|
||||||
|
@ -20,8 +24,14 @@ class NavigatorView (gtk.TreeView):
|
||||||
logger.log('debug', 'Initializing naviagor window')
|
logger.log('debug', 'Initializing naviagor window')
|
||||||
|
|
||||||
def row_activated_handler(self, widget, path, column):
|
def row_activated_handler(self, widget, path, column):
|
||||||
|
iter = self.data_tree.get_iter(path)
|
||||||
iter = self.navigator.get_iter(path)
|
obj = self.data_tree.get_value(iter, 2)
|
||||||
object = self.navigator.get_value(iter, 2)
|
if isinstance(obj, plots.Plot):
|
||||||
logger.log('notice', 'Button pressed')
|
logger.log('debug', 'Activating plot')
|
||||||
self.app.change_plot(object)
|
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()
|
object.show()
|
||||||
return object
|
return object
|
||||||
|
|
||||||
|
def set_current_data(self, obj):
|
||||||
|
self.current_data = obj
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import gtk
|
import gtk
|
||||||
import logger
|
import logger
|
||||||
from workflow import *
|
from workflow import *
|
||||||
from scipy import array
|
from scipy import array,zeros
|
||||||
from data import read_affy_annot,read_mootha,data_dict_to_matrix
|
from data import read_affy_annot,read_mootha,data_dict_to_matrix
|
||||||
import plots
|
import plots
|
||||||
|
import dataset
|
||||||
|
|
||||||
class PCAWorkflow(Workflow):
|
class PCAWorkflow(Workflow):
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ class PCAWorkflow(Workflow):
|
||||||
self.name = 'PCAs Workflow'
|
self.name = 'PCAs Workflow'
|
||||||
|
|
||||||
load = Stage('load', 'Load Data')
|
load = Stage('load', 'Load Data')
|
||||||
load.add_function(Function('load_mootha', 'Load'))
|
load.add_function(LoadMoothaData())
|
||||||
self.add_stage(load)
|
self.add_stage(load)
|
||||||
|
|
||||||
preproc = Stage('preprocess', 'Preprocessing')
|
preproc = Stage('preprocess', 'Preprocessing')
|
||||||
|
@ -113,6 +114,7 @@ class LoadMoothaData(Function):
|
||||||
f = open(filename)
|
f = open(filename)
|
||||||
logger.log('notice', 'Loading expression file: %s' % filename)
|
logger.log('notice', 'Loading expression file: %s' % filename)
|
||||||
self.file = f
|
self.file = f
|
||||||
|
self.filename = filename
|
||||||
|
|
||||||
def on_response(self, dialog, response):
|
def on_response(self, dialog, response):
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
|
@ -122,16 +124,23 @@ class LoadMoothaData(Function):
|
||||||
def run(self, data):
|
def run(self, data):
|
||||||
btns = ('Open', gtk.RESPONSE_OK, \
|
btns = ('Open', gtk.RESPONSE_OK, \
|
||||||
'Cancel', gtk.RESPONSE_CANCEL)
|
'Cancel', gtk.RESPONSE_CANCEL)
|
||||||
dialog = gtk.FileChooserDialog('Open Affy Annotation File',
|
dialog = gtk.FileChooserDialog('Open diabetes expression File',
|
||||||
buttons=btns)
|
buttons=btns)
|
||||||
dialog.connect('response', self.on_response)
|
dialog.connect('response', self.on_response)
|
||||||
dialog.run()
|
dialog.run()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
### Reading and parsing here
|
### Reading and parsing here
|
||||||
d,sample_names = read_mootha(self.file)
|
d,sample_names = read_mootha()
|
||||||
x,gene_ids = data_dict_to_matrix(d)
|
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]
|
gene_def = ['genes',gene_ids]
|
||||||
sample_def = ['samples', sample_names]
|
sample_def = ['samples', sample_names]
|
||||||
X = dataset.Dataset(x,[sample_def,gene_def]) # samples x genes
|
X = dataset.Dataset(x,[sample_def,gene_def]) # samples x genes
|
||||||
return X
|
return [X]
|
||||||
|
|
Reference in New Issue