pegasus.violin

pegasus.violin(data, attrs, groupby, hue=None, matkey=None, stripplot=False, scale='width', panel_size=(8, 0.5), left=0.15, bottom=0.15, wspace=0.1, ylabel=None, return_fig=False, dpi=300.0, **kwargs)[source]

Generate a stacked violin plot.

Parameters
  • data (AnnData or MultimodalData or UnimodalData object) – Single-cell expression data.

  • attrs (str or List[str]) – Cell attributes or features to plot. Cell attributes must exist in data.obs and must be numeric. Features must exist in data.var.

  • groupby (str) – A categorical variable in data.obs that is used to categorize the cells, e.g. Clusters.

  • hue (str, optional, default: None) – ‘hue’ should be a categorical variable in data.obs that has only two levels. Set ‘hue’ will show us split violin plots.

  • matkey (str, optional, default: None) – If matkey is set, select matrix with matkey as keyword in the current modality. Only works for MultimodalData or UnimodalData objects.

  • stripplot (bool, optional, default: False) – Attach a stripplot to the violinplot or not. This option will be automatically turn off if ‘hue’ is set.

  • scale (str, optional, default: width) –

    The method used to scale the width of each violin:
    • If width, each violin will have the same width.

    • If area, each violin will have the same area.

    • If count, the width of the violins will be scaled by the number of observations in that bin.

  • jitter (float or bool, optional, default: False) – Amount of jitter (only along the categorical axis) to apply to stripplot. This is used only when stripplot is set to True. This can be useful when you have many points and they overlap, so that it is easier to see the distribution. You can specify the amount of jitter (half the width of the uniform random variable support), or just use True for a good default.

  • panel_size (Tuple[float, float], optional, default: (8, 0.5)) – The size (width, height) in inches of each violin panel.

  • left (float, optional, default: 0.15) – This parameter sets the figure’s left margin as a fraction of panel’s width (left * panel_size[0]).

  • bottom (float, optional, default: 0.15) – This parameter sets the figure’s bottom margin as a fraction of panel’s height (bottom * panel_size[1]).

  • wspace (float, optional, default: 0.1) – This parameter sets the width between panels and also the figure’s right margin as a fraction of panel’s width (wspace * panel_size[0]).

  • ylabel (str, optional, default: None) – Y-axis label. No label to show if None.

  • return_fig (bool, optional, default: False) – Return a Figure object if True; return None otherwise.

  • dpi (float, optional, default: 300.0) – The resolution in dots per inch.

  • kwargs – Are passed to seaborn.violinplot.

Returns

A matplotlib.figure.Figure object containing the dot plot if show == False

Return type

Figure object

Examples

>>> pg.violin(data, attrs=['CD14', 'TRAC', 'CD34'], groupby='louvain_labels')