Commits

Marko Toplak committed 0b67816

obiGsea.takeClasses: now builds a class value with get_value_from.

Comments (0)

Files changed (2)

_bioinformatics/obiGeneSetSig.py

 from .obiAssess import pca, PLSCall, corgs_activity_score
 from . import obiExpression, obiGene, obiGeneSets, obiGsea, stats
 
-
 class GeneSetTrans(object):
 
     __new__ = Orange.utils._orange__new__(object)

_bioinformatics/obiGsea.py

 import numpy
 
 import orange
+import Orange
 
 from . import obiGeneSets
 from .obiExpression import *
 
         #take only examples with classValues classes
         nclass = orange.EnumVariable(cv.name, values=nclassvalues)
-        ndom = orange.Domain(itOrFirst(datai).domain.attributes, nclass)
 
-        def removeAndTransformClasses(data):
+        def transform_class(ex,cv,mapval,classValues):
             """
             Removes unnecessary class values and joins them according
             to function input.
             """
-            examples = []
-            for ex in data:
-                if ex[cv] in classValues:
-                    nex = orange.Example(ndom, ex)
-                    nex[-1] = mapval[str(ex[cv].value)]
-                    examples.append(nex)
+            if ex[cv] in classValues:
+                nex = orange.Example(ndom, ex)
+                return nclass(mapval[str(ex[cv].value)])
+            else:
+                return "?"
 
-            return orange.ExampleTable(ndom, examples)
+        nclass.get_value_from = lambda ex,_: transform_class(ex,cv=cv,mapval=mapval,classValues=classValues)
+
+        ndom = orange.Domain(itOrFirst(datai).domain.attributes, nclass)
+
+        def removeAndTransformClasses(data):
+            ndata = Orange.data.Table(ndom, data)
+            ndata = Orange.data.Table(ndom, [ex for ex in ndata if ex[-1].value != "?"])
+            return ndata
 
         if iset(datai):
             datai = removeAndTransformClasses(datai)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.