@@ -123,8 +123,9 @@ def _fit_ks(self, background, activity, p):
123123 self ._X .update ({f [1 ]: {'PVAL' : p , 'KS' : k }})
124124
125125 def _fit_binom (self , activity , p ):
126+ activity = ((x [0 ], [x [1 ].count (1 ), x [1 ].count (0 )]) for x in activity )
126127 scaffolds , activity = zip (* activity )
127- func = partial (self ._hyp , p = self ._p , alternative = self ._alt )
128+ func = partial (self ._hyp , n = None , p = self ._p , alternative = self ._alt )
128129 with ProcessPoolExecutor (self ._n_jobs ) as pool :
129130 for f in tqdm .tqdm (zip (pool .map (func , activity ), scaffolds ),
130131 total = len (scaffolds ), disable = p is False ):
@@ -150,11 +151,13 @@ def to_dataframe(self, top_n=100):
150151
151152 df = pd .DataFrame ()
152153 x = sorted (self ._X , key = lambda x : self ._X [x ]['PVAL' ])
153- scaffolds = x [:top_n ]
154+ scaffolds = x [:top_n ] if len ( x ) >= top_n else x
154155 df ['SCAFFOLD' ] = scaffolds
155156 df ['PVAL' ] = [self ._X [s ]['PVAL' ] for s in scaffolds ]
156157 df ['CRIT' ] = [self ._X [s ]['CRIT' ] for s in scaffolds ]
157158
159+ return df
160+
158161 def __getitem__ (self , item ):
159162 return self ._X [item ]
160163
0 commit comments