annotate_new_cellnames

besca.tl.rc.annotate_new_cellnames(adata, cluster_subset, names, new_label='celltype', method='leiden')[source]

annotate new cellnames to each of the subclusters identified by running recluster.

Give each subcluster a new celltype identifier. Can only be run on an AnnData subset that has already been reclustered, e.g. using the recluster function also available in this package. The list of provided names must be of equal length to the number of subclusters in the AnnData subset. The order must be the same as the order of the clusters identifiers (integer expected).

Parameters:
  • adata – complete AnnData object from which the subset was extracted. Must contain adata.obs.celltype.

  • cluster_subset – AnnData subset on which a reclustering has been run. Must contain adata.obs.celltype.

  • names ([str]) – list of strings containing the new celltype annotation. Order and Length must mach the lexicographic order of the louvain clusters in the AnnData susbet.

  • celltype_label

  • new_label (str | default = ‘celltype’) – string specifying under which label in adata.obs the new annotation should be saved (it will overwrite existing annotations under this name)

  • method (str | default = ‘leiden’) –

    string indicating the method used for clustering. This string will be used to retrieve the cluster numbers

    in adata.obs and in the cluster_subset. (assuming the same obs column name)

Returns:

  • Complete AnnData object with the new celltype annotations in the adata.obs.new_label column for

  • the subclusters.

Examples

Please refer to the code examples section of the documentation for a complete example of the reclustering process.