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)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.