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={}, **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 (list) – The gene names whose gene expression will be faceted.

  • mode (str (default: vector_field)) – 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. By default potential estimated with the diffusion graph built from reconstructed vector field will be used as pseudotime when mode is pseudotime.

  • basis (str or None (default: None)) – The embedding data used for drawing the kinetic gene expression curves, only used when mode is vector_field.

  • layer (str (default: X)) – Which layer of expression value will be used. Not used if mode is vector_field.

  • project_back_to_high_dim (bool (default: False)) – 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’.

  • color (list or None (default: ‘ntr’)) – A list of attributes of cells (column names in the adata.obs) will be used to color cells.

  • tkey (str (default: potential)) – The .obs column that will be used for timing each cell, only used when mode is not vector_field.

  • dist_threshold (float (default: 1e-10)) – 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.

  • ncol (int (default: 4)) – Number of columns in each facet grid.

  • c_palette (Name of color_palette supported in seaborn color_palette function (default: None)) – The color map function to use.

  • standard_scale (int (default: 1)) – Either 0 (rows) or 1 (columns). Whether or not to standardize that dimension, meaning for each row or column, subtract the minimum and divide each by its maximum.

  • traj_ind (int (default: 0)) – 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.

  • log (bool (default: True)) – 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.

  • save_show_or_return ({‘show’, ‘save_fig’, ‘return’} (default: show)) – Whether to save_fig, show or return the figure.

  • save_kwargs (dict (default: {})) – A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig function will use the {“path”: None, “prefix”: ‘kinetic_curves’, “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.

  • color_map (str (default: BrBG)) – 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.

  • gene_order_method (str (default: half_max_ordering) [half_max_ordering, maximum]) – Supports two different methods for ordering genes when plotting the heatmap: either half_max_ordering, or maximum. 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.

  • show_colorbar (bool (default: False)) – Whether to show the color bar.

  • cluster_row_col ([bool, bool] (default: [False, False])) – Whether to cluster the row or columns.

  • figsize (str (default: (11.5, 6)) – Size of figure

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

  • n_convolve (int (default: 30)) – Number of cells for convolution.

  • traj_ind – 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.

  • log – 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.

  • gene_group (Optional[list]) – The key of the gene groups in .var.

  • gene_group_cmap (Optional[list]) – The str of the colormap for gene groups.

  • cell_group (Optional[list]) – The key of the cell groups in .obs.

  • cell_group_cmap (Optional[list]) – The str of the colormap for cell groups.

  • 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 the .uns[‘kinetic_heatmap’] is in the adata object, we will use data from .uns[‘kinetic_heatmap’] directly.

  • hline_rows (Optional[list]) – The indices of rows that we can place a line on the heatmap.

  • hlines_kwargs (dict) – The dictionary of arguments that will be passed into sns_heatmap.ax_heatmap.hlines.

  • vline_cols (Optional[list]) – The indices of column that we can place a line on the heatmap.

  • vlines_kwargs (dict) – The dictionary of arguments that will be passed into sns_heatmap.ax_heatmap.vlines.

  • save_show_or_return – Whether to save_fig, show or return the figure.

  • save_kwargs – A dictionary that will passed to the save_fig function. By default it is an empty dictionary and the save_fig 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.

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

Returns

Return type

Nothing but plots a heatmap that shows the gene expression dynamics over time.