def log1p(data, copy=False):
"""Logarithmize the data matrix.
Computes `X = log(X + 1)`, where `log` denotes the natural logrithm.
Parameters
----------
data : array-like or AnnData
The data matrix.
copy : bool (default: False)
If an AnnData is passed, determines whether a copy is returned.
Returns
-------
Returns or updates data, depending on `copy`.
"""
if isinstance(data, AnnData):
adata = data.copy() if copy else data
adata.X = log1p(data.X)
return adata if copy else None
X = data # proceed with data matrix
if not issparse(X):
return np.log1p(X)
else:
return X.log1p()
评论列表
文章目录