grassp.tl.knn_annotation#
- knn_annotation(data, obs_ann_col, key_added='consensus_graph_annotation', exclude_category=None, inplace=True)[source]#
Annotate proteins based on their k-nearest neighbors.
For each protein, looks at its k-nearest neighbors and assigns the most common annotation among them.
- Parameters:
- data
AnnData
Annotated data matrix with proteins as observations (rows)
- obs_ann_col
str
Column in data.obs containing annotations to propagate
- key_added
str
(default:'consensus_graph_annotation'
) Key under which to add the annotations in data.obs
- exclude_category
Union
[str
,List
[str
],None
] (default:None
) Category or list of categories to exclude from annotation propagation
- inplace
bool
(default:True
) If True, modify the data in place. If False, return the modified data.
- data
- Return type:
AnnData
|None
- Returns:
None | AnnData Modified AnnData object with new annotations in .obs[key_added]