From aa6f598f879efac9704ff53d095e5413cfa9027f Mon Sep 17 00:00:00 2001 From: flatberg Date: Fri, 21 Apr 2006 08:30:37 +0000 Subject: [PATCH] workflow update --- workflows/pca_workflow.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/workflows/pca_workflow.py b/workflows/pca_workflow.py index 6c6d03d..ff87dcb 100644 --- a/workflows/pca_workflow.py +++ b/workflows/pca_workflow.py @@ -2,7 +2,7 @@ import gtk import logger from workflow import * from scipy import array -from data import read_affy_annot +from data import read_affy_annot,read_mootha,data_dict_to_matrix import plots class PCAWorkflow(Workflow): @@ -12,7 +12,7 @@ class PCAWorkflow(Workflow): self.name = 'PCAs Workflow' load = Stage('load', 'Load Data') - load.add_function(Function('load_mootha', 'Load Microarrays')) + load.add_function(Function('load_mootha', 'Load')) self.add_stage(load) preproc = Stage('preprocess', 'Preprocessing') @@ -103,3 +103,34 @@ class PCAFunction(Function): return [T,P,E,r] +class LoadMoothaData(Function): + def __init__(self): + Function.__init__(self, 'load', 'Load diabetes data') + self.annotations = None + + def load_expression_file(self, filename): + f = open(filename) + logger.log('notice', 'Loading expression file: %s' % filename) + self.file = f + + def on_response(self, dialog, response): + if response == gtk.RESPONSE_OK: + logger.log('notice', 'Reading file: %s' % dialog.get_filename()) + self.load_expression_file(dialog.get_filename()) + + def run(self, data): + btns = ('Open', gtk.RESPONSE_OK, \ + 'Cancel', gtk.RESPONSE_CANCEL) + dialog = gtk.FileChooserDialog('Open Affy Annotation 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) + gene_def = ['genes',gene_ids] + sample_def = ['samples', sample_names] + X = dataset.Dataset(x,[sample_def,gene_def]) # samples x genes + return X