Commits

Marko Toplak committed 959e64f

obiGeneSetSig: Prevent crashing of LLR if the standard deviation is zero.

Comments (0)

Files changed (1)

_bioinformatics/obiGeneSetSig.py

         return st1 == 0 or st2 == 0
     
     if common_if_extreme and extreme():
-        print "extreme", st1, st2,
         st1 = st2 = statc.std(list1 + list2)
-        print "new", st1, st2
 
     return mi1, st1, mi2, st2
 
     return -(x-mi)**2 / (2.0*std**2) - _norm_pdf_logC - math.log(std)
 
 def _llrlogratio(v, mi1, std1, mi2, std2):
-    if mi1 == None or std1 == None or mi2 == None or std2 == None:
+    if mi1 == None or std1 == None or mi2 == None or std2 == None or std1 == 0 or std2 == 0:
         return 0. #problem with estimation
     #lpdf1 = scipy.stats.norm.logpdf(v, mi1, std1)
     #lpdf2 = scipy.stats.norm.logpdf(v, mi2, std2)
                 vals2 = []
                 for v,g in zip(vals, genes_gs):
                     m,s = normalizec[g]
-                    vals2.append((v-m)/s)
+                    if s == 0: #disregard attributes without differences
+                        vals2.append(0.)
+                    else:
+                        vals2.append((v-m)/s)
                 vals = vals2
             
             return sum(vals)