- spac.visualization.boxplot(adata, annotation=None, second_annotation=None, layer=None, ax=None, features=None, log_scale=False, **kwargs)[source]
Create a boxplot visualization of the features in the passed adata object. This function offers flexibility in how the boxplots are displayed, based on the arguments provided.
- Parameters:
adata (anndata.AnnData) – The AnnData object.
annotation (str, optional) – Annotation to determine if separate plots are needed for every label.
second_annotation (str, optional) – Second annotation to further divide the data.
layer (str, optional) – The name of the matrix layer to use. If not provided, uses the main data matrix adata.X.
ax (matplotlib.axes.Axes, optional) – An existing Axes object to draw the plot onto, optional.
features (list, optional) – List of feature names to be plotted. If not provided, all features will be plotted.
log_scale (bool, optional) – If True, the Y-axis will be in log scale. Default is False.
**kwargs –
Additional arguments to pass to seaborn.boxplot. Key arguments include: - orient: Determines the orientation of the plot. * “v”: Vertical orientation (default). In this case, categorical data
will be plotted on the x-axis, and the boxplots will be vertical.
- ”h”: Horizontal orientation. Categorical data will be plotted on the
y-axis, and the boxplots will be horizontal.
- Returns:
fig, ax – The created figure and axes for the plot.
- Return type:
matplotlib.figure.Figure, matplotlib.axes.Axes
Examples
Multiple features boxplot: boxplot(adata, features=[‘GeneA’,’GeneB’])
Boxplot grouped by a single annotation: boxplot(adata, features=[‘GeneA’], annotation=’cell_type’)
Boxplot for multiple features grouped by a single annotation: boxplot(adata, features=[‘GeneA’, ‘GeneB’], annotation=’cell_type’)
Nested grouping by two annotations: boxplot(adata, features=[‘GeneA’], annotation=’cell_type’, second_annotation=’treatment’)