netmap.masking.internal.binarize_adata

netmap.masking.internal.binarize_adata(adata, expression_threshold=0, layer='X')[source]

Binarize gene expression to 0/1 based on an expression threshold.

Parameters:
  • adata (anndata.AnnData) – Expression AnnData object.

  • expression_threshold (float) – Values above this are set to 1. Defaults to 0.

  • layer (str) – 'X' to use adata.X, otherwise the name of a layer in adata.layers. Defaults to 'X'.

Returns:

Binary expression matrix of shape

(n_cells, n_genes).

Return type:

numpy.ndarray or numpy.matrix