dynamo.pl.kinetic_heatmap

dynamo.pl.kinetic_heatmap(adata, genes, mode='vector_field', basis=None, layer='X', project_back_to_high_dim=True, tkey='potential', dist_threshold=1e-10, color_map='BrBG', gene_order_method='maximum', show_colorbar=False, cluster_row_col=[False, False], figsize=(11.5, 6), standard_scale=1, n_convolve=30, spaced_num=100, traj_ind=0, log=True, gene_group=None, gene_group_cmap=None, cell_group=None, cell_group_cmap=None, enforce=False, hline_rows=None, hlines_kwargs={}, vline_cols=None, vlines_kwargs={}, save_show_or_return='show', save_kwargs={}, transpose=False, **kwargs)[source]

Plot the gene expression dynamics over time (pseudotime or inferred real time) in a heatmap.

Note that by default potential estimated with the diffusion graph built from reconstructed vector field will be used as the measure of pseudotime.

Parameters:
  • adata (AnnData) – an Annodata object.

  • genes (Union[List[str], Index]) – the gene names whose gene expression will be faceted.

  • mode (str) – which data mode will be used, either vector_field, lap or pseudotime. if mode is vector_field, the trajectory predicted by vector field function will be used; if mode is lap, the trajectory predicted by least action path will be used otherwise pseudotime trajectory (defined by time argument) will be used. Defaults to “vector_field”.

  • basis (Optional[str]) – the embedding data used for drawing the kinetic gene expression curves, only used when mode is vector_field. Defaults to None.

  • layer (str) – the key to the layer of expression value will be used. Not used if mode is vector_field. Defaults to “X”.

  • project_back_to_high_dim (bool) – whether to map the coordinates in low dimension back to high dimension to visualize the gene expression curves, only used when mode is vector_field and basis is not X. Currently only works when basis is ‘pca’ and ‘umap’. Defaults to True.

  • tkey (str) – the .obs column that will be used for timing each cell, only used when mode is not vector_field. Defaults to “potential”.

  • dist_threshold (float) – the threshold for the distance between two points in the gene expression state, i.e, x(t), x(t+1). If below this threshold, we assume steady state is achieved and those data points will not be considered. This argument is ignored when mode is pseudotime. Defaults to 1e-10.

  • color_map (int) – the color map that will be used to color the gene expression. If half_max_ordering is True, the color map need to be divergent, good examples, include BrBG, RdBu_r or coolwarm, etc. Defaults to “BrBG”.

  • gene_order_method (Literal['maximum', 'half_max_ordering', 'raw']) – supports three different methods for ordering genes when plotting the heatmap: either half_max_ordering, maximum or raw. For half_max_ordering, it will order genes into up, down and transit groups by the half max ordering algorithm (HA Pliner, et al., Molecular cell 71 (5), 858-871. e8). While for maximum, it will order by the position of the highest gene expression. raw means just use the original order from the input gene list. Defaults to “maximum”.

  • show_colorbar (bool) – whether to show the color bar. Defaults to False.

  • cluster_row_col (List[bool]) – whether to cluster the row or columns. Defaults to (False, False).

  • figsize (Tuple[float, float]) – size of figure. Defaults to (11.5, 6).

  • standard_scale (int) – either 0 (rows, cells) or 1 (columns, genes). Whether to standardize that dimension, meaning for each row or column, subtract the minimum and divide each by its maximum. Defaults to 1.

  • n_convolve (int) – the number of cells for convolution. Defaults to 30.

  • spaced_num (int) – the number of points on the loess fitting curve. Defaults to 100.

  • traj_ind (int) – if the element from the dictionary is a list (obtained from a list of trajectories), the index of trajectory that will be selected for visualization.. Defaults to 0.

  • log (bool) – whether to log1p transform your data before data visualization. If expression data is from adata object, it is generally already log1p transformed. When the data is from predicted either from traj simulation or LAP, the data is generally in the original gene expression space and needs to be log1p transformed. Note: when predicted data is not inverse transformed back to original expression space, no transformation will be applied. Defaults to True.

  • gene_group (Optional[List[str]]) – the key of the gene groups in .var. Defaults to None.

  • gene_group_cmap (Optional[List[str]]) – the str of the colormap for gene groups. Defaults to None.

  • cell_group (Optional[List[str]]) – the key of the cell groups in .obs. Defaults to None.

  • cell_group_cmap (Optional[List[str]]) – the str of the colormap for cell groups. Defaults to None.

  • enforce (bool) – whether to recalculate the dataframe that will be used to create the kinetic heatmap. If this is set to be False and the .uns[‘kinetic_heatmap’] is in the adata object, we will use data from .uns[‘kinetic_heatmap’] directly.. Defaults to False.

  • hline_rows (Optional[List[int]]) – the indices of rows that we can place a line on the heatmap. Defaults to None.

  • hlines_kwargs (Dict[str, Any]) – a dictionary of arguments that will be passed into sns_heatmap.ax_heatmap.hlines. Defaults to {}.

  • vline_cols (Optional[List[int]]) – the indices of column that we can place a line on the heatmap. Defaults to None.

  • vlines_kwargs (Dict[str, Any]) – a dictionary of arguments that will be passed into sns_heatmap.ax_heatmap.vlines. Defaults to {}.

  • save_show_or_return (Literal['save', 'show', 'return']) – whether to save, show, or return the figure. Defaults to “show”.

  • save_kwargs (Dict[str, Any]) – a dictionary that will be passed to the save_show_ret function. By default, it is an empty dictionary and the save_show_ret function will use the {“path”: None, “prefix”: ‘kinetic_heatmap’, “dpi”: None, “ext”: ‘pdf’, “transparent”: True, “close”: True, “verbose”: True} as its parameters. Otherwise, you can provide a dictionary that properly modify those keys according to your needs. Defaults to {}.

  • transpose (bool) – whether to transpose the dataframe and swap X-Y in heatmap. In single cell case, transpose=True results in gene on the x-axis. Defaults to False.

  • **kwargs – any other keyword arguments are passed to heatmap(). Currently xticklabels=False, yticklabels=’auto’ is passed to heatmap() by default.

Raises:

NotImplementedError – invalid order_method.

Return type:

Optional[ClusterGrid]

Returns:

None would be returned by default. If save_show_or_return is set to be ‘return’, the generated seaborn ClusterGrid would be returned.