liana.utils.zi_minmax#
- liana.utils.zi_minmax(X, cutoff=0.5)#
Zero-inflated min-max scaling, adopted from CiteFuse (Kim et al., 2020; https://academic.oup.com/bioinformatics/article/36/14/4137/5827474).
This function scales the data to the range [0, 1] for each column of a two-dimensional array and sets values below a specified cutoff to 0 (after scaling).
- Parameters:
- Return type:
csr_matrix- Returns:
X The scaled data matrix
Examples
>>> import numpy as np >>> import liana as li >>> x = np.array([[0.1, 0.3], ... [2.0, 4.0], ... [5.5, 7.1]]) >>> li.ut.zi_minmax(x).toarray().round(3) array([[0. , 0. ], [0. , 0.544], [1. , 1. ]])
cutoffis applied after scaling, so lowering it keeps more of the middle:>>> li.ut.zi_minmax(x, cutoff=0.1).toarray().round(3) array([[0. , 0. ], [0.352, 0.544], [1. , 1. ]])