netmap.downstream.edge_selection.add_top_edge_annotation_cluster

netmap.downstream.edge_selection.add_top_edge_annotation_cluster(grn_adata, top_edges=[0.1], nan_fill=0, cluster_var='spectral')[source]

Annotate grn_adata.var with per-cluster top-edge cell counts.

For each cluster in grn_adata.obs[cluster_var], counts how many cells within that cluster include each edge among their top-N% highest-attribution edges. Results are merged into grn_adata.var as new columns.

Pass multiple values in top_edges when several thresholds are needed; sorting is performed only once regardless of how many thresholds are supplied.

Parameters:
  • grn_adata (anndata.AnnData) – GRN AnnData object to process.

  • top_edges (list of float) – Fractions of top edges to count. Defaults to [0.1].

  • nan_fill (int or float) – Value used to fill edges with no count at a given threshold/cluster combination. Defaults to 0.

  • cluster_var (str) – Column in grn_adata.obs that identifies cluster membership. Defaults to 'spectral'.

Returns:

grn_adata with new columns added to .var

named 'cell_count_{top_edge}_{cluster}' for every combination of threshold and cluster.

Return type:

anndata.AnnData