liana.method.process_scores

Contents

liana.method.process_scores#

liana.method.process_scores(liana_res, score_key, inverse_fun=<function DefaultValues.inverse_fun>)#

Processes and outputs a given score.

Parameters:
  • liana_res (DataFrame) – liana_res a DataFrame in liana’s format.

  • score_key (str) – Column name of the score in liana_res. If None, the score is inferred from the method.

  • inverse_fun (Callable (default: <function DefaultValues.inverse_fun at 0x760ec1da6520>)) – Function applied to scores for which a lower value is the stronger one – p-values and aggregate ranks such as magnitude_rank – so that “higher is stronger” holds throughout. Defaults to -log10(x + eps). Which scores are inverted is decided by liana.method.get_method_scores, so this is handled automatically for liana’s own scores.

Return type:

DataFrame

Returns:

A DataFrame with the processed scores.

Examples

magnitude_rank is one of the scores for which a lower value is the stronger one, so it is inverted with inverse_fun. A score that is already “higher is stronger” is returned unchanged:

>>> import liana as li
>>> adata = li.testing.generate_toy_adata()
>>> li.mt.rank_aggregate(adata, groupby='bulk_labels', n_perms=None)
>>> res = li.mt.process_scores(adata.uns['liana_res'],
...                            score_key='magnitude_rank')