netmap.masking.internal.add_neighbourhood_expression_mask

netmap.masking.internal.add_neighbourhood_expression_mask(adata, grn_adata, strict=False, layer='X', mask_data=True)[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, and whose var must contain unambiguous source/target gene columns (as produced by netmap.grn.inferrence.inferrence()) — edge genes are read from these columns rather than parsed from var_names, since gene names may themselves contain underscores.

  • 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