# dynamo.pl.causality

dynamo.pl.causality(adata, pairs_mat, hessian_matrix=False, xkey=None, ykey=None, zkey=None, log=True, drop_zero_cells=False, delay=0, k=30, normalize=True, grid_num=25, n_row=1, n_col=None, cmap='viridis', show_rug=True, show_extent=False, ext_format=None, stacked_fraction=False, figsize=(6, 4), save_show_or_return='show', save_kwargs={}, return_data=False, **kwargs)[source]

Plot the heatmap for the expected value $$y(t)$$ given $$x(t - d)$$ and $$y(t - 1)$$. This plotting function tries to intuitively visualize the informatioin transfer from $$x(t - d)$$ to $$y(t)$$ given $$y(t)$$’s previous state $$y(t - 1)$$. Firstly, we divide the expression space for $$x(t - d)$$ to $$y(t - 1)$$ based on grid_num and then we estimate the k-nearest neighbor for each of the grid. We then use a Gaussian kernel to estimate the expected value for $$y(t)$$. It is then displayed in two dimension with $$x(t - d)$$ and $$y(t - 1)$$ as two axis and the color represents the expected value of $$y(t)$$ give $$x(t - d)$$ and $$y(t - 1)$$. This function accepts a matrix where each row is the gene pair and the first column is the hypothetical source or regulator while the second column represents the hypothetical target. The name in this matrix should match the name in the gene_short_name column of the cds_subset object.

Parameters:
• adata (Anndata) – Annotated Data Frame, an Anndata object.

• hessian_matrix (bool) – Whether to visualize the Hessian matrix results (row, column are the regulatory/co-regulator gene expression while the color is the results of the Hessian to the effector).

• pairs_mat ('np.ndarray') – A matrix where each row is the gene pair and the first column is the hypothetical source or regulator while the second column represents the hypothetical target. The name in this matrix should match the name in the gene_short_name column of the adata object.

• log (bool (Default: True)) – A logic argument used to determine whether or not you should perform log transformation (using log(expression + 1)) before calculating density estimates, default to be TRUE.

• drop_zero_cells (bool (Default: True)) – Whether to drop cells that with zero expression for either the potential regulator or potential target. This can signify the relationship between potential regulators and targets, speed up the calculation, but at the risk of ignoring strong inhibition effects from certain regulators to targets.

• delay (int (Default: 1)) – The time delay between the source and target gene. Always zero because we don’t have real time-series.

• k (int (Default: 5)) – Number of k-nearest neighbors used in calculating 2-D kernel density

• grid_num (int (Default: 25)) – The number of grid when creating the lagged DREVI plot.

• n_row (int (Default: None)) – number of columns used to layout the faceted cluster panels.

• n_col (int (Default: 1)) – number of columns used to layout the faceted cluster panels.

• ext_format (None or str or List[str]) – The string/list of strings (the first is for x and second for y labels) that will be used to format the ticks on x or y-axis. If it is None or one of the element in the list is None, the default setting will be used.

• stacked_fraction (bool (default: False)) – If True the jacobian will be represented as a stacked fraction in the title, otherwise a linear fraction style is used.

• save_show_or_return (str {‘save’, ‘show’, ‘return’} (default: show)) – Whether to save, show or return the figure. If “both”, it will save and plot the figure at the same time. If “all”, the figure will be saved, displayed and the associated axis and other object will be return.

• 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”: ‘scatter’, “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.

Returns:

A figure created by matplotlib.