Changes in [1804:4981b5cd8411:1823:fb105c3cd60f] in orange-bioinformatics


Ignore:
Location:
_bioinformatics
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiGeneSets.py

    r1798 r1818  
    1010import cPickle as pickle, os, tempfile, sys 
    1111from collections import defaultdict 
     12import datetime 
    1213 
    1314import Orange.core as orange 
     
    143144 
    144145    go_sets = obimiRNA.get_GO(mirnas, annotations, enrichment=enrichment, pval=pval, goSwitch=False) 
    145     print go_sets 
    146146 
    147147    go_sets = obimiRNA.filter_GO(go_sets, annotations, treshold=treshold) 
     
    159159 
    160160    For now the description is skipped. 
     161 
     162    Example Gene Set (.gmt) file: 
     163    anti-liver_sw   anti-liver_sw   BMPR1A  APOD    WSB1    BMI1    SLC2A1  ... 
     164    B-cells_sw  B-cells_sw  E2F5    NCF1    PALM2-AKAP2 IRF4    SLC2A1  ... 
     165    Bladder_sw  Bladder_sw  PLCD4   ANGPTL1 LOC286191   ST0N1   LOC283904   ... 
     166    cerebellum_sw   cerebellum_sw   C19orf43    LOC653464   KI110802    ... 
     167    Cervix_sw   Cervix_sw   LAMA4   GSTM5   SNX19   DKK1    NT5E    ... 
    161168    """ 
    162169 
     
    164171        tabs = [tab.strip() for tab in s.split("\t")] 
    165172        return GeneSet(id=tabs[0], description=tabs[1], 
    166                                    hierarchy=(name,), genes=tabs[2:]) 
     173                                   hierarchy=("Custom Gene Sets",name), genes=tabs[2:]) 
    167174 
    168175    def handleNELines(s, fn): 
     
    176183    return GeneSets(handleNELines(contents, hline)) 
    177184 
     185def getGenesetsStats(genesets): 
     186    num_sets = len(genesets) 
     187    unique_genes = len(set([gene for geneset in genesets for gene in geneset.genes])) 
     188    genes_per_geneset = sum([len(geneset.genes) for geneset in genesets])/num_sets 
     189    return num_sets, unique_genes, genes_per_geneset 
    178190""" 
    179191We have multiple paths for gene set data: 
     
    224236    gs_files = filter(is_genesets_file, os.listdir(pth)) 
    225237    return [ filename_parse(fn) + (True,) for fn in gs_files ] 
     238 
     239def remove_local(gene_set): 
     240    """ Removes a given gene set from the local repository. """ 
     241    pth = local_path() 
     242    gs_files = filter(is_genesets_file, os.listdir(pth))  
     243    for setfile in gs_files: 
     244        if setfile.__contains__(gene_set): 
     245            setBgone = os.path.join(pth, setfile) 
     246            os.remove(setBgone)  
     247 
     248def modification_date(file): 
     249    t = os.path.getmtime(file) 
     250    return datetime.datetime.fromtimestamp(t) 
    226251 
    227252def list_serverfiles_from_flist(flist): 
     
    414439 
    415440if __name__ == "__main__": 
    416     print reactomePathwaysGeneSets() 
    417     exit() 
    418441    rsf = orngServerFiles.ServerFiles(username=sys.argv[1], password=sys.argv[2]) 
    419442    upload_genesets(rsf) 
  • _bioinformatics/widgets/OWSetEnrichment.py

    r1804 r1823  
    6969    def __init__(self, parent=None, signalManager=None, name="Gene Set Enrichment Analysis", **kwargs): 
    7070        OWWidget.__init__(self, parent, signalManager, name, **kwargs) 
    71         self.inputs = [("Example Table", ExampleTable, self.setData, Default), ("Reference", ExampleTable, self.setReference)] 
    72         self.outputs = [("Selected Examples", ExampleTable)] 
     71        self.inputs = [("Data", ExampleTable, self.setData, Default), ("Reference", ExampleTable, self.setReference)] 
     72        self.outputs = [("Data subset", ExampleTable)] 
    7373 
    7474        self.speciesIndex = 0 
     
    204204            with orngServerFiles.DownloadProgress.setredirect(self.progressBarSet): 
    205205                all, local = obiGeneSets.list_all(), obiGeneSets.list_local() 
    206                 organisms = set(obiTaxonomy.essential_taxids() + [t[1] for t in all]) 
     206                organisms = set(obiTaxonomy.essential_taxids() + filter(None, [t[1] for t in all])) 
    207207            self.progressBarFinished() 
    208208 
     
    268268        for hierarchy, t_id, _ in self.genesets: 
    269269            collect(collection[t_id], hierarchy) 
     270 
     271        #add genesets without species identifiers 
     272        collection[taxid].update(collection[None]) 
    270273        return collection[taxid] 
    271274 
Note: See TracChangeset for help on using the changeset viewer.