dynamo.pl.response

dynamo.pl.response(adata, pairs_mat, xkey=None, ykey=None, log=True, drop_zero_cells=True, delay=0, grid_num=25, n_row=1, n_col=None, cmap=None, show_ridge=False, show_rug=True, zero_indicator=False, zero_line_style='w--', zero_line_width=2.5, mean_style='c*', fit_curve=False, fit_mode='hill', curve_style='c-', curve_lw=2.5, no_degradation=True, show_extent=False, ext_format=None, stacked_fraction=False, figsize=(6, 4), save_show_or_return='show', save_kwargs={}, return_data=False)[source]

Plot the lagged DREVI plot pairs of genes across pseudotime.

This plotting function builds on the original idea of DREVI plot but is extended in the context for causal network. It considers the time delay between the hypothetical regulators to the target genes which is parametered by d. Lagged DREVI plot first estimates the joint density (P(x_{t - d}, y_t)) for variables x_{t - d} and y_t, then it divides the joint density by the marginal density P(x_{t - d}) to get the conditional density estimate (P(x_{t - d}, y_t | x_{x - d})). We then calculate the z-score normalizing each column of conditional density. Note that this plot tries to demonstrate the potential influence between two variables instead of the factual influence. A red line corresponding to the point with maximal density on each x value is plot which indicates the maximal possible point for y_t give the value of x_{t - d}. The 2-d density is estimated through the kde2d function.

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

  • pairs_mat (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.

  • xkey (Optional[str]) – the key of the layer storing x data. Defaults to None.

  • ykey (Optional[str]) – the key of the layer storing y data. Defaults to None.

  • log (bool) – whether to perform log transformation (using log(expression + 1)) before calculating density estimates. Defaults to True.

  • drop_zero_cells (bool) – 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. Defaults to True.

  • delay (int) – the time delay between the source and target gene. Always zero because we don’t have real time-series. Defaults to 0.

  • grid_num (int) – the number of grid when creating the lagged DREVI plot. Defaults to 25.

  • n_row (int) – number of rows used to layout the faceted cluster panels. Defaults to 1.

  • n_col (Optional[int]) – number of columns used to layout the faceted cluster panels. Defaults to None.

  • cmap (Union[str, Colormap, None]) – the color map used to plot the heatmap. Could be the name of the color map or a matplotlib color map object. If None, the color map would be generated automatically. Defaults to None.

  • show_ridge (bool) – whether to show the ridge curve. Defaults to False.

  • show_rug (bool) – whether to plot marginal distributions by drawing ticks along the x and y axes. Defaults to True.

  • zero_indicator (bool) – whether to plot the zero line in the graph. Defaults to False.

  • zero_line_style (str) – line style of the zero line. Defaults to “w–“.

  • zero_line_width (float) – line width of the zero line. Defaults to 2.5.

  • mean_style (str) – the line style for plotting the y mean data. Defaults to “c*”.

  • fit_curve (bool) – whether to fit the curve between x and y. Defaults to False.

  • fit_mode (Literal['hill']) – the fitting mode for fitting the curve between x and y. Currently, the relationship can only be fit into Hill function. Defaults to “hill”.

  • curve_style (str) – the line style of fitted curve. Defaults to “c-“.

  • curve_lw (float) – the line width of the fitted curve. Defaults to 2.5.

  • no_degradation (bool) – whether to consider degradation when fitting Hill equations. Defaults to True.

  • show_extent (bool) – whether to extend the figure. If False, show_ridge and show_rug would be set to False automatically. Defaults to False.

  • ext_format (Optional[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. Defaults to None.

  • stacked_fraction (bool) – If True the jacobian will be represe nted as a stacked fraction in the title, otherwise a linear fraction tyle is used. Defaults to False.

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

  • save_show_or_return (Literal['save', 'show', 'both', 'all']) – whether to save or show 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[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”: ‘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. Defaults to {}.

  • return_data (bool) – whether to return the data used to generate the heatmap. Defaults to False.

Raises:
Return type:

Union[Tuple[DataFrame, DataFrame, DataFrame], Tuple[DataFrame, DataFrame, DataFrame, Dict[str, Dict[str, Any]]], None]

Returns:

None would be returned in default. If return_data is set to be True, a tuple (flat_res, flat_res_subset, ridge_curve_subset) would be returned, where flat_res is a pandas data frame used to create the heatmap with four columns (x: x-coordinate; y: y-coordinate; den: estimated density at x/y coordinate; type: the corresponding gene pair), flat_res_subset is a pandas data frame used to create the heatmap for the last gene pair (if multiple gene-pairs are inputted) with four columns (x: x-coordinate; y: y-coordinate; den: estimated density at x/y coordinate; type: the corresponding gene pair), and ridge_curve_subset is a pandas data frame used to create the read ridge line for the last gene pair (if multiple gene-pairs are inputted) with four columns (x: x-coordinate; y: y-coordinate; type: the corresponding gene pair). If fit_curve is True, the hill function fitting result would also be returned at the 4th position.