Flashpoint committed c7d693f

Added a genesets statistics function to Added additional columns in

  • Participants
  • Parent commits c4f8bb0

Comments (0)

Files changed (2)


     return GeneSets(handleNELines(contents, hline))
+def getGenesetsStats(genesets):
+    num_sets = len(genesets)
+    unique_genes = len(set([gene for geneset in genesets for gene in geneset.genes]))
+    genes_per_geneset = sum([len(geneset.genes) for geneset in genesets])/num_sets
+    return num_sets, unique_genes, genes_per_geneset
 We have multiple paths for gene set data:


 from StringIO import StringIO
 import Orange
+import cPickle as pickle
 from OWWidget import *
 import OWGUI
-from import loadGMT, list_local, register, local_path, remove_local, modification_date
+from import loadGMT, list_local, register, local_path, remove_local, modification_date, getGenesetsStats
 class standard_icons(object):
     def __init__(self, qwidget=None, style=None):
         self.listView = QTreeWidget(ma)
-        self.listView.setColumnCount(2)
-        self.listView.setHeaderLabels(["Genesets name", "Import time"])
+        self.listView.setColumnCount(5)
+        self.listView.setHeaderLabels(["Name", "Gene Sets", "Unique Genes", "Average no. of Genes/Geneset", "Import time"])
             name = geneset[geneset.index("_._")+3:geneset.index(".gmt")+4]
             the_file = os.path.join(local_path(), geneset)
             mod_time = str(modification_date(the_file))
+            sets = pickle.load(open(the_file, "rb"))
+            stats = getGenesetsStats(sets)
             item.setText(0, name)
-            item.setText(1, mod_time[:mod_time.rfind(".")])
+            item.setText(1, str(stats[0]))
+            item.setText(2, str(stats[1]))
+            item.setText(3, str(stats[2]))
+            item.setText(4, mod_time[:mod_time.rfind(".")])
         print list_local()