ehrapy.plot.catplot

ehrapy.plot.catplot(adata, x=None, y=None, hue=None, kind='strip', **kwargs)[source]

Plot categorical data.

Wrapper around seaborn.catplot. Typically used to show the behaviour of one numerical variable with respect to one or several categorical variables.

Considers adata.obs only.

Parameters:
  • adata (AnnData) – AnnData object.

  • x (str, default: None) – Variable to plot on the x-axis.

  • y (str, default: None) – Variable to plot on the y-axis.

  • hue (str, default: None) – Variable to plot as different colors.

  • kind (str, default: 'strip') – Kind of plot to make. Options are: “point”, “bar”, “strip”, “swarm”, “box”, “violin”, “boxen”, or “count”.

  • **kwargs – Keyword arguments for seaborn.catplot.

Return type:

FacetGrid

Returns:

A Seaborn FacetGrid object for further modifications.

Examples

>>> import ehrapy as ep
>>> adata = ep.dt.diabetes_130_fairlearn()
>>> ep.ad.move_to_obs(adata, ["A1Cresult", "admission_source_id"], copy_obs=True)
>>> adata.obs["A1Cresult_measured"] = ~adata.obs["A1Cresult"].isna()
>>> ep.pl.catplot(
...     adata=adata,
...     y="A1Cresult_measured",
...     x="admission_source_id",
...     kind="point",
...     ci=95,
...     join=False,
... )
../../_images/catplot.png