From 553bfbe1ae454ffbd04a26571dec2e54f006a1a6 Mon Sep 17 00:00:00 2001 From: tangstad Date: Sat, 22 Apr 2006 17:59:15 +0000 Subject: [PATCH] Big cleanup of affymatrix importer. Now use E@exprs to get matrix from loaded data. Also made row and colname import better by ensuring vector-handling, ensuring that getting single column/row data works without being converted into a single string instead of string in a list. Removed ;1-hack and use NO_CONVERSION to ensure no extra computation is done when calculating r stuff. Now AffyMatrix data is named as such. --- workflows/go_workflow.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/workflows/go_workflow.py b/workflows/go_workflow.py index 3a08151..a93040d 100644 --- a/workflows/go_workflow.py +++ b/workflows/go_workflow.py @@ -186,19 +186,25 @@ class CelFileImportFunction(Function): chooser.add_filter(cel_filter) chooser.add_filter(all_filter) - if chooser.run() == gtk.RESPONSE_OK: - logger.log('debug', "Selected files: %s" % ", ".join(chooser.get_filenames())) - rpy.r.library("affy") - # hack: we append ";1" to make sure no r-object is returned to python (faster) - rpy.r('At.aBatch <- ReadAffy(filenames=c("%s"));1' % '", "'.join(chooser.get_filenames())) - # we destroy it immediately to keep it from being on - # screen while we do something with the files - chooser.destroy() - # also here we append ";1" - rpy.r('At.eSet <- expresso(At.aBatch, bg.correct=F, summary.method="liwong", pmcorrect.method="pmonly", normalize.method="qspline");1') - m = rpy.r('At.m <- exprs(At.eSet)') - rownames = rpy.r('rownames(At.m)') - colnames = rpy.r('colnames(At.m)') - return [dataset.Dataset(m, (('ids', rownames), ('filename', colnames)))] - else: + try: + if chooser.run() == gtk.RESPONSE_OK: + rpy.r.library("affy") + + silent_eval = rpy.with_mode(rpy.NO_CONVERSION, rpy.r) + silent_eval('E <- ReadAffy(filenames=c("%s"))' % '", "'.join(chooser.get_filenames())) + + m = rpy.r('m <- E@exprs') + + vector_eval = rpy.with_mode(rpy.VECTOR_CONVERSION, rpy.r) + rownames = vector_eval('rownames(m)') + colnames = vector_eval('colnames(m)') + + # We should be nice and clean up after ourselves + rpy.r.rm(["E", "m"]) + + if m: + return [dataset.Dataset(m, (('ids', rownames), ('filename', colnames)), "AffyMatrix Data")] + else: + logger.log("notice", "No data loaded from importer.") + finally: chooser.destroy()