omicverse.pl.plot_boxplots¶
- omicverse.pl.plot_boxplots(data, feature_name, modality_key='coda', y_scale='relative', plot_facets=False, add_dots=False, cell_types=None, args_boxplot=None, args_swarmplot=None, palette='Blues', show_legend=True, level_order=None, figsize=None, dpi=100, return_fig=None, ax=None, show=None, save=None)[source]¶
Grouped boxplot visualization.
The cell counts for each cell type are shown as a group of boxplots with intra–group separation by a covariate from data.obs.
- Parameters:
data – AnnData object or MuData object
feature_name (
str) – The name of the feature in data.obs to plotmodality_key (
str(default:'coda')) – If data is a MuData object, specify which modality to use.y_scale (default:
'relative') – Transformation to of cell counts. Options: “relative” - Relative abundance, “log” - log(count), “log10” - log10(count), “count” - absolute abundance (cell counts).plot_facets (
bool(default:False)) – If False, plot cell types on the x-axis. If True, plot as facets.add_dots (
bool(default:False)) – If True, overlay a scatterplot with one dot for each data point.cell_types (default:
None) – Subset of cell types that should be plotted.args_boxplot (default:
None) – Arguments passed to sns.boxplot.args_swarmplot (default:
None) – Arguments passed to sns.swarmplot.figsize (default:
None) – Figure size.dpi (default:
100) – Dpi setting.palette (default:
'Blues') – The seaborn color map for the barplot.show_legend (default:
True) – If True, adds a legend.level_order (default:
None) – Custom ordering of bars on the x-axis.
- Returns:
Depending on plot_facets, returns a
Axes(plot_facets = False) or: class:~sns.axisgrid.FacetGrid (plot_facets = True) object
Examples
>>> import pertpy as pt >>> haber_cells = pt.dt.haber_2017_regions() >>> sccoda = pt.tl.Sccoda() >>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", sample_identifier="batch", covariate_obs=["condition"]) >>> sccoda.plot_boxplots(mdata, feature_name="condition", add_dots=True)
- Preview: