netmap.masking.internal

Neighbourhood-expression masking for GRN edges.

Functions in this module build binary cell×edge masks that indicate whether both the source and target genes of an edge are expressed in the local kNN neighbourhood of each cell. The masks are stored in grn_adata.layers['mask'] and used downstream to filter low-confidence edges.

Functions

add_cluster_based_candidate_edges

Annotate edges with per-cluster mask support fractions and candidacy flags.

add_cluster_wise_spearman

Compute cluster-wise Spearman rank correlation between source and target gene expression for each edge in grn_adata, adding a '{cluster}_spearman' column to grn_adata.var for every cluster.

add_neighbourhood_expression_mask

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

binarize_adata

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

create_pairwise_binary_mask

Creates a dense 2D array of pairwise masks using preallocation.

find_consistent_pairs

Compute Spearman correlation between forward and reverse edge attribution scores.

get_neighborhood_expression

Checks if each gene is expressed in the k-nearest neighbors (kNN) of each cell.