anndict.wrappers.ai_annotate_biological_process_adata_dict

anndict.wrappers.ai_annotate_biological_process_adata_dict#

anndict.wrappers.ai_annotate_biological_process_adata_dict(adata, groupby, n_top_genes, new_label_column='ai_biological_process')[source]#

Annotate biological processes based on the top n marker genes for each cluster.

This function performs differential expression analysis to identify marker genes for each cluster and applies a user-defined function to determine the biological processes for each cluster based on the top marker genes. The results are added to the AnnData object and returned as a DataFrame.

Parameters:
adata AnnData

An AnnData object.

groupby str

Column in adata.obs to group by for differential expression analysis.

n_top_genes int

The number of top marker genes to consider.

label_column

The name of the new column in adata.obs where the cell type annotations will be stored.

new_label_column str

Return type:

DataFrame

Returns:

A pd.DataFrame with a column for the top marker genes for each cluster.

Notes

This function also modifies the input adata in place, adding annotations to adata.obs[new_label_col]

Examples

import anndict as adt

# This will annotate the treatment group with biological processes based on the top 10 differentially expressed genes in each group
ai_annotate_biological_process(adata, groupby='treatment_vs_control',
    n_top_genes=10, new_label_column='ai_biological_process')