spapros.pl.selection_histogram

spapros.pl.selection_histogram(adata, selections_dict, x_axis_keys, background_key='highly_variable', penalty_kernels=None, penalty_keys=None, penalty_labels=None, upper_borders=None, lower_borders=None, size_factor=4.5, legend_size=11, show=True, save=None)

Plot histogram of quantiles for selected genes for different penalty kernels.

Parameters:
  • adata (AnnData) – sc.AnnData object containing the data for plotting the histogram in adata.var[x_axis_key].

  • selections_dict (Dict[str, DataFrame]) – Dictionary of dataframes with gene identifiers as index and a boolean column indicating the selection. The dictionary keys are used as label in the plot and need to be equivalent to the keys in penalty_kernels and penalty_keys.

  • x_axis_keys (Dict[str, str]) –

    Dictionary with the column in adata.var that is used for the x axis of the plotted histograms. There are two reasonable options:

    • If a penalty is plottet: the column containing the values of which the penalty scores were derived by applying the penalty kernel. Use the penalty_key as dictionary key in this case.

    • If no penalty is plottet: a column containing some statistic, eg. 99% quantile. Use the same keys as selection_dict in this case.

  • background_key (Union[str, Literal[False]]) – Key of column in adata.var which is plottet as background histogram. If False, no background histogram is plotted. If ‘all’, all genes are used as background.

  • penalty_kernels (Optional[Dict[str, Dict[str, Callable]]]) – Dictionary of penalty kernels, which were used for each selection. The outer key is the selection name. The inner keys are used as subplot titles. Additionally, penalty_keys can be provided. If both are None, only the histograms are plottet.

  • penalty_keys (Optional[Dict[str, List[str]]]) – Dictionary of a list of column keys of adata.var containing penalty scores for each selection. Additionally, penalty_kernels can be provided. If both are None, only the histograms are plottet.

  • penalty_labels (Optional[Dict[str, Dict[str, str]]]) – A legend label for each selection and each penalty. The keys of the outer dictionary need to be the selection names. As keys for the inner dictionary, use the penalty keys. I.e. penalty_labels[selection_label][penalty_key] = “some label”.

  • upper_borders (Optional[Union[bool, Dict[str, Union[float, bool]]]]) – Dictionary with the lower borders above which the kernels are 1, which is indicated as a vertical line in the plot. Use the same dictionay keys as penalty_keys or penalty_kernels. If None, it is automatically infered. If False or not in the dictionary, no vertical line at the upper border is drawn.

  • lower_borders (Optional[Union[bool, Dict[str, Union[float, bool]]]]) – Dictionary with the upper borders below which the kernels are 1, which is indicated as a vertical line in the plot. Use the same dictionay keys as penalty_keys or penalty_kernels. If None, it is automatically infered. If False or not in the dictionary, no vertical line at the lower border is drawn.

  • size_factor (float) – Factor for scaling the figure size.

  • legend_size (float) – Matplotlib legend size.

  • show (bool) – Whether to display the plot.

  • save (Optional[str]) – Save the plot to path.

Return type:

None

Returns: