liana.utils.neg_to_zero#
- liana.utils.neg_to_zero(X, cutoff=0)#
Set negative values to 0.
- Parameters:
- Return type:
csr_matrix- Returns:
The modified data matrix
Examples
>>> import numpy as np >>> import liana as li >>> x = np.array([-1, -0.5, 0.1, 0.4, 2]) >>> li.ut.neg_to_zero(x).toarray() array([[0. , 0. , 0.1, 0.4, 2. ]])
cutoffraises the threshold above 0:>>> li.ut.neg_to_zero(x, cutoff=0.5).toarray() array([[0., 0., 0., 0., 2.]])