@@ -343,13 +343,16 @@ def logit_combine_p_values(pvalues):
343343
344344def aggregate_es (es_array , p_array ):
345345 if len ([x for x in es_array if not pd .isna (x )]) > 0 :
346- weights = [- 1 * np .log10 (x ) for x in p_array if x != 1 and not pd .isna (x )]
347- try :
348- es_mean = np .round (np .average (es_array , weights = weights ), 3 )
349- except TypeError :
350- print (es_array , p_array )
351- raise
352- es_mostsig = es_array [int (np .argmax (weights ))]
346+ weights = - np .log10 (p_array )
347+ inds = np .isfinite (weights )
348+ weights = weights [inds ]
349+ if weights .sum () == 0 :
350+ weights = 1 / len (weights )
351+ else :
352+ weights /= weights .sum ()
353+ es_array = np .array (es_array )[inds ]
354+ es_mean = np .sum (es_array * weights )
355+ es_mostsig = es_array [np .argmax (weights )]
353356 else :
354357 es_mean = np .nan
355358 es_mostsig = np .nan
@@ -358,9 +361,8 @@ def aggregate_es(es_array, p_array):
358361
359362def get_es_list (filtered_df , allele ):
360363 es_col = get_counts_column (allele , 'es' )
361- pval_col = get_counts_column (allele , 'pval' )
362364 return [(row [es_col ], row ['fname' ]) for _ , row in filtered_df .iterrows ()
363- if not pd .isna (row [es_col ]) and row [ pval_col ] != 1 ]
365+ if not pd .isna (row [es_col ])]
364366
365367
366368def list_to_str (array ):
0 commit comments