metachat.tl.communication_responseGenes_cluster

metachat.tl.communication_responseGenes_cluster(df_deg, df_yhat, deg_clustering_npc=10, deg_clustering_knn=5, deg_clustering_res=1.0, n_deg_genes=200, p_value_cutoff=0.05)[source]

Function for cluster the communcation DE genes based on their fitted expression pattern.

Parameters

df_degpd.DataFrame

DEG summary DataFrame from mc.tl.communication_responseGenes. Each row corresponds to a tested gene with columns including: “waldStat” (Wald statistics), “df” (degrees of freedom), and “pvalue” (p-value).

df_yhatpd.DataFrame

Smoothed gene expression patterns (fitted values) from mc.tl.communication_responseGenes.

deg_clustering_npcint, default=10

Number of principal components to retain for clustering.

deg_clustering_knnint, default=5

Number of neighbors when constructing the KNN graph for Leiden clustering.

deg_clustering_resfloat, default=1.0

Resolution parameter for Leiden clustering.

n_deg_genesint, default=200

Number of top DE genes (ranked by Wald statistics) to include in clustering.

p_value_cutofffloat, default=0.05

p-value cutoff for selecting DE genes to cluster.

Returns

df_deg_clus: pd.DataFrame

Metadata table of clustered DE genes, including columns: [‘waldStat’, ‘df’, ‘pvalue’, ‘cluster’].

df_yhat_clus: pd.DataFrame

The fitted gene expression patterns of the clustered genes