decoupler.swap_layer

decoupler.swap_layer(adata, layer_key, X_layer_key='X', inplace=False)

Swaps an adata.X for a given layer.

Swaps an AnnData X matrix with a given layer. Generates a new object by default.

Parameters:
adataAnnData

Annotated data matrix.

layer_keystr

.layers key to place in .X.

X_layer_keystr, None

.layers key where to move and store the original .X. If None, the original .X is discarded.

inplacebool

If False, return a copy. Otherwise, do operation inplace and return None.

Returns:
layerAnnData, None

If inplace=False, new AnnData object.