scrnatools.plotting.gene_heatmap
- scrnatools.plotting.gene_heatmap(adata: AnnData, gene_list: List[str], obs_key: str, layer: str = 'X', obs_values: List[str] = ['All'], cbar_args: List[int] | None = None, swap_axes: bool = False, cell_size: int = 30, save_path: str | None = None, dpi: int = 300, *args, **kwargs)[source]
Plots a heatmap of expression of genes.
- Parameters:
adata (AnnData) – The dataset containing the gene expression and cell data.
gene_list (List[str]) – A list of genes to plot.
obs_key (str) – The categorical grouping to display on the heatmap.
layer (str, optional) – The type of the expression data to use for the heatmap, can be a layer in ‘adata.layers’ or ‘X’ to use the data stored in adata.X. Defaults to “X”.
obs_values (List[str], optional) – Values from obs key group to display on heatmap. Defaults to [‘All’].
cbar_args (List[int], optional) – List of integers to position color bar on heatmap. [x position, y position, width, height]. ‘None’ automatically adjusts to right middle of heatmap.. Defaults to None.
swap_axes (bool, optional) – AWhether to swap x and y axes. Defaults to False.
cell_size (int, optional) – Integer specifying the size of each cell in the heatmap. Defaults to 30.
save_path (str, optional) – The path to save the figure. Defaults to None.
dpi (int, optional) – The resolution of the saved image. Defaults to 300.
- Raises:
ValueError – If a gene in ‘gene_list’ provided is not in provided AnnData layer.
ValueError – If ‘gene_list’ provided less than 2.
ValueError – If the ‘obs_values’ provided less than 2.
ValueError – If a value in ‘obs_values’ provided is not in provided AnnData layer obs key.