[docs]defannotation(adata:AnnData,label_list:list[str],use_label:str="leiden",copy:bool=False,)->AnnData|None:"""\ Adding annotation for cluster Parameters ---------- adata Annotated data matrix. label_list List of the labels which assigned to current cluster result. use_label Choosing cluster type. copy Return a copy instead of writing to adata. Returns ------- Depending on `copy`, returns or updates `adata` with the following fields. **[cluster method name]_anno** : `adata.obs` field The annotation of cluster results. """iflabel_listisNone:raiseValueError("Please give the label list!")adata=adata.copy()ifcopyelseadataiflen(label_list)!=len(adata.obs[use_label].unique()):raiseValueError("Please give the correct number of label list!")adata.obs[use_label+"_anno"]=adata.obs[use_label].cat.rename_categories(label_list)print("The annotation is added to adata.obs['"+use_label+"_anno"+"']")returnadataifcopyelseNone