tacco.plots.annotated_heatmap

annotated_heatmap(adata, obs_key=None, var_key=None, n_genes=None, var_highlight=None, obs_colors=None, var_colors=None, cmap='bwr', cmap_center=0, cmap_vmin_vmax=(-2, 2), trafo=None, axsize=(4, 4))[source]

Plots a heatmap of cells and genes grouped by categorical annotations.

Parameters:
  • adata – An AnnData with annotation in .obs and/or .var.

  • obs_key – The .obs key with the categorical obs annotation to use. If None, the observations are not grouped and plotted in the order in which they appear in adata.

  • var_key – The .var key with the categorical var annotation to use. Can also be a mapping of annotations to list-likes of var names. If None, the genes are not grouped and plotted in the order in which they appear in adata. If n_genes is set, the meaning of this key is modified.

  • n_genes – The number of differentially expressed genes to find for the groups of observations. The differentially exressed genes will be used in place of a categorical var annotation. Setting n_genes changes the behaviour of var_key: It is interpreted as a categorical .obs key defining the groups of observations for which to derive the differentially expressed genes. If var_key is None, obs_key is used for that.

  • var_highlight – A list-like of var names to annotate.

  • obs_colors – A dict-like with the colors to use for the obs_key annotation. If None, default colors are used.

  • var_colors – A dict-like with the colors to use for the var_key annotation. If None, default colors are used, except if n_genes is set which triggers the usage of obs_colors for var_colors.

  • cmap – A string/colormap to use in the heatmap.

  • cmap_center – A value to use as center of the colormap. E.g. choosing 0 sets the central color to 0. If None, the colormap spans the entire value range.

  • cmap_vmin_vmax – A tuple giving the range of values for the colormap. This can be modfied by cmap_center.

  • trafo – Whether to normalize, logarithmize, and scale the data prior to plotting. This makes sense if bare count data is supplied. If the data is already preprocessed, this can be set to False. If None, a heuristic tries to figure out whether count data was supplied, and if so performs the preprocessing.

  • axsize – Tuple of width and size of the main axis.

Returns:

A Figure.