Changeset 1476:e7918c4d665f in orange-bioinformatics


Ignore:
Timestamp:
09/29/11 15:56:01 (3 years ago)
Author:
markotoplak
Branch:
default
Convert:
5aa76b0cff8f4b85047a8823232baddae28a87a2
Message:

Genotype distances now has Spearman correlation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • widgets/OWGenotypeDistances.py

    r1401 r1476  
    121121    return math.sqrt( sum((a-b)*(a-b) for a,b in okvals )) 
    122122 
     123def spearman_lists(l1, l2): 
     124    """ Returns pearson correlation between two lists. Ignores elements 
     125    which are None.""" 
     126    import scipy.stats 
     127    okvals = [ (a,b) for a,b in zip(l1,l2) if a != None and b != None ] 
     128    #print okvals, len(okvals) 
     129    return scipy.stats.spearmanr([ v[0] for v in okvals], [ v[1] for v in okvals] )[0] 
     130 
     131def dist_spearman(l1, l2): 
     132    return (1.-spearman_lists(l1, l2))/2 
     133 
    123134def dist_pcorr(l1, l2): 
    124135    #normalized to 0..1 
    125     return (1-pearson_lists(l1, l2))/2 
     136    return (1.-pearson_lists(l1, l2))/2 
    126137 
    127138def dist_eucl(l1, l2): 
     
    189200    settingsList = ["auto_commit"] 
    190201     
    191     DISTANCE_FUNCTIONS = [("Pearson correlation", dist_pcorr), 
    192                           ("Euclidean distance", dist_eucl)] 
     202    DISTANCE_FUNCTIONS = [("Distance from Pearson correlation", dist_pcorr), 
     203                          ("Euclidean distance", dist_eucl), 
     204                          ("Distance from Spearman correlation", dist_spearman)] 
    193205     
    194206    def __init__(self, parent=None, signalManager=None, title="Genotype Distances"): 
Note: See TracChangeset for help on using the changeset viewer.