boxplot_interactive

spac.visualization.boxplot_interactive(adata, annotation=None, layer=None, ax=None, features=None, showfliers=None, log_scale=False, orient='v', figure_width=3.2, figure_height=2, figure_dpi=200, defined_color_map=None, annotation_colorscale='viridis', feature_colorscale='seismic', figure_type='interactive', return_metrics=False, **kwargs)[source]

Generate a boxplot for given features from an AnnData object.

This function visualizes the distribution of gene expression (or other features) across different annotations in the provided data. It can handle various options such as log-transformation, feature selection, and handling of outliers.

Parameters:
  • adata (AnnData) – An AnnData object containing the data to plot. The expression matrix is accessed via adata.X or adata.layers[layer], and annotations are taken from adata.obs.

  • annotation (str, optional) – The name of the annotation column (e.g., cell type or sample condition) from adata.obs used to group the features. If None, no grouping is applied.

  • layer (str, optional) – The name of the layer from adata.layers to use. If None, adata.X is used.

  • ax (matplotlib.axes.Axes, optional) – The figure to plot the boxplot onto. If None, a new figure is created.

  • features (list of str, optional) – The list of features (genes) to plot. If None, all features are included.

  • showfliers ({None, "downsample", "all"}, default = None) – If ‘all’, all outliers are displayed in the boxplot. If ‘downsample’, when num outliers is >10k, they are downsampled to 10% of the original count. If None, outliers are hidden.

  • log_scale (bool, default=False) – If True, the log1p transformation is applied to the features before plotting. This option is disabled if negative values are found in the features.

  • orient ({"v", "h"}, default="v") – The orientation of the boxplots: “v” for vertical, “h” for horizontal.

  • figure_width (int, optional) – Width of the figure in inches. Default is 3.2.

  • figure_height (int, optional) – Height of the figure in inches. Default is 2.

  • figure_dpi (int, optional) – DPI (dots per inch) for the figure. Default is 200.

  • defined_color_map (str, optional) – Key in ‘adata.uns’ holding a pre-computed color dictionary. Falls back to automatic generation from ‘annotation’ values.

  • ax – A Matplotlib Axes object. Currently, this parameter is not used by the underlying plotting functions (Seaborn’s catplot/displot), which will always generate a new figure and axes. The ax key in the returned dictionary will contain the Axes from these new plots. This parameter is maintained for API consistency and potential future enhancements. Default is None.

  • **kwargs (dict) – Additional arguments for seaborn figure-level functions.

Returns:

figplotly.graph_objects.Figure or str
The generated boxplot figure, which can be either:
  • If figure_type is “static”: A base64-encoded PNG

image string - If figure_type is “interactive”: A Plotly figure object

dfpd.DataFrame

A DataFrame containing the features and their corresponding values.

metricspd.DataFrame

A DataFrame containing the computed boxplot metrics (if return_metrics is True).

Return type:

A dictionary containing the following keys