grassp.tl.prune_markers#
- prune_markers(adata, gt_col, key_added=None, min_probability=0.9)[source]#
Remove “outliers” from marker proteins whose compartment label is not supported by their k-NN neighbourhood.
Runs
competitive_diffusion()on the existing markers and retains only those whose neighbours confidently predict the same compartment label. Markers whose predicted label disagrees with their annotated label, or whose neighbourhood confidence falls belowmin_probability, are set to NaN in the output column. Non-marker proteins (NaN ingt_col) are always set to NaN.This is useful for cleaning noisy or misannotated training sets before semi-supervised classification.
- Parameters:
- adata
AnnData anndata.AnnDatawith a populated neighbour graph (adata.obsp["connectivities"]).- gt_col
str .obscolumn containing the ground-truth compartment labels. Proteins with NaN values are treated as unannotated.- key_added
str|None(default:None) .obscolumn to write the pruned labels to. Defaults to"{gt_col}_pruned".- min_probability
float(default:0.9) Minimum k-NN probability for a marker to be considered neighbourhood-consistent. Markers below this threshold are removed. Increasing this value will remove more markers, leading to more consistent but sparser annotations. Default is
0.9.
- adata
- Return type:
- Returns:
Modifies
adata.obs[key_added]in place: retained markers keep their original label; removed markers are set to NaN.