Commits

Marko Toplak committed 9884f85

Updated GSEA examples to the new namespace.

Comments (0)

Files changed (3)

docs/reference-html/gsea1.py

-import orange, obiGsea, obiGene
+import Orange
+from Orange.bio import obiGsea, obiGene
 
-data = orange.ExampleTable("iris")
+data = Orange.data.Table("iris")
 
 gen1 = dict([
     ("sepal",["sepal length", "sepal width"]), 
 
 res = obiGsea.runGSEA(data, matcher=obiGene.matcher([]), minSize=2, geneSets=gen1)
 print "%5s  %6s %6s %s" % ("LABEL", "NES", "P-VAL", "GENES")
-for name,resu in res.items():
-    print "%5s  %6.3f %6.3f %s" % (name, resu["nes"], resu["p"], str(resu["genes"]))
+for gs,resu in res.items():
+    print "%5s  %6.3f %6.3f %s" % (gs.id, resu["nes"], resu["p"], str(resu["genes"]))

docs/reference-html/gsea2.py

-import obiDicty
-import obiGeneSets
-import obiGsea
-import orange
-import obiGene
+import Orange
+from Orange.bio import obiDicty, obiGeneSets, obiGsea,obiGene
 
 dbc = obiDicty.DatabaseConnection()
-data = dbc.getData(sample='pkaC-', time="8")[0] #get first chip
+data = dbc.get_single_data(sample='pkaC-', time="8")
 
-print "First 10 examples"
-for ex in data[:10]:
-    print ex
+#select the first chip (the first attribute)
+data = data.translate([data.domain.attributes[0]], True)
 
-matcher=obiGene.matcher([[obiGene.GMKEGG("ddi"),obiGene.GMDicty()]])
+matcher = obiGene.matcher([[obiGene.GMKEGG("dicty"), obiGene.GMDicty()]])
+genesets =  obiGeneSets.collections((("KEGG",), "dicty"))
 
-genesets =  obiGeneSets.collections([":kegg:ddi"])
-res = obiGsea.runGSEA(data, matcher=matcher, minPart=0.05, geneSets=genesets, 
-    permutation="gene")
+res = obiGsea.runGSEA(data, matcher=matcher, minPart=0.05, 
+    geneSets=genesets, permutation="gene")
 
-print "GSEA results"
-print "%-40s %6s %6s %6s %7s" % ("LABEL", "NES", "P-VAL", "SIZE", "MATCHED") 
-for name,resu in res.items()[:10]: 
-    print "%-40s %6.3f %6.3f %6d %7d" % (name[:30], resu["nes"], resu["p"], 
-        resu["size"], resu["matched_size"]) 
+print "%-40s %6s %6s %6s %7s" % ("LABEL", "NES", "P-VAL", "SIZE", "MATCHED")
+for name,resu in sorted(res.items()[:10], key=lambda x: x[1]["p"]): 
+    print "%-40s %6.3f %6.3f %6d %7d" % (name.name[:35], resu["nes"],
+        resu["p"], resu["size"], resu["matched_size"]) 
 

docs/reference-html/gsea3.py

-import obiGeneSets
-import obiGsea
-import orange
-import obiGene
-import obiGEO
+import Orange
+from Orange.bio import obiDicty, obiGeneSets, obiGsea, obiGene, obiGEO
 
-import obiGEO
 gds = obiGEO.GDS("GDS10")
 data = gds.getdata() 
 
 print "Possible phenotype descriptors:"
 print map(lambda x: x[0], obiGsea.allgroups(data).items())
 
-matcher=obiGene.matcher([obiGene.GMKEGG("9606")])
+matcher = obiGene.matcher([obiGene.GMKEGG("Homo sapiens")])
+genesets = obiGeneSets.collections((("KEGG",), "Homo sapiens"))
 
-phenVar = "tissue"
-geneVar = "gene" #use gene meta variable for gene names
-
-genesets =  obiGeneSets.collections([":kegg:hsa"])
+#the number of permutations (n) should be much higher
 res = obiGsea.runGSEA(data, matcher=matcher, minPart=0.05, geneSets=genesets, 
-    permutation="class", n=10, phenVar=phenVar, geneVar=geneVar)
+    permutation="class", n=10, phenVar="tissue", geneVar="gene") 
 
 print
-print "GSEA results (choosen descriptor: tissue)"
+print "GSEA results (descriptor: tissue)"
 print "%-40s %6s %6s %6s %7s" % ("LABEL", "NES", "FDR", "SIZE", "MATCHED") 
-for name,resu in sorted(res.items(), key=lambda x: x[1]["fdr"])[:10]: 
-    print "%-40s %6.3f %6.3f %6d %7d" % (name[:30], resu["nes"], resu["fdr"], 
-        resu["size"], resu["matched_size"]) 
+for gs, resu in sorted(res.items(), key=lambda x: x[1]["fdr"])[:10]: 
+    print "%-40s %6.3f %6.3f %6d %7d" % (gs.name[:30],
+        resu["nes"], resu["fdr"], resu["size"], resu["matched_size"])