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:
parent
d26dd54f5b
commit
553bfbe1ae
|
@ -186,19 +186,25 @@ class CelFileImportFunction(Function):
|
||||||
chooser.add_filter(cel_filter)
|
chooser.add_filter(cel_filter)
|
||||||
chooser.add_filter(all_filter)
|
chooser.add_filter(all_filter)
|
||||||
|
|
||||||
|
try:
|
||||||
if chooser.run() == gtk.RESPONSE_OK:
|
if chooser.run() == gtk.RESPONSE_OK:
|
||||||
logger.log('debug', "Selected files: %s" % ", ".join(chooser.get_filenames()))
|
|
||||||
rpy.r.library("affy")
|
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()))
|
silent_eval = rpy.with_mode(rpy.NO_CONVERSION, rpy.r)
|
||||||
# we destroy it immediately to keep it from being on
|
silent_eval('E <- ReadAffy(filenames=c("%s"))' % '", "'.join(chooser.get_filenames()))
|
||||||
# screen while we do something with the files
|
|
||||||
chooser.destroy()
|
m = rpy.r('m <- E@exprs')
|
||||||
# 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')
|
vector_eval = rpy.with_mode(rpy.VECTOR_CONVERSION, rpy.r)
|
||||||
m = rpy.r('At.m <- exprs(At.eSet)')
|
rownames = vector_eval('rownames(m)')
|
||||||
rownames = rpy.r('rownames(At.m)')
|
colnames = vector_eval('colnames(m)')
|
||||||
colnames = rpy.r('colnames(At.m)')
|
|
||||||
return [dataset.Dataset(m, (('ids', rownames), ('filename', colnames)))]
|
# 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:
|
else:
|
||||||
|
logger.log("notice", "No data loaded from importer.")
|
||||||
|
finally:
|
||||||
chooser.destroy()
|
chooser.destroy()
|
||||||
|
|
Reference in New Issue