Changeset 1814:c7d693f650af in orange-bioinformatics


Ignore:
Timestamp:
06/06/13 12:58:47 (11 months ago)
Author:
Flashpoint <vid.flashpoint@…>
Branch:
default
Message:

Added a genesets statistics function to obiGeneSets.py. Added additional columns in OWCustomSets.py

Location:
_bioinformatics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiGeneSets.py

    r1812 r1814  
    176176    return GeneSets(handleNELines(contents, hline)) 
    177177 
     178def getGenesetsStats(genesets): 
     179    num_sets = len(genesets) 
     180    unique_genes = len(set([gene for geneset in genesets for gene in geneset.genes])) 
     181    genes_per_geneset = sum([len(geneset.genes) for geneset in genesets])/num_sets 
     182    return num_sets, unique_genes, genes_per_geneset 
    178183""" 
    179184We have multiple paths for gene set data: 
  • _bioinformatics/widgets/prototypes/OWCustomSets.py

    r1812 r1814  
    99 
    1010import Orange 
     11import cPickle as pickle 
    1112 
    1213from OWWidget import * 
    1314import OWGUI 
    1415 
    15 from Orange.bio.obiGeneSets import loadGMT, list_local, register, local_path, remove_local, modification_date 
     16from Orange.bio.obiGeneSets import loadGMT, list_local, register, local_path, remove_local, modification_date, getGenesetsStats 
    1617 
    1718class standard_icons(object): 
     
    8586        ma.layout().addWidget(self.listView) 
    8687        self.listView.setAllColumnsShowFocus(1) 
    87         self.listView.setColumnCount(2) 
    88         self.listView.setHeaderLabels(["Genesets name", "Import time"]) 
     88        self.listView.setColumnCount(5) 
     89        self.listView.setHeaderLabels(["Name", "Gene Sets", "Unique Genes", "Average no. of Genes/Geneset", "Import time"]) 
    8990 
    9091        self.listView.header().setStretchLastSection(True) 
     
    115116            the_file = os.path.join(local_path(), geneset) 
    116117            mod_time = str(modification_date(the_file)) 
     118            sets = pickle.load(open(the_file, "rb")) 
     119            stats = getGenesetsStats(sets) 
    117120            item.setText(0, name) 
    118             item.setText(1, mod_time[:mod_time.rfind(".")]) 
     121            item.setText(1, str(stats[0])) 
     122            item.setText(2, str(stats[1])) 
     123            item.setText(3, str(stats[2])) 
     124            item.setText(4, mod_time[:mod_time.rfind(".")]) 
    119125 
    120126        print list_local() 
Note: See TracChangeset for help on using the changeset viewer.