netmap.masking.internal.add_neighbourhood_expression_mask

netmap.masking.internal.add_neighbourhood_expression_mask(adata, grn_adata, strict=False, layer='X')[source]

Create a binary cell×edge co-expression mask and add it to the GRN AnnData.

The mask indicates whether both the source and target genes of each edge are expressed in the kNN neighbourhood of each cell.

Parameters:
  • adata (anndata.AnnData) – Expression AnnData; must have obsm['X_pca'].

  • grn_adata (anndata.AnnData) – GRN AnnData whose var_names are SourceGene_TargetGene edge identifiers.

  • strict (bool) – If True, use direct binarization of adata.X instead of neighbourhood expression. Defaults to False.

  • layer (str) – Layer to use for expression values. Defaults to 'X'.

Returns:

grn_adata with layers['mask'] (int8) and

var['count_nonzero'] added.

Return type:

anndata.AnnData