Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

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.
This commit is contained in:
Truls Alexander Tangstad 2006-04-22 17:59:15 +00:00
parent d26dd54f5b
commit 553bfbe1ae
1 changed files with 21 additions and 15 deletions

View File

@ -186,19 +186,25 @@ class CelFileImportFunction(Function):
chooser.add_filter(cel_filter)
chooser.add_filter(all_filter)
try:
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)))]
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()