enrichmap.pl.gene_contributions_pca

enrichmap.pl.gene_contributions_pca#

enrichmap.pl.gene_contributions_pca(adata: AnnData, score_key: str, top_n_genes: int = 5, highlight_genes: list[str] | None = None, figsize: tuple = (4, 4), fontsize: int = 8, save: str | None = None) None#

Visualise gene contributions to a spatial gene signature using PCA-reduced scatter plot.

Each point represents a gene’s contribution vector projected into 2D via PCA. The top contributing genes and any specified genes of interest can be highlighted.

Parameters:
  • adata (AnnData) – Annotated data matrix. Must contain gene_contributions for the given signature_name in adata.uns.

  • score_key (str) – Name of the gene signature whose gene contributions are to be visualised. Should match a key in adata.uns[“gene_contributions”].

  • top_n_genes (int, default 5) – Number of top genes (by vector norm) to highlight in the plot.

  • highlight_genes (list of str, optional) – Specific gene names to highlight, regardless of their contribution magnitude.

  • figsize (tuple, default (4, 4)) – Size of the resulting plot.

  • fontsize (int, default 8) – Font size used for gene labels in the plot.

  • save (str, optional) – Path to save the plot. If None, the plot is only shown and not saved.

Returns:

Displays the PCA plot and optionally saves it to a file.

Return type:

None

Raises:

ValueError – If gene_contributions for the specified signature is not found in adata.uns.