Added support for affy cel files.
This commit is contained in:
parent
c601ad3966
commit
23914b2d1e
|
@ -6,6 +6,7 @@ import plots
|
||||||
import dataset
|
import dataset
|
||||||
#import geneontology
|
#import geneontology
|
||||||
#import gostat
|
#import gostat
|
||||||
|
import rpy
|
||||||
from scipy import array,randn
|
from scipy import array,randn
|
||||||
|
|
||||||
class EinarsWorkflow (Workflow):
|
class EinarsWorkflow (Workflow):
|
||||||
|
@ -16,6 +17,7 @@ class EinarsWorkflow (Workflow):
|
||||||
|
|
||||||
load = Stage('load', 'Load Data')
|
load = Stage('load', 'Load Data')
|
||||||
load.add_function(Function('load', 'Load Microarrays'))
|
load.add_function(Function('load', 'Load Microarrays'))
|
||||||
|
load.add_function(CelFileImportFunction())
|
||||||
load.add_function(TestDataFunction())
|
load.add_function(TestDataFunction())
|
||||||
self.add_stage(load)
|
self.add_stage(load)
|
||||||
|
|
||||||
|
@ -98,3 +100,40 @@ class TestDataFunction(Function):
|
||||||
axis_1 = ['cols',[]]
|
axis_1 = ['cols',[]]
|
||||||
X = dataset.Dataset(x,[axis_0,axis_1])
|
X = dataset.Dataset(x,[axis_0,axis_1])
|
||||||
return [X, plots.SinePlot(None)]
|
return [X, plots.SinePlot(None)]
|
||||||
|
|
||||||
|
|
||||||
|
class CelFileImportFunction(Function):
|
||||||
|
def __init__(self):
|
||||||
|
Function.__init__(self, 'cel_import', 'Import Affy')
|
||||||
|
|
||||||
|
def run(self, data):
|
||||||
|
chooser = gtk.FileChooserDialog(title="Select cel files...", parent=None,
|
||||||
|
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
|
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||||
|
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
||||||
|
chooser.set_select_multiple(True)
|
||||||
|
cel_filter = gtk.FileFilter()
|
||||||
|
cel_filter.set_name("Cel Files (*.cel)")
|
||||||
|
cel_filter.add_pattern("*.[cC][eE][lL]")
|
||||||
|
all_filter = gtk.FileFilter()
|
||||||
|
all_filter.set_name("All Files (*.*)")
|
||||||
|
all_filter.add_pattern("*")
|
||||||
|
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:
|
||||||
|
chooser.destroy()
|
||||||
|
|
Reference in New Issue