Changeset 1578:9bc83a60db78 in orange-bioinformatics for obiGeneSetSig.py


Ignore:
Timestamp:
02/22/12 11:49:26 (2 years ago)
Author:
markotoplak
Branch:
default
Children:
1579:364880120934, 1583:2b90e7c95085
rebase_source:
7341d6e68353eb1fad743387809483d39c88b813
Message:

Gene matcher now have a call function and return a Match object, which is used for matching. Backward compatibility was retained.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • obiGeneSetSig.py

    r1572 r1578  
    22import obiAssess 
    33import Orange.misc 
    4 import orange 
    54import obiGeneSets 
    65import obiGene 
     
    109import stats 
    1110 
     11def selectGenesetsData(data, matcher, geneSets, minSize=3, maxSize=1000, minPart=0.1, classValues=None): 
     12    """ 
     13    Returns gene sets and data which falling under upper criteria. 
     14    """ 
     15    gso = obiGsea.GSEA(data, matcher=matcher, classValues=classValues, atLeast=0) 
     16    gso.addGenesets(geneSets) 
     17    okgenesets = gso.selectGenesets(minSize=minSize, maxSize=maxSize, minPart=minPart).keys() 
     18    gsetsnum = gso.to_gsetsnum(okgenesets) 
     19    return gso.data, okgenesets, gsetsnum 
     20 
    1221class SetSig(object): 
    1322 
    1423    __new__ = Orange.misc._orange__new__(object) 
    1524 
    16     def __init__(self, matcher, geneSets, minSize=3, maxSize=1000, minPart=0.1, classValues=None): 
     25    def __init__(self, matcher, gene_sets, min_size=3, max_size=1000, min_part=0.1, class_values=None): 
    1726        self.matcher = matcher 
    18         self.geneSets = geneSets 
    19         self.minSize = minSize 
    20         self.maxSize = maxSize 
    21         self.minPart = minPart 
    22         self.classValues = classValues 
     27        self.gene_sets = gene_sets 
     28        self.min_size = min_size 
     29        self.max_size = max_size 
     30        self.min_part = min_part 
     31        self.class_values = class_values 
    2332 
    2433    def __call__(self, data, weight_id=None): 
    2534        data, oknames, gsetsnum = obiAssess.selectGenesetsData(data,  
    26             self.matcher, self.geneSets, 
    27             minSize=self.minSize, maxSize=self.maxSize,  
    28             minPart=self.minPart, classValues=self.classValues) 
     35            self.matcher, self.gene_sets, 
     36            minSize=self.min_size, maxSize=self.max_size,  
     37            minPart=self.min_part, classValues=self.class_values) 
    2938 
    3039        def setSig_example_geneset(ex, data): 
     
    6877 
    6978            def t(ex, w, gs=gs, ldata=data): 
    70                 domain = orange.Domain([ldata.domain.attributes[ai] for ai in gs], ldata.domain.classVar) 
    71                 datao = orange.ExampleTable(domain, ldata) 
    72                 example = orange.Example(domain, ex) #domains need to be the same 
     79                domain = Orange.data.Domain([ldata.domain.attributes[ai] for ai in gs], ldata.domain.classVar) 
     80                datao = Orange.data.Table(domain, ldata) 
     81                example = Orange.data.Instance(domain, ex) #domains need to be the same 
    7382                return setSig_example_geneset(example, datao) 
    7483          
     
    8998 
    9099    fp = 120 
    91     ldata = orange.ExampleTable(data.domain, data[:fp]) 
    92     tdata = orange.ExampleTable(data.domain, data[fp:]) 
     100    ldata = Orange.data.Table(data.domain, data[:fp]) 
     101    tdata = Orange.data.Table(data.domain, data[fp:]) 
    93102 
    94103    matcher = obiGene.matcher([]) 
     
    107116        print '\n'.join([ a + ": " +str(b) for a,b in ol]) 
    108117 
    109     ass = SetSig(ldata, matcher=matcher, geneSets=gsets, classValues=choosen_cv, minPart=0.0) 
     118    ass = SetSig(ldata, matcher=matcher, gene_sets=gsets, class_values=choosen_cv, min_part=0.0) 
    110119    print ass.domain 
    111120    ar = to_old_dic(ass.domain, data[:5]) 
Note: See TracChangeset for help on using the changeset viewer.