liana.mt.process_scores

Contents

liana.mt.process_scores#

liana.mt.process_scores(liana_res, score_key, inverse_fn=<function DefaultValues.inverse_fn>)#

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_fn Callable[[Series], Series] (default: <function DefaultValues.inverse_fn at 0x7e3fdb8699e0>)

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.mt.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_fn. A score that is already “higher is stronger” is returned unchanged:

>>> import liana as li
>>> adata = li.ds.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")