liana.pp.neg_to_zero

Contents

liana.pp.neg_to_zero#

liana.pp.neg_to_zero(X, cutoff=0)#

Set negative values to 0.

Parameters:
X NDArray[number] | csc_matrix | csr_matrix | csc_array | csr_array

Data to be transformed.

cutoff float (default: 0)

Cutoff value for zero-inflation - values less than this are set to 0. Default is 0.

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.pp.neg_to_zero(x).toarray()
array([[0. , 0. , 0.1, 0.4, 2. ]])

cutoff raises the threshold above 0:

>>> li.pp.neg_to_zero(x, cutoff=0.5).toarray()
array([[0., 0., 0., 0., 2.]])