scanpy.pp.log1p#

scanpy.pp.log1p(data, *, base=None, use=None, out=False, chunked=None, chunk_size=None, copy=False, layer=None, obsm=None)[source]#
scanpy.pp.log1p(x, *, base=None, copy=False)
scanpy.pp.log1p(x, *, base=None, copy=False)
scanpy.pp.log1p(x, *, base=None, copy=False)
scanpy.pp.log1p(x, *, base=None, copy=False)
scanpy.pp.log1p(x, *, base=None, copy=False)
scanpy.pp.log1p(x, *, base=None, copy=False)
scanpy.pp.log1p(adata, *, base=None, use=None, out=False, chunked=False, chunk_size=None, layer=None, obsm=None)

Logarithmize the data matrix.

Computes X=log⁡(X+1), where log denotes the natural logarithm unless a different base is given.

Array type support#

Array type

supported

… experimentally in dask Array

numpy.ndarray

✅

✅

scipy.sparse.{csr,csc}_{array,matrix}

✅

✅

Parameters:
data AnnData | ndarray | csr_array | csc_array | csr_matrix | csc_matrix

The (annotated) data matrix of shape n_obs × n_vars. Rows correspond to cells and columns to genes.

base Number | None (default: None)

Base of the logarithm. Natural logarithm is used by default.

use LayerAcc | MultiAcc | str | None (default: None)

Which matrix to logarithmize. Given by an accessor, e.g. A.X, A.layers['counts'] or A.obsm['pca']. strs are anndata.acc.AdAcc.resolve()d, e.g. 'layers.counts'.

layer str | None (default: None)

Deprecated since version 1.13.0: Use use/out instead.

A key of layers, i.e. layer='k' is use=A.layers['k'].

obsm str | None (default: None)

Deprecated since version 1.13.0: Use use/out instead.

A key of obsm, i.e. obsm='k' is use=A.obsm['k'].

out LayerAcc | MultiAcc | str | bool (default: False)

Where to write the result, e.g. A.layers['scaled']. strs are anndata.acc.AdAcc.resolve()d, e.g. 'layers.scaled'. If True, the result is returned instead of written. If False, it is written to the place use reads from.

chunked bool | None (default: None)

Process the data matrix in chunks, which will save memory. Applies only to AnnData.

chunk_size int | None (default: None)

n_obs of the chunks to process the data in.

copy bool (default: False)

Deprecated since version 1.13.0: Copy adata before calling this function instead.

Whether to return a modified copy instead of modifying adata in place.

Return type:

AnnData | ndarray | csr_array | csc_array | csr_matrix | csc_matrix | None

Returns:

Returns None if the result was written, else the logarithmized matrix.